def _scan_real_end_loop(bytecode, setuploop_inst):
    """Find the end of loop.
    Return the instruction offset.
    """
    start = setuploop_inst.next
    end = start + setuploop_inst.arg
    offset = start
    depth = 0
    while offset < end:
        inst = bytecode[offset]
        depth += inst.block_effect
        if depth < 0:
            return inst.next
        offset = inst.next