// File: /workspace/github_c_makefile_star2_O2/janet-lang[P]janet/src/core/specials.c
// Function: janetc_varset
static JanetSlot janetc_varset(JanetFopts opts, int32_t argn, const Janet *argv) {
    if (argn != 2) {
        janetc_cerror(opts.compiler, "expected 2 arguments to set");
        return janetc_cslot(janet_wrap_nil());
    }
    JanetFopts subopts = janetc_fopts_default(opts.compiler);
    if (janet_checktype(argv[0], JANET_SYMBOL)) {
        /* Normal var - (set a 1) */
        const uint8_t *sym = janet_unwrap_symbol(argv[0]);
        JanetSlot dest = janetc_resolve(opts.compiler, sym);
        if (!(dest.flags & JANET_SLOT_MUTABLE)) {
            janetc_cerror(opts.compiler, "cannot set constant");
            return janetc_cslot(janet_wrap_nil());
        }
        subopts.flags = JANET_FOPTS_HINT;
        subopts.hint = dest;
        JanetSlot ret = janetc_value(subopts, argv[1]);
        janetc_copy(opts.compiler, dest, ret);
        return ret;
    } else if (janet_checktype(argv[0], JANET_TUPLE)) {
        /* Set a field (setf behavior) - (set (tab :key) 2) */
        const Janet *tup = janet_unwrap_tuple(argv[0]);
        /* Tuple must have 2 elements */
        if (janet_tuple_length(tup) != 2) {
            janetc_cerror(opts.compiler, "expected 2 element tuple for l-value to set");
            return janetc_cslot(janet_wrap_nil());
        }
        JanetSlot ds = janetc_value(subopts, tup[0]);
        JanetSlot key = janetc_value(subopts, tup[1]);
        /* Can't be tail position because we will emit a PUT instruction afterwards */
        /* Also can't drop either */
        opts.flags &= ~(JANET_FOPTS_TAIL | JANET_FOPTS_DROP);
        JanetSlot rvalue = janetc_value(opts, argv[1]);
        /* Emit the PUT instruction */
        janetc_emit_sss(opts.compiler, JOP_PUT, ds, key, rvalue, 0);
        return rvalue;
    } else {
        /* Error */
        janetc_cerror(opts.compiler, "expected symbol or tuple for l-value to set");
        return janetc_cslot(janet_wrap_nil());
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %rbx
leaq 0x10(%rbp), %r13
cmpl $0x2, %esi
jne 0x3efdf
movq %rdx, %r14
movq (%r13), %r15
leaq -0x50(%rbp), %rdi
movq %r15, %rsi
callq 0x19f04
movq (%r14), %rdi
movabsq $-0x800000000000, %rax  # imm = 0xFFFF800000000000
andq %rdi, %rax
movabsq $-0x4000000000000, %rcx # imm = 0xFFFC000000000000
cmpq %rcx, %rax
je 0x3efef
movabsq $-0x5800000000000, %rcx # imm = 0xFFFA800000000000
cmpq %rcx, %rax
jne 0x3f0cb
callq 0x4b1f1
leaq -0x68(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x1a590
testb $0x4, 0x12(%r12)
jne 0x3f0d4
leaq 0x25c10(%rip), %rsi     # 0x64bea
jmp 0x3f144
movq (%r13), %rdi
leaq 0x25be4(%rip), %rsi     # 0x64bce
jmp 0x3f147
callq 0x4b1f1
cmpl $0x2, -0x10(%rax)
jne 0x3f13d
movq %rax, %r12
movq (%rax), %rsi
movq -0x30(%rbp), %rax
movq %rax, 0x20(%rsp)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq -0x68(%rbp), %r15
movq %r15, %rdi
callq 0x1abbf
movq 0x8(%r12), %rsi
movq -0x30(%rbp), %rax
movq %rax, 0x20(%rsp)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq -0x80(%rbp), %r12
movq %r12, %rdi
callq 0x1abbf
andb $-0x6, 0x22(%r13)
movq 0x8(%r14), %rsi
movq 0x20(%r13), %rax
movq %rax, 0x20(%rsp)
movups (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rbx, %rdi
callq 0x1abbf
movq (%r13), %rdi
movq 0x10(%rbx), %rax
movq %rax, 0x40(%rsp)
movups (%rbx), %xmm0
movups %xmm0, 0x30(%rsp)
movq 0x10(%r12), %rax
movq %rax, 0x28(%rsp)
movups (%r12), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
pushq $0x3c
popq %rsi
xorl %edx, %edx
callq 0x2010f
jmp 0x3f166
leaq 0x25b58(%rip), %rsi     # 0x64c2a
jmp 0x3f144
movl $0x20000, -0x30(%rbp)   # imm = 0x20000
movups -0x68(%rbp), %xmm0
movups %xmm0, -0x48(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x38(%rbp)
movq 0x8(%r14), %rsi
movq -0x30(%rbp), %rax
movq %rax, 0x20(%rsp)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rbx, %rdi
callq 0x1abbf
movq 0x10(%rbx), %rax
movq %rax, 0x28(%rsp)
movups (%rbx), %xmm0
movups %xmm0, 0x18(%rsp)
movq -0x58(%rbp), %rax
movq %rax, 0x10(%rsp)
movups -0x68(%rbp), %xmm0
movups %xmm0, (%rsp)
movq %r15, %rdi
callq 0x1f88f
jmp 0x3f166
leaq 0x25aba(%rip), %rsi     # 0x64bfe
movq %r15, %rdi
callq 0x19fa9
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x4b313
movq %rbx, %rdi
movq %rax, %rsi
callq 0x19f5c
movq %rbx, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq