Returns a list of instruction offsets in the supplied bytecode
    which are the targets of some sort of jump instruction.
427865
def get_jump_targets(code, opc):
    
    offsets = []
    for offset, op, arg in unpack_opargs_wordcode(code, opc):
        if arg is not None:
            if op in opc.JREL_OPS:
                jump_offset = offset + 2 + arg
            elif op in opc.JABS_OPS:
                jump_offset = arg
            else:
                continue
            if jump_offset not in offsets:
                offsets.append(jump_offset)
    return offsets
1200611
def is_jump_back(self, offset, extended_arg):
        
        if self.code[offset] != self.opc.JUMP_ABSOLUTE:
            return False
        return offset > self.get_target(offset, extended_arg)
977324
def _get_bits(bits=None, target=None):
    

    if bits is not None:
        bits = int(bits)
        if bits in (8, 16, 32, 64):
            return bits
        else:
            raise ValueError('bits needs to be 8, 16, 32 or 64')
    else:
        return int((target if target is not None else pwnypack.target.target).bits)
1080896
public boolean containsInstructionWithOffset(int offset) {
        Iterator<InstructionHandle> i = instructionIterator();
        while (i.hasNext()) {
            if (i.next().getPosition() == offset) {
                return true;
            }
        }
        return false;
    }
136406
def lookup(instruction, instructions = None):
    
    if instructions is None:
        instructions = default_instructions

    if isinstance(instruction, str):
        return instructions[instruction]
    elif hasattr(instruction, "__call__"):
        rev = dict(((v,k) for (k,v) in instructions.items()))
        return rev[instruction]
    else:
        raise errors.MachineError(KeyError("Unknown instruction: %s" %
            str(instruction)))
146620
def _states_to_dfa_bytecode(self, states, \
      tran=None, \
      debug=False, \
      compiled_states=None, \
      gathered_epsilons=None, \
      cached_transitions=None, \
      cached_tcode=None, \
      reltags_cache=None \
      ):
    ''''''
    pstates = copy.copy(states)

    if reltags_cache == None:
      reltags_cache = {}

    if cached_tcode == None:
      cached_tcode = {}

    if cached_transitions == None:
      cached_transitions = {}

    if gathered_epsilons == None:
      gathered_epsilons = {}

    self._add_epsilon_states(states, gathered_epsilons)

    if tran != None:
      states = self.nextstates(states, tran)
      self._add_epsilon_states(states, gathered_epsilons)

    if self._magic != None:
      states = states.union(self._magic(states))

    tstates = tuple(states)

    # this is used so we only compile each stateset once
    if compiled_states == None:
      compiled_states = {}

    if tstates in compiled_states:
      return compiled_states[tstates]

    # grab the ip from our codeblock
    ip = self._bytecode.newblock(tstates)
    compiled_states[tstates] = ip

    # TODO
    # epsilon transitions are never 'taken' so we need
    # to insert any ltagv/utagv instructions required
    # for all epsilon transitions
    # gathered_epsilons[state] holds a dictionary of dst: src mappings, so we can use that data

    if self.do_tags:
      tags = set()
      rtags = set()
  
      for ts in pstates:
        for dst in gathered_epsilons[ts]:
          rtags.update(self.reltags(dst, reltags_cache))
          src = gathered_epsilons[ts][dst]
          if self.is_tagged(NFA.EPSILON, src, dst):
            tags.add((self.tag(NFA.EPSILON, src, dst), dst))
  
      self._write_transition_code(tags, rtags, ip)

    # run any defined state hooks
    for s in tstates:
      if s in self._state_hooks:
        ip.append(VM.PyCode(self._state_hooks[s]))

    # do a multi-match for any final states
    finals = self._final_states.intersection(states)
    if len(finals) > 0:
      ip.append(VM.MultiMatch(finals))

    # do any interupts required
    interupts = self._interupt_states.intersection(states)
    if len(interupts) > 0:
      ip.append(VM.MultiInterupt(interupts))

    # consume a character
    ip.append(VM.Consume())

    ts = self.transitions(states, cached_transitions)

    if debug:
      print 'compiling bytecode for stateset:\n\t%s\n\t0x%x: %s' % (states,ip,(defaults,ts))

    def mkbytecode(t):
      return lambda: self._transitions_to_dfa_bytecode(states, t, cached_tcode, debug=debug, compiled_states=compiled_states, gathered_epsilons=gathered_epsilons, cached_transitions=cached_transitions, reltags_cache=reltags_cache)

    # for any of the non-default states add a conditional jmp
    for k in ts:

      if k in (NFA.ANY, NFA.EPSILON):
        continue

      jmppoint = VM.DelayedArg(mkbytecode(k))
      ip.append(VM.Compare(k))
      ip.append(VM.CondJmp(jmppoint))

    # jmp to default state if there is one, otherwise leave
    defaults = self.nextstates(states, NFA.ANY)
    if len(defaults) > 0:
      jmppoint = VM.DelayedArg(mkbytecode(NFA.ANY))
      ip.append(VM.Jmp(jmppoint))
    else:
      ip.append(VM.Leave())

    # return the instruction pointer
    return ip
