@staticmethod
  def resolve_jump_targets(bytecode, new_co):
    new_bytecode = []
    bc_indices = Merger.build_bytecode_offsets(new_co, bytecode)
    length = len(bc_indices)

    def find_target_index(target, j, instr_counter, current_index, op):
      direction = 1
      is_absolute = False
      if op in opcode.hasjabs:
        direction = 1 if target > current_index else -1
        is_absolute = True
      else:
        direction = 1 if target >= 0 else -1
      bound = -1 if direction < 0 else length

      # Search in the same instrumentation code if the target address is
      # already present. If so, we just return that one.
      k = j
      while k != bound:
        if bytecode[k][0][0] == target and bytecode[k][1] == instr_counter:
          return k
        k += direction

      # If we didn't find a match for the jump, we need to look outside of the
      # bounds of the same source code.
      k = j
      current_pos = bc_indices[j]
      increment = (bytecode[j][0][3] - bytecode[j][0][0]) if is_absolute else (bytecode[j][0][3] + 3)
      idx = bc_indices.index(current_pos + increment)
      return idx


    i = 0
    for bc_tpl in bytecode:
      op, arg, index, instr = bc_tpl[0][2], bc_tpl[0][3], bc_tpl[0][0], bc_tpl[1]
      if not CodeObject.is_jump_op(op):
        new_bytecode.append(((bc_indices[i], bc_tpl[0][1], bc_tpl[0][2], \
                              bc_tpl[0][3], bc_tpl[0][4], bc_tpl[0][5]), \
                             instr))
      else:
        new_address = -1
        target_address = arg if op in opcode.hasjabs else (index + 3 + arg)
        target_index = find_target_index(target_address, i, instr, index, op)

        if op in opcode.hasjrel:
          new_address = bc_indices[target_index] - bc_indices[i] - 3
        else:
          new_address = bc_indices[target_index]

        new_bytecode.append(((bc_indices[i], bc_tpl[0][1], bc_tpl[0][2], \
                              new_address, bc_tpl[0][4], bc_tpl[0][5]), \
                             instr))
      i += 1

    return new_bytecode
Resolves targets of jumps. Since we add new bytecode, absolute (resp. relative)
dataset/ETHPy150Open neuroo/equip/equip/rewriter/merger.py/Merger.resolve_jump_targets