// File: /workspace/github_c_makefile_star2_O3/janet-lang[P]janet/src/core/debug.c
// Function: janet_debug_find
void janet_debug_find(
    JanetFuncDef **def_out, int32_t *pc_out,
    const uint8_t *source, int32_t sourceLine, int32_t sourceColumn) {
    /* Scan the heap for right func def */
    JanetGCObject *current = janet_vm.blocks;
    /* Keep track of the best source mapping we have seen so far */
    int32_t besti = -1;
    int32_t best_line = -1;
    int32_t best_column = -1;
    JanetFuncDef *best_def = NULL;
    while (NULL != current) {
        if ((current->flags & JANET_MEM_TYPEBITS) == JANET_MEMORY_FUNCDEF) {
            JanetFuncDef *def = (JanetFuncDef *)(current);
            if (def->sourcemap &&
                    def->source &&
                    !janet_string_compare(source, def->source)) {
                /* Correct source file, check mappings. The chosen
                 * pc index is the instruction closest to the given line column, but
                 * not after. */
                int32_t i;
                for (i = 0; i < def->bytecode_length; i++) {
                    int32_t line = def->sourcemap[i].line;
                    int32_t column = def->sourcemap[i].column;
                    if (line <= sourceLine && line >= best_line) {
                        if (column <= sourceColumn &&
                                (line > best_line || column > best_column)) {
                            best_line = line;
                            best_column = column;
                            besti = i;
                            best_def = def;
                        }
                    }
                }
            }
        }
        current = current->data.next;
    }
    if (best_def) {
        *def_out = best_def;
        *pc_out = besti;
    } else {
        janet_panic("could not find breakpoint");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, %r15d
movl %ecx, %r12d
movq %rdx, -0x48(%rbp)
movq %rsi, -0x40(%rbp)
movq %rdi, -0x38(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x90(%rax), %rbx
testq %rbx, %rbx
je 0x207f2
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
xorl %r13d, %r13d
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
movl %r15d, -0x30(%rbp)
movl %r12d, -0x2c(%rbp)
cmpb $0xc, (%rbx)
jne 0x207c3
cmpq $0x0, 0x38(%rbx)
je 0x207c3
movq 0x40(%rbx), %rsi
testq %rsi, %rsi
je 0x207c3
movl %r10d, %r12d
movl %r9d, %r15d
movq -0x48(%rbp), %rdi
callq 0x447ad
testl %eax, %eax
je 0x20772
movl %r15d, %r9d
movl %r12d, %r10d
jmp 0x207c3
movslq 0x70(%rbx), %rax
testq %rax, %rax
movl %r15d, %r9d
movl %r12d, %r10d
jle 0x207c3
movq 0x38(%rbx), %rcx
xorl %edx, %edx
movl -0x30(%rbp), %r15d
movl -0x2c(%rbp), %r12d
movl (%rcx,%rdx,8), %esi
cmpl %r12d, %esi
jg 0x207bb
cmpl %r14d, %esi
jl 0x207bb
movl 0x4(%rcx,%rdx,8), %edi
cmpl %r15d, %edi
jg 0x207bb
cmpl %r14d, %esi
jg 0x207af
cmpl %r10d, %edi
jle 0x207bb
movl %edi, %r10d
movq %rbx, %r13
movl %esi, %r14d
movl %edx, %r9d
incq %rdx
cmpq %rdx, %rax
jne 0x2078f
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
jne 0x20742
testq %r13, %r13
je 0x207f2
movq -0x38(%rbp), %rax
movq %r13, (%rax)
movq -0x40(%rbp), %rax
movl %r9d, (%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x37b83(%rip), %rdi     # 0x5837c
callq 0x191a3