// File: /workspace/github_c_makefile_star2_O2/janet-lang[P]janet/src/core/specials.c
// Function: varleaf
static int varleaf(
    JanetCompiler *c,
    const uint8_t *sym,
    JanetSlot s,
    JanetTable *reftab) {
    if (c->scope->flags & JANET_SCOPE_TOP) {
        /* Global var, generate var */
        JanetSlot refslot;
        JanetTable *entry = janet_table_clone(reftab);

        Janet redef_kw = janet_ckeywordv("redef");
        int is_redef = janet_truthy(janet_table_get(c->env, redef_kw));

        JanetArray *ref;
        JanetBinding old_binding;
        if (is_redef && (old_binding = janet_resolve_ext(c->env, sym),
                         old_binding.type == JANET_BINDING_VAR)) {
            ref = janet_unwrap_array(old_binding.value);
        } else {
            ref = janet_array(1);
            janet_array_push(ref, janet_wrap_nil());
        }

        janet_table_put(entry, janet_ckeywordv("ref"), janet_wrap_array(ref));
        janet_table_put(entry, janet_ckeywordv("source-map"),
                        janet_wrap_tuple(janetc_make_sourcemap(c)));
        janet_table_put(c->env, janet_wrap_symbol(sym), janet_wrap_table(entry));
        refslot = janetc_cslot(janet_wrap_array(ref));
        janetc_emit_ssu(c, JOP_PUT_INDEX, refslot, s, 0, 0);
        return 1;
    } else {
        return namelocal(c, sym, JANET_SLOT_MUTABLE, s);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rax
testb $0x4, 0x6c(%rax)
jne 0x40dad
movq %rbx, %rdi
movq %r14, %rsi
movl $0x40000, %edx          # imm = 0x40000
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x405c3
movabsq $-0x5000000000000, %r12 # imm = 0xFFFB000000000000
movq %rdx, %rdi
callq 0x44033
movq %rax, -0x38(%rbp)
leaq 0x23c46(%rip), %rdi     # 0x64a10
callq 0x439c6
movq %rax, %rdi
movq %r12, %r15
movq %r12, %rsi
callq 0x4b366
movq %rax, %r12
movq 0x18(%rbx), %rdi
movq %rax, %rsi
callq 0x43c35
shrq $0x2f, %rax
cmpl $0x1fff1, %eax          # imm = 0x1FFF1
movq %r14, -0x30(%rbp)
je 0x40e5b
movabsq $-0x800000000000, %r13  # imm = 0xFFFF800000000000
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0x43c35
andq %r13, %rax
movabsq $-0x7000000000000, %rcx # imm = 0xFFF9000000000000
cmpq %rcx, %rax
jne 0x40e33
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0x43c35
testb $0x1, %al
je 0x40e5b
movq 0x18(%rbx), %rsi
leaq -0x50(%rbp), %r12
movq %r12, %rdi
movq %r14, %rdx
callq 0x45b75
cmpl $0x2, (%r12)
jne 0x40e5b
movq -0x48(%rbp), %rdi
callq 0x4b1f1
movq %rax, %r13
jmp 0x40e86
movabsq $-0x7800000000000, %r12 # imm = 0xFFF8800000000000
pushq $0x1
popq %rdi
callq 0x12f68
movq %rax, %r13
incq %r12
movq %r12, %rdi
callq 0x4b313
movq %r13, %rdi
movq %rax, %rsi
callq 0x131d2
leaq 0x2324a(%rip), %rdi     # 0x640d7
callq 0x439c6
movq %rax, %rdi
movq %r15, %r14
movq %r15, %rsi
callq 0x4b366
movq %rax, %r12
movabsq $-0x4800000000000, %rsi # imm = 0xFFFB800000000000
movq %r13, %rdi
callq 0x4b3ab
movq -0x38(%rbp), %r15
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x43e19
leaq 0x23b37(%rip), %rdi     # 0x64a05
callq 0x439c6
movq %rax, %rdi
movq %r14, %rsi
callq 0x4b366
movq %rax, %r12
movq %rbx, %rdi
callq 0x40558
movabsq $-0x4000000000000, %rsi # imm = 0xFFFC000000000000
movq %rax, %rdi
callq 0x4b366
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x43e19
movq 0x18(%rbx), %r12
movabsq $-0x5800000000000, %rsi # imm = 0xFFFA800000000000
movq -0x30(%rbp), %rdi
callq 0x4b366
movq %rax, %r14
movabsq $-0x3800000000000, %rsi # imm = 0xFFFC800000000000
movq %r15, %rdi
callq 0x4b3ab
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x43e19
movq %r13, %rdi
movabsq $-0x4800000000000, %rsi # imm = 0xFFFB800000000000
callq 0x4b3ab
leaq -0x50(%rbp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x19f5c
leaq 0x10(%rbp), %rcx
movq 0x10(%rcx), %rax
movq %rax, 0x28(%rsp)
movups (%rcx), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
pushq $0x3e
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x20105
pushq $0x1
popq %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop