// File: /workspace/github_c_makefile_star2_O1/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 0x42e66
movq %rdx, %r14
movq (%r13), %rsi
leaq -0x50(%rbp), %rdi
callq 0x1bbf0
movq (%r14), %rdi
movabsq $-0x800000000000, %rax  # imm = 0xFFFF800000000000
andq %rdi, %rax
movabsq $-0x4000000000000, %rcx # imm = 0xFFFC000000000000
cmpq %rcx, %rax
je 0x42e76
movabsq $-0x5800000000000, %rcx # imm = 0xFFFA800000000000
cmpq %rcx, %rax
jne 0x42f54
callq 0x4f838
movq (%r13), %rsi
leaq -0x68(%rbp), %r15
movq %r15, %rdi
movq %rax, %rdx
callq 0x1c2a5
testb $0x4, 0x12(%r15)
jne 0x42f61
movq (%r13), %rdi
leaq 0x26d89(%rip), %rsi     # 0x69bea
jmp 0x42fd6
movq (%r13), %rdi
leaq 0x26d5d(%rip), %rsi     # 0x69bce
jmp 0x42fd6
callq 0x4f838
cmpl $0x2, -0x10(%rax)
jne 0x42fcb
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 0x1ca05
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 0x1ca05
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 0x1ca05
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)
movl $0x3c, %esi
xorl %edx, %edx
callq 0x223bf
jmp 0x42ff5
movq (%r13), %rdi
leaq 0x26ccb(%rip), %rsi     # 0x69c2a
jmp 0x42fd6
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 0x1ca05
movq (%r13), %rdi
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)
callq 0x21b57
jmp 0x42ff5
movq (%r13), %rdi
leaq 0x26c28(%rip), %rsi     # 0x69bfe
callq 0x1bc9e
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x4f95a
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1bc4e
movq %rbx, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq