// File: /workspace/github_c_makefile_star2_O2/janet-lang[P]janet/src/core/emit.c
// Function: janetc_loadconst
static void janetc_loadconst(JanetCompiler *c, Janet k, int32_t reg) {
    switch (janet_type(k)) {
        case JANET_NIL:
            janetc_emit(c, (reg << 8) | JOP_LOAD_NIL);
            break;
        case JANET_BOOLEAN:
            janetc_emit(c, (reg << 8) |
                        (janet_unwrap_boolean(k) ? JOP_LOAD_TRUE : JOP_LOAD_FALSE));
            break;
        case JANET_NUMBER: {
            double dval = janet_unwrap_number(k);
            if (dval < INT16_MIN || dval > INT16_MAX)
                goto do_constant;
            int32_t i = (int32_t) dval;
            if (dval != i)
                goto do_constant;
            uint32_t iu = (uint32_t)i;
            janetc_emit(c,
                        (iu << 16) |
                        (reg << 8) |
                        JOP_LOAD_INTEGER);
            break;
        }
        default:
        do_constant: {
                int32_t cindex = janetc_const(c, k);
                janetc_emit(c,
                            (cindex << 16) |
                            (reg << 8) |
                            JOP_LOAD_CONSTANT);
                break;
            }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebx
movq %rsi, %r15
movq %rsi, %xmm0
movq %rsi, %rcx
shrq $0x2f, %rcx
andl $0xf, %ecx
xorl %eax, %eax
ucomisd %xmm0, %xmm0
movq %rdi, %r14
cmovpl %ecx, %eax
testl %eax, %eax
je 0x202bc
cmpl $0x1, %eax
je 0x202b1
movq %r14, %r13
cmpl $0x2, %eax
jne 0x202f1
shll $0x8, %ebx
andl $0x1, %r15d
subl %r15d, %ebx
addl $0x2a, %ebx
jmp 0x203c1
shll $0x8, %ebx
orl $0x28, %ebx
jmp 0x203c1
movsd 0x34c3c(%rip), %xmm1    # 0x54f00
ucomisd %xmm0, %xmm1
movq %r14, %r13
ja 0x202f1
ucomisd 0x34c33(%rip), %xmm0    # 0x54f08
movq %r14, %r13
ja 0x202f1
cvttpd2dq %xmm0, %xmm1
cvtdq2pd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movq %r14, %r13
jne 0x202f1
jnp 0x203d9
movq (%r13), %r13
testq %r13, %r13
je 0x20307
testb $0x1, 0x6c(%r13)
jne 0x20307
addq $0x8, %r13
jmp 0x202f1
movq %r14, -0x30(%rbp)
movq 0x18(%r13), %rax
xorl %r14d, %r14d
movl $0x0, %ecx
testq %rax, %rax
je 0x2031f
movl -0x4(%rax), %ecx
testl %ecx, %ecx
movl $0x0, %r12d
movl %ecx, -0x34(%rbp)
cmovgl %ecx, %r12d
cmpq %r14, %r12
je 0x2034c
movq 0x18(%r13), %rax
movq (%rax,%r14,8), %rsi
movq %r15, %rdi
callq 0x466c8
testl %eax, %eax
jne 0x20371
incq %r14
jmp 0x2032e
movl -0x34(%rbp), %r12d
cmpl $0xffff, %r12d          # imm = 0xFFFF
jl 0x2037a
leaq 0x34c10(%rip), %rsi     # 0x54f70
movq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x19fa9
xorl %r12d, %r12d
jmp 0x203b4
movl %r14d, %r12d
movq -0x30(%rbp), %r14
jmp 0x203b4
movq 0x18(%r13), %rax
testq %rax, %rax
movq -0x30(%rbp), %r14
je 0x20392
movl -0x4(%rax), %ecx
leal 0x1(%rcx), %edx
cmpl -0x8(%rax), %edx
jl 0x203aa
pushq $0x1
popq %rsi
pushq $0x8
popq %rdx
movq %rax, %rdi
callq 0x4799c
movq %rax, 0x18(%r13)
movl -0x4(%rax), %ecx
leal 0x1(%rcx), %edx
movl %edx, -0x4(%rax)
movslq %ecx, %rcx
movq %r15, (%rax,%rcx,8)
shll $0x10, %r12d
shll $0x8, %ebx
orl %r12d, %ebx
orl $0x2c, %ebx
movq %r14, %rdi
movl %ebx, %esi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1f7c4
cvttsd2si %xmm0, %eax
shll $0x10, %eax
shll $0x8, %ebx
orl %eax, %ebx
orl $0x2b, %ebx
jmp 0x203c1
nop