753132
@Override
    public void sawOpcode(int seen) {
        if (downwardBranchTarget == -1) {
            switch (state) {
                case SAW_NOTHING:
                    sawOpcodeAfterNothing(seen);
                break;

                case SAW_LOAD:
                    sawOpcodeAfterLoad(seen);
                break;

                case SAW_CHECKCAST:
                    sawOpcodeAfterCheckCast(seen);
                break;
            }

            int insTarget = -1;
            if (((seen >= Const.IFEQ) && (seen <= Const.IF_ACMPNE)) || (seen == Const.GOTO) || (seen == Const.GOTO_W)) {
                insTarget = getBranchTarget();
                if (insTarget < getPC()) {
                    insTarget = -1;
                }
            } else if ((seen == Const.LOOKUPSWITCH) || (seen == Const.TABLESWITCH)) {
                insTarget = this.getDefaultSwitchOffset() + getPC();
            }

            if (insTarget > downwardBranchTarget) {
                downwardBranchTarget = insTarget;
            }
        } else {
            state = State.SAW_NOTHING;
            if (getPC() >= downwardBranchTarget) {
                downwardBranchTarget = -1;
            }
        }
    }
316403
public MMAXPointer getPointerList(int i) {
    if (MMAXAnnotation_Type.featOkTst && ((MMAXAnnotation_Type)jcasType).casFeat_pointerList == null)
      jcasType.jcas.throwFeatMissing("pointerList", "de.julielab.jules.types.mmax.MMAXAnnotation");
    jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((MMAXAnnotation_Type)jcasType).casFeatCode_pointerList), i);
    return (MMAXPointer)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((MMAXAnnotation_Type)jcasType).casFeatCode_pointerList), i)));}
522694
private byte encodeTargetDiscriminator() {
        byte result = 0;
        if (Positions.isReadable(targetPosition)) {
            result |= 1;
        }
        if (Positions.isWritable(targetPosition)) {
            result |= 2;
        }
        return result;
    }
1042608
def findlinestarts(code, dup_lines=False):
    
    if not isinstance(code.co_lnotab, str):
        byte_increments = list(code.co_lnotab[0::2])
        line_increments = list(code.co_lnotab[1::2])
    else:
        byte_increments = [ord(c) for c in code.co_lnotab[0::2]]
        line_increments = [ord(c) for c in code.co_lnotab[1::2]]

    lastlineno = None
    lineno = code.co_firstlineno
    offset = 0
    for byte_incr, line_incr in zip(byte_increments, line_increments):
        if byte_incr:
            if (lineno != lastlineno or
                (dup_lines and 0 < byte_incr < 255)):
                yield (offset, lineno)
                lastlineno = lineno
                pass
            offset += byte_incr
            pass
        lineno += line_incr
    if (lineno != lastlineno or
        (dup_lines and 0 < byte_incr < 255)):
        yield (offset, lineno)
808917
private static Set<Integer> find(final Predicate<Instruction> predicate, final List<Instruction> instructions) {
        final Set<Integer> positions = new HashSet<>();

        for (int i = 0; i < instructions.size(); i++) {
            final Instruction instruction = instructions.get(i);
            if (predicate.test(instruction)) {
                positions.add(i);
            }
        }

        return positions;
    }
756868
private int loadBinaryOffsets(RandomAccessFile binarySSpace) 
            throws IOException {

        // Reader off the 4-byte header if it exists
        if (containsHeader)
            binarySSpace.readInt();
    
        int rows = binarySSpace.readInt();
        int cols = binarySSpace.readInt();

        for (int row = 0; row < rows; ++row) {
            String word = binarySSpace.readUTF();
            termToOffset.put(word, binarySSpace.getFilePointer());
            // read and discard the rest of the vector
            for (int col = 0; col < cols; ++col) {
                binarySSpace.readDouble();
            }
        }
        return cols;
    }
454424
def operands(self):
        
        if not self.is_instruction:
            raise ValueError('expected instruction value, got %s'
                             % (self._kind,))
        it = ffi.lib.LLVMPY_InstructionOperandsIter(self)
        parents = self._parents.copy()
        parents.update(instruction=self)
        return _OperandsIterator(it, parents)
1188187
public static long getOffsetUnsafe(DataBuffer shapeInformation, int dim0, int dim1, int dim2) {
        long offset = 0;
        int size_0 = sizeUnsafe(shapeInformation, 0);
        int size_1 = sizeUnsafe(shapeInformation, 1);
        int size_2 = sizeUnsafe(shapeInformation, 2);
        if (dim0 >= size_0 || dim1 >= size_1 || dim2 >= size_2)
            throw new IllegalArgumentException("Invalid indices: cannot get [" + dim0 + "," + dim1 + "," + dim2
                    + "] from a " + Arrays.toString(shape(shapeInformation)) + " NDArray");

        if (size_0 != 1)
            offset += dim0 * strideUnsafe(shapeInformation, 0, 3);
        if (size_1 != 1)
            offset += dim1 * strideUnsafe(shapeInformation, 1, 3);
        if (size_2 != 1)
            offset += dim2 * strideUnsafe(shapeInformation, 2, 3);

        return offset;
    }
728881
def position_code(code_start)
      assemblers.each do |asm|
        Position.log.debug "Method start #{code_start.to_s(16)} #{asm.callable.name}"
        code_pos = CodeListener.init(asm.callable.binary, platform)
        instructions = asm.instructions
        InstructionListener.init( instructions, asm.callable.binary)
        code_pos.position_listener( LabelListener.new(instructions))
        code_pos.set(code_start)
        code_start = Position.get(asm.callable.binary.last_code).next_slot
      end
    end
541476
synchronized List<PageWrapper> getPagesSortedByOffset() {
        return this.pageByOffset
                .values().stream()
                .sorted(Comparator.comparingLong(PageWrapper::getOffset))
                .collect(Collectors.toList());
    }
626020
def disassemble(bytecode):
    

    offset = 0
    end = len(bytecode)

    while offset < end:
        orig_offset = offset

        code = bytecode[offset]
        if not isinstance(code, int):   # Py3
            code = ord(code)

        offset += 1

        args = tuple()
        fmt = get_arg_format(code)
        if fmt:
            args, offset = fmt(bytecode, offset)

        yield (orig_offset, code, args)