Compares & pops top 2 operands out of the stack, and checks
        if the 1st operand > 2nd operand (top of the stack).
        Pushes 0 if False, 1 if True.

        16 bit unsigned version
343808
def _gtu16(ins):
    ''' 
    '''
    output = _16bit_oper(ins.quad[2], ins.quad[3], reversed=True)
    output.append('or a')
    output.append('sbc hl, de')
    output.append('sbc a, a')
    output.append('push af')
    return output
1157735
public int expectUInt16() throws IOException {
        int b1 = in.read();
        if (b1 < 0) {
            throw new IOException("Missing byte 1 to expected uint16");
        }
        int b2 = in.read();
        if (b2 < 0) {
            throw new IOException("Missing byte 2 to expected uint16");
        }
        return unshift2bytes(b1, b2);
    }
991089
def _8bit_oper(op1, op2=None, reversed_=False):
    
    output = []

    if op2 is not None and reversed_:
        tmp = op1
        op1 = op2
        op2 = tmp

    op = op1
    indirect = (op[0] == '*')
    if indirect:
        op = op[1:]

    immediate = (op[0] == '#')
    if immediate:
        op = op[1:]

    if is_int(op):
        op = int(op)

        if indirect:
            output.append('ld a, (%i)' % op)
        else:
            if op == 0:
                output.append('xor a')
            else:
                output.append('ld a, %i' % int8(op))
    else:
        if immediate:
            if indirect:
                output.append('ld a, (%s)' % op)
            else:
                output.append('ld a, %s' % op)
        elif op[0] == '_':
            if indirect:
                idx = 'bc' if reversed_ else 'hl'
                output.append('ld %s, (%s)' % (idx, op))  # can't use HL
                output.append('ld a, (%s)' % idx)
            else:
                output.append('ld a, (%s)' % op)
        else:
            if immediate:
                output.append('ld a, %s' % op)
            elif indirect:
                idx = 'bc' if reversed_ else 'hl'
                output.append('pop %s' % idx)
                output.append('ld a, (%s)' % idx)
            else:
                output.append('pop af')

    if op2 is None:
        return output

    if not reversed_:
        tmp = output
        output = []

    op = op2
    indirect = (op[0] == '*')
    if indirect:
        op = op[1:]

    immediate = (op[0] == '#')
    if immediate:
        op = op[1:]

    if is_int(op):
        op = int(op)

        if indirect:
            output.append('ld hl, (%i - 1)' % op)
        else:
            output.append('ld h, %i' % int8(op))
    else:
        if immediate:
            if indirect:
                output.append('ld hl, %s' % op)
                output.append('ld h, (hl)')
            else:
                output.append('ld h, %s' % op)
        elif op[0] == '_':
            if indirect:
                output.append('ld hl, (%s)' % op)
                output.append('ld h, (hl)' % op)
            else:
                output.append('ld hl, (%s - 1)' % op)
        else:
            output.append('pop hl')

        if indirect:
            output.append('ld h, (hl)')

    if not reversed_:
        output.extend(tmp)

    return output
1106343
def top(bits, name=None, uninitialized=False):
        
        return StridedInterval(name=name,
                               bits=bits,
                               stride=1,
                               lower_bound=0,
                               upper_bound=StridedInterval.max_int(bits),
                               uninitialized=uninitialized)
508822
def BE16(value, min_value=None, max_value=None, fuzzable=True, name=None, full_range=False):
    ''''''
    return UInt16(value, min_value=min_value, max_value=max_value, encoder=ENC_INT_BE, fuzzable=fuzzable, name=name, full_range=full_range)
1016775
def _lti16(ins):
    ''' 
    '''
    output = _16bit_oper(ins.quad[2], ins.quad[3])
    output.append('call __LTI16')
    output.append('push af')
    REQUIRES.add('lti16.asm')
    return output
1058731
def _ret16(ins):
    
    output = _16bit_oper(ins.quad[1])
    output.append('#pragma opt require hl')
    output.append('jp %s' % str(ins.quad[2]))
    return output
576771
def _loadf16(ins):
    
    output = _f16_oper(ins.quad[2])
    output.append('push de')
    output.append('push hl')
    return output
