// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/gc.c
// Function: janet_collect
void janet_collect(void) {
    uint32_t i;
    if (janet_vm.gc_suspend) return;
    depth = JANET_RECURSION_GUARD;
    janet_vm.gc_mark_phase = 1;
    /* Try to prevent many major collections back to back.
     * A full collection will take O(janet_vm.block_count) time.
     * If we have a large heap, make sure our interval is not too
     * small so we won't make many collections over it. This is just a
     * heuristic for automatically changing the gc interval */
    if (janet_vm.block_count * 8 > janet_vm.gc_interval) {
        janet_vm.gc_interval = janet_vm.block_count * sizeof(JanetGCObject);
    }
    orig_rootcount = janet_vm.root_count;
#ifdef JANET_EV
    janet_ev_mark();
#endif
    janet_mark_fiber(janet_vm.root_fiber);
    for (i = 0; i < orig_rootcount; i++)
        janet_mark(janet_vm.roots[i]);
    while (orig_rootcount < janet_vm.root_count) {
        Janet x = janet_vm.roots[--janet_vm.root_count];
        janet_mark(x);
    }
    janet_vm.gc_mark_phase = 0;
    janet_sweep();
    janet_vm.next_collection = 0;
    janet_free_all_scratch();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
cmpl $0x0, 0xb8(%rax)
je 0x39ff6
jmp 0x3a229
movq %fs:0x0, %rax
leaq -0x358(%rax), %rax
movl $0x400, (%rax)          # imm = 0x400
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movl $0x1, 0xbc(%rax)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0xb0(%rax), %rax
shlq $0x3, %rax
movq %rax, -0x18(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq %rax, %rcx
movq -0x18(%rbp), %rax
cmpq 0xa0(%rcx), %rax
jbe 0x3a0a2
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0xb0(%rax), %rax
shlq $0x4, %rax
movq %rax, -0x20(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq -0x20(%rbp), %rcx
movq %rcx, 0xa0(%rax)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0xc8(%rax), %rax
movq %rax, -0x28(%rbp)
movq %fs:0x0, %rax
movq -0x28(%rbp), %rcx
leaq -0x350(%rax), %rax
movq %rcx, (%rax)
callq 0x2b190
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x28(%rax), %rdi
callq 0x38fa0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
movq %rax, -0x30(%rbp)
movq %fs:0x0, %rax
movq %rax, %rcx
movq -0x30(%rbp), %rax
leaq -0x350(%rcx), %rcx
cmpq (%rcx), %rax
jae 0x3a150
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0xc0(%rax), %rax
movl -0x4(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
callq 0x38b90
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x3a0fc
jmp 0x3a152
movq %fs:0x0, %rax
leaq -0x350(%rax), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq %rax, %rcx
movq -0x38(%rbp), %rax
cmpq 0xc8(%rcx), %rax
jae 0x3a1ea
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0xc0(%rax), %rax
movq %rax, -0x40(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq %rax, %rdx
movq -0x40(%rbp), %rax
movq 0xc8(%rdx), %rcx
movq %rcx, %rsi
addq $-0x1, %rsi
movq %rsi, 0xc8(%rdx)
movq -0x8(%rax,%rcx,8), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x38b90
jmp 0x3a152
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movl $0x0, 0xbc(%rax)
callq 0x39380
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq $0x0, 0xa8(%rax)
callq 0x3a230
addq $0x40, %rsp
popq %rbp
retq
nop