// File: /workspace/github_c_makefile_star2_O3/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 0x43b5f
movq %rsi, -0x30(%rbp)
movabsq $-0x5000000000000, %r13 # imm = 0xFFFB000000000000
movq %rdx, %rdi
callq 0x478f5
movq %rax, %rbx
leaq 0x2511c(%rip), %rdi     # 0x689e5
callq 0x47261
movq %rax, %rdi
movq %r13, %rsi
callq 0x4ed39
movq %rax, %r15
movq %r14, %rdi
callq 0x43b8b
movabsq $-0x4000000000000, %rsi # imm = 0xFFFC000000000000
movq %rax, %rdi
callq 0x4ed39
movq %rbx, %r12
movq %rbx, %rdi
movq %r13, %rbx
movq %r15, %rsi
movq %rax, %rdx
callq 0x476f0
leaq 0x250df(%rip), %rdi     # 0x689f0
callq 0x47261
movq %rax, %rdi
movq %r13, %rsi
callq 0x4ed39
movq %rax, %r15
movq 0x18(%r14), %rdi
movq %rax, %rsi
callq 0x474e0
shrq $0x2f, %rax
cmpl $0x1fff1, %eax          # imm = 0x1FFF1
movq %r12, -0x38(%rbp)
jne 0x439da
leaq 0x196bc(%rip), %rdi     # 0x5d006
callq 0x47261
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4ed39
leaq -0x50(%rbp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x1baf6
movq %r12, %rdi
movabsq $-0x3800000000000, %r12 # imm = 0xFFFC800000000000
movq %r12, %rsi
callq 0x4ed7e
leaq -0x68(%rbp), %r13
movq %r13, %rdi
movq %rax, %rsi
callq 0x1baf6
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 0x22063
jmp 0x43b21
movabsq $-0x7000000000000, %r13 # imm = 0xFFF9000000000000
movq 0x18(%r14), %rdi
movq %r15, %rsi
callq 0x474e0
movabsq $-0x800000000000, %rcx  # imm = 0xFFFF800000000000
andq %rcx, %rax
cmpq %r13, %rax
jne 0x43a16
movq 0x18(%r14), %rdi
movq %r15, %rsi
callq 0x474e0
testb $0x1, %al
je 0x43943
incq %r13
movq %r13, %rdi
callq 0x4ece6
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x476f0
movq 0x18(%r14), %rsi
leaq -0x50(%rbp), %r15
movq %r15, %rdi
movq -0x30(%rbp), %rdx
callq 0x49643
movl (%r15), %eax
andl $-0x2, %eax
cmpl $0x4, %eax
jne 0x43a5c
movq -0x48(%rbp), %rdi
callq 0x4ebc4
movq %rax, %r15
jmp 0x43a89
movabsq $-0x7800000000000, %r13 # imm = 0xFFF8800000000000
movl $0x1, %edi
callq 0x14690
movq %rax, %r15
incq %r13
movq %r13, %rdi
callq 0x4ece6
movq %r15, %rdi
movq %rax, %rsi
callq 0x148a3
leaq 0x24627(%rip), %rdi     # 0x680b7
callq 0x47261
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4ed39
movq %rax, %r13
movabsq $-0x4800000000000, %rbx # imm = 0xFFFB800000000000
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4ed7e
movq %r12, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x476f0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4ed7e
leaq -0x68(%rbp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x1baf6
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 0x22059
movabsq $-0x3800000000000, %r12 # imm = 0xFFFC800000000000
movq 0x18(%r14), %r15
movabsq $-0x5800000000000, %rsi # imm = 0xFFFA800000000000
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0x4ed39
movq %rax, %r13
movq -0x38(%rbp), %rdi
movq %r12, %rsi
callq 0x4ed7e
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x476f0
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 0x43bfb
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq