// File: /workspace/github_c_makefile_star2_O1/janet-lang[P]janet/src/core/specials.c
// Function: defleaf
static int defleaf(
    JanetCompiler *c,
    const uint8_t *sym,
    JanetSlot s,
    JanetTable *tab) {
    if (c->scope->flags & JANET_SCOPE_TOP) {
        JanetTable *entry = janet_table_clone(tab);
        janet_table_put(entry, janet_ckeywordv("source-map"),
                        janet_wrap_tuple(janetc_make_sourcemap(c)));

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

        if (is_redef) {
            JanetBinding binding = janet_resolve_ext(c->env, sym);
            JanetArray *ref;
            if (binding.type == JANET_BINDING_DYNAMIC_DEF || binding.type == JANET_BINDING_DYNAMIC_MACRO) {
                ref = janet_unwrap_array(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));
            JanetSlot refslot = janetc_cslot(janet_wrap_array(ref));
            janetc_emit_ssu(c, JOP_PUT_INDEX, refslot, s, 0, 0);
        } else {
            JanetSlot valsym = janetc_cslot(janet_ckeywordv("value"));
            JanetSlot tabslot = janetc_cslot(janet_wrap_table(entry));
            janetc_emit_sss(c, JOP_PUT, tabslot, valsym, s, 0);
        }

        /* Add env entry to env */
        janet_table_put(c->env, janet_wrap_symbol(sym), janet_wrap_table(entry));
    }
    return namelocal(c, sym, 0, s);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %r14
leaq 0x10(%rbp), %rcx
movq (%rdi), %rax
testb $0x4, 0x6c(%rax)
je 0x4447b
movq %rsi, -0x30(%rbp)
movabsq $-0x5000000000000, %r13 # imm = 0xFFFB000000000000
movq %rdx, %rdi
callq 0x483b2
movq %rax, %rbx
leaq 0x25820(%rip), %rdi     # 0x69a05
callq 0x47cd3
movq %rax, %rdi
movq %r13, %rsi
callq 0x4f9ad
movq %rax, %r15
movq %r14, %rdi
callq 0x444a7
movabsq $-0x4000000000000, %rsi # imm = 0xFFFC000000000000
movq %rax, %rdi
callq 0x4f9ad
movq %rbx, %r12
movq %rbx, %rdi
movq %r13, %rbx
movq %r15, %rsi
movq %rax, %rdx
callq 0x481b3
leaq 0x257e3(%rip), %rdi     # 0x69a10
callq 0x47cd3
movq %rax, %rdi
movq %r13, %rsi
callq 0x4f9ad
movq %rax, %r15
movq 0x18(%r14), %rdi
movq %rax, %rsi
callq 0x47f51
shrq $0x2f, %rax
cmpl $0x1fff1, %eax          # imm = 0x1FFF1
movq %r12, -0x38(%rbp)
jne 0x442f6
leaq 0x19da0(%rip), %rdi     # 0x5e006
callq 0x47cd3
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4f9ad
leaq -0x50(%rbp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x1bc4e
movq %r12, %rdi
movabsq $-0x3800000000000, %r12 # imm = 0xFFFC800000000000
movq %r12, %rsi
callq 0x4f9f2
leaq -0x68(%rbp), %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0x1bc4e
leaq 0x10(%rbp), %rcx
movq 0x10(%rcx), %rax
movq %rax, 0x40(%rsp)
movups (%rcx), %xmm0
movups %xmm0, 0x30(%rsp)
movq 0x10(%r15), %rax
movq %rax, 0x28(%rsp)
movups (%r15), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movups (%r13), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
movl $0x3c, %esi
xorl %edx, %edx
callq 0x223bf
jmp 0x4443d
movabsq $-0x7000000000000, %r13 # imm = 0xFFF9000000000000
movq 0x18(%r14), %rdi
movq %r15, %rsi
callq 0x47f51
movabsq $-0x800000000000, %rcx  # imm = 0xFFFF800000000000
andq %rcx, %rax
cmpq %r13, %rax
jne 0x44332
movq 0x18(%r14), %rdi
movq %r15, %rsi
callq 0x47f51
testb $0x1, %al
je 0x4425f
incq %r13
movq %r13, %rdi
callq 0x4f95a
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x481b3
movq 0x18(%r14), %rsi
leaq -0x50(%rbp), %r15
movq %r15, %rdi
movq -0x30(%rbp), %rdx
callq 0x4a15b
movl (%r15), %eax
andl $-0x2, %eax
cmpl $0x4, %eax
jne 0x44378
movq -0x48(%rbp), %rdi
callq 0x4f838
movq %rax, %r15
jmp 0x443a5
movabsq $-0x7800000000000, %r13 # imm = 0xFFF8800000000000
movl $0x1, %edi
callq 0x146a0
movq %rax, %r15
incq %r13
movq %r13, %rdi
callq 0x4f95a
movq %r15, %rdi
movq %rax, %rsi
callq 0x148b3
leaq 0x24d2b(%rip), %rdi     # 0x690d7
callq 0x47cd3
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4f9ad
movq %rax, %r13
movabsq $-0x4800000000000, %rbx # imm = 0xFFFB800000000000
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4f9f2
movq %r12, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x481b3
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4f9f2
leaq -0x68(%rbp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x1bc4e
leaq 0x10(%rbp), %rcx
movq 0x10(%rcx), %rax
movq %rax, 0x28(%rsp)
movups (%rcx), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
movl $0x3e, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x223b5
movabsq $-0x3800000000000, %r12 # imm = 0xFFFC800000000000
movq 0x18(%r14), %r15
movabsq $-0x5800000000000, %rsi # imm = 0xFFFA800000000000
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0x4f9ad
movq %rax, %r13
movq -0x38(%rbp), %rdi
movq %r12, %rsi
callq 0x4f9f2
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x481b3
movq %rbx, %rsi
leaq 0x10(%rbp), %rcx
movq 0x10(%rcx), %rax
movq %rax, 0x10(%rsp)
movups (%rcx), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
xorl %edx, %edx
callq 0x44517
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq