'Detect all offsets in a byte code which are jump targets.
Return the list of offsets.
This procedure is modelled after dis.findlables(), but here
for each target the number of jumps are counted.'

def find_jump_targets(self, code):

    hasjrel = dis.hasjrel
    hasjabs = dis.hasjabs
    n = len(code)
    self.structs = [{'type': 'root', 'start': 0, 'end': (n - 1)}]
    self.loops = []
    self.fixed_jumps = {}
    self.ignore_if = set()
    self.build_stmt_indices()
    self.not_continue = set()
    self.return_end_ifs = set()
    targets = {}
    for i in self.op_range(0, n):
        op = code[i]
        self.detect_structure(i, op)
        if (op >= HAVE_ARGUMENT):
            label = self.fixed_jumps.get(i)
            oparg = (code[(i + 1)] + (code[(i + 2)] * 256))
            if (label is None):
                if ((op in hasjrel) and (op != FOR_ITER)):
                    label = ((i + 3) + oparg)
                elif (op in hasjabs):
                    if (op in (JUMP_IF_FALSE_OR_POP, JUMP_IF_TRUE_OR_POP)):
                        if (oparg > i):
                            label = oparg
            if ((label is not None) and (label != (-1))):
                targets[label] = (targets.get(label, []) + [i])
        elif ((op == END_FINALLY) and (i in self.fixed_jumps)):
            label = self.fixed_jumps[i]
            targets[label] = (targets.get(label, []) + [i])
    return targets
