// File: /workspace/github_c_makefile_star2_O0/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
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x90(%rax), %rax
movq %rax, -0x28(%rbp)
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x30(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x34(%rbp) # imm = 0xFFFFFFFF
movq $0x0, -0x40(%rbp)
xorl %eax, %eax
cmpq -0x28(%rbp), %rax
je 0x27c64
movq -0x28(%rbp), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0xc, %eax
jne 0x27c53
movq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x27c51
movq -0x48(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x27c51
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rax
movq 0x40(%rax), %rsi
callq 0x64900
cmpl $0x0, %eax
jne 0x27c51
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl 0x70(%rcx), %eax
jge 0x27c4f
movq -0x48(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x4c(%rbp), %rcx
movl (%rax,%rcx,8), %eax
movl %eax, -0x50(%rbp)
movq -0x48(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x4c(%rbp), %rcx
movl 0x4(%rax,%rcx,8), %eax
movl %eax, -0x54(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x27c3f
movl -0x50(%rbp), %eax
cmpl -0x30(%rbp), %eax
jl 0x27c3f
movl -0x54(%rbp), %eax
cmpl -0x20(%rbp), %eax
jg 0x27c3d
movl -0x50(%rbp), %eax
cmpl -0x30(%rbp), %eax
jg 0x27c23
movl -0x54(%rbp), %eax
cmpl -0x34(%rbp), %eax
jle 0x27c3d
movl -0x50(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x27c3f
jmp 0x27c41
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x27bca
jmp 0x27c51
jmp 0x27c53
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x27b63
cmpq $0x0, -0x40(%rbp)
je 0x27c81
movq -0x40(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
jmp 0x27c8d
leaq 0x5d704(%rip), %rdi     # 0x8538c
callq 0x1ad60
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)