// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/compile.c
// Function: janetc_popscope
void janetc_popscope(JanetCompiler *c) {
    JanetScope *oldscope = c->scope;
    JanetScope *newscope = oldscope->parent;
    /* Move free slots to parent scope if not a new function.
     * We need to know the total number of slots used when compiling the function. */
    if (!(oldscope->flags & (JANET_SCOPE_FUNCTION | JANET_SCOPE_UNUSED)) && newscope) {
        /* Parent scopes inherit child's closure flag. Needed
         * for while loops. (if a while loop creates a closure, it
         * is compiled to a tail recursive iife) */
        if (oldscope->flags & JANET_SCOPE_CLOSURE) {
            newscope->flags |= JANET_SCOPE_CLOSURE;
        }
        if (newscope->ra.max < oldscope->ra.max) {
            newscope->ra.max = oldscope->ra.max;
        }

        /* Keep upvalue slots and symbols for debugging. */
        for (int32_t i = 0; i < janet_v_count(oldscope->syms); i++) {
            SymPair pair = oldscope->syms[i];
            /* The variable should not be lexically accessible */
            pair.sym = NULL;
            if (pair.death_pc == UINT32_MAX) {
                pair.death_pc = (uint32_t) janet_v_count(c->buffer);
            }
            if (pair.keep) {
                /* The variable should also not be included in the locals */
                pair.sym2 = NULL;
                janetc_regalloc_touch(&newscope->ra, pair.slot.index);
            }
            janet_v_push(newscope->syms, pair);
        }
    }

    /* Free the old scope */
    janet_v_free(oldscope->consts);
    janet_v_free(oldscope->syms);
    janet_v_free(oldscope->envs);
    janet_v_free(oldscope->defs);
    janetc_regalloc_deinit(&oldscope->ra);
    janetc_regalloc_deinit(&oldscope->ua);
    /* Update pointer */
    if (newscope)
        newscope->child = NULL;
    c->scope = newscope;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x6c(%rax), %eax
andl $0x9, %eax
cmpl $0x0, %eax
jne 0x207bb
cmpq $0x0, -0x18(%rbp)
je 0x207bb
movq -0x10(%rbp), %rax
movl 0x6c(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x2065d
movq -0x18(%rbp), %rax
movl 0x6c(%rax), %ecx
orl $0x10, %ecx
movl %ecx, 0x6c(%rax)
movq -0x18(%rbp), %rax
movl 0x40(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x40(%rcx), %eax
jge 0x2067b
movq -0x10(%rbp), %rax
movl 0x40(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x40(%rax)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x206a3
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x4(%rax), %eax
movl %eax, -0x60(%rbp)
jmp 0x206aa
xorl %eax, %eax
movl %eax, -0x60(%rbp)
jmp 0x206aa
movl -0x5c(%rbp), %eax
movl -0x60(%rbp), %ecx
cmpl %ecx, %eax
jge 0x207b9
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
movslq -0x1c(%rbp), %rax
imulq $0x38, %rax, %rax
addq %rax, %rsi
leaq -0x58(%rbp), %rdi
movl $0x38, %edx
callq 0x12680
movq $0x0, -0x40(%rbp)
cmpl $-0x1, -0x28(%rbp)
jne 0x2070f
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x20702
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x4(%rax), %eax
movl %eax, -0x64(%rbp)
jmp 0x20709
xorl %eax, %eax
movl %eax, -0x64(%rbp)
jmp 0x20709
movl -0x64(%rbp), %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x2072d
movq $0x0, -0x38(%rbp)
movq -0x18(%rbp), %rdi
addq $0x30, %rdi
movl -0x50(%rbp), %esi
callq 0x5ded0
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x20753
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x4(%rax), %eax
addl $0x1, %eax
movq -0x18(%rbp), %rcx
movq 0x20(%rcx), %rcx
cmpl -0x8(%rcx), %eax
jl 0x20777
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movl $0x1, %esi
movl $0x38, %edx
callq 0x70760
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0x20779
jmp 0x20779
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rcx
movl -0x4(%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x4(%rcx)
cltq
imulq $0x38, %rax, %rax
addq %rax, %rdi
leaq -0x58(%rbp), %rsi
movl $0x38, %edx
callq 0x12680
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x20682
jmp 0x207bb
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x207d9
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
addq $-0x8, %rdi
callq 0x3acb0
jmp 0x207db
jmp 0x207db
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x207f9
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
addq $-0x8, %rdi
callq 0x3acb0
jmp 0x207fb
jmp 0x207fb
movq -0x10(%rbp), %rax
cmpq $0x0, 0x60(%rax)
je 0x20819
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rdi
addq $-0x8, %rdi
callq 0x3acb0
jmp 0x2081b
jmp 0x2081b
movq -0x10(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x20839
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
addq $-0x8, %rdi
callq 0x3acb0
jmp 0x2083b
jmp 0x2083b
movq -0x10(%rbp), %rdi
addq $0x30, %rdi
callq 0x5ddd0
movq -0x10(%rbp), %rdi
addq $0x48, %rdi
callq 0x5ddd0
cmpq $0x0, -0x18(%rbp)
je 0x20868
movq -0x18(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)