88436
def _eq8(ins):
    
    if is_int(ins.quad[3]):
        output = _8bit_oper(ins.quad[2])
        n = int8(ins.quad[3])
        if n:
            if n == 1:
                output.append('dec a')
            else:
                output.append('sub %i' % n)
    else:
        output = _8bit_oper(ins.quad[2], ins.quad[3])
        output.append('sub h')

    output.append('sub 1')  # Sets Carry only if 0
    output.append('sbc a, a')
    output.append('push af')

    return output
421179
def ones_comp_sum16(num1: int, num2: int) -> int:
    

    carry = 1 << 16
    result = num1 + num2
    return result if result < carry else result + 1 - carry
843907
def _astore16(ins):
    ''' 
    '''
    output = _addr(ins.quad[1])
    op = ins.quad[2]

    indirect = op[0] == '*'
    if indirect:
        op = op[1:]

    immediate = op[0] == '#'
    if immediate:
        op = op[1:]

    if is_int(op):
        op = str(int(op) & 0xFFFF)  # Truncate to 16bit pointer

        if indirect:
            if immediate:
                output.append('ld de, (%s)' % op)
            else:
                output.append('ld de, (%s)' % op)
                output.append('call __LOAD_DE_DE')
                REQUIRES.add('lddede.asm')
        else:
            H = int(op) >> 8
            L = int(op) & 0xFF
            output.append('ld (hl), %i' % L)
            output.append('inc hl')
            output.append('ld (hl), %i' % H)
            return output

    elif op[0] == '_':
        if indirect:
            if immediate:
                output.append('ld de, (%s)' % op)  # redundant: *#_id == _id
            else:
                output.append('ld de, (%s)' % op)  # *_id
                output.append('call __LOAD_DE_DE')
                REQUIRES.add('lddede.asm')
        else:
            if immediate:
                output.append('ld de, %s' % op)
            else:
                output.append('ld de, (%s)' % op)
    else:
        output.append('pop de')

    output.append('ld (hl), e')
    output.append('inc hl')
    output.append('ld (hl), d')

    return output
398706
public int readUInt16() throws IOException {
        int b1 = in.read();
        if (b1 < 0) {
            return 0;
        }
        int b2 = in.read();
        if (b2 < 0) {
            throw new IOException("Missing byte 2 to read uint16");
        }
        return unshift2bytes(b1, b2);
    }
463987
def _ltu16(ins):
    ''' 
    '''
    output = _16bit_oper(ins.quad[2], ins.quad[3])
    output.append('or a')
    output.append('sbc hl, de')
    output.append('sbc a, a')
    output.append('push af')
    return output
1148230
def _neg16(ins):
    ''' 
    '''
    output = _16bit_oper(ins.quad[2])
    output.append('call __NEGHL')
    output.append('push hl')
    REQUIRES.add('neg16.asm')
    return output
980303
public static boolean unsignedIntersects(ShortBuffer set1, int length1, ShortBuffer set2,
      int length2) {
    if ((0 == length1) || (0 == length2)) {
      return false;
    }
    int k1 = 0;
    int k2 = 0;

    // could be more efficient with galloping
    short s1 = set1.get(k1);
    short s2 = set2.get(k2);

    mainwhile: while (true) {
      if (toIntUnsigned(s2) < toIntUnsigned(s1)) {
        do {
          ++k2;
          if (k2 == length2) {
            break mainwhile;
          }
          s2 = set2.get(k2);
        } while (toIntUnsigned(s2) < toIntUnsigned(s1));
      }
      if (toIntUnsigned(s1) < toIntUnsigned(s2)) {
        do {
          ++k1;
          if (k1 == length1) {
            break mainwhile;
          }
          s1 = set1.get(k1);
        } while (toIntUnsigned(s1) < toIntUnsigned(s2));
      } else {
        return true;
      }
    }
    return false;
  }
330531
private static int compareLexical(BitVector a, BitVector b) {
		final int aSize = a.size();
		final int bSize = b.size();
		if (aSize == bSize) return compareNumeric(a, b); // more efficient
		final int size = Math.min(aSize, bSize);
		final int aStart = a.finish - size;
		final int bStart = b.finish - size;
		for (int i = size - 1; i >= 0; i--) {
			boolean aBit = a.getBitAdj(aStart + i);
			boolean bBit = b.getBitAdj(bStart + i);
			if (aBit != bBit) return bBit ? -1 : 1;
		}
		return aSize < bSize ? -1 : 1;
	}
1284716
def is_top(self):
        
        return (self.stride == 1 and
                self.lower_bound == self._modular_add(self.upper_bound, 1, self.bits)
                )