// File: /workspace/github_c_makefile_star2_O1/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
cmovpl %ecx, %eax
testl %eax, %eax
je 0x2258c
cmpl $0x2, %eax
je 0x2257a
cmpl $0x1, %eax
jne 0x225b8
shll $0x8, %ebx
orl $0x28, %ebx
jmp 0x2268c
shll $0x8, %ebx
andl $0x1, %r15d
subl %r15d, %ebx
addl $0x2a, %ebx
jmp 0x2268c
movsd 0x3796c(%rip), %xmm1    # 0x59f00
ucomisd %xmm0, %xmm1
ja 0x225b8
ucomisd 0x37966(%rip), %xmm0    # 0x59f08
ja 0x225b8
cvttpd2dq %xmm0, %xmm1
cvtdq2pd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x225b8
jnp 0x226a1
movq (%rdi), %r12
testq %r12, %r12
je 0x225cf
testb $0x1, 0x6c(%r12)
jne 0x225cf
movq 0x8(%r12), %r12
jmp 0x225bb
movq 0x18(%r12), %rax
testq %rax, %rax
movq %rdi, -0x38(%rbp)
je 0x225e2
movl -0x4(%rax), %eax
jmp 0x225e4
xorl %eax, %eax
movl %eax, -0x2c(%rbp)
testl %eax, %eax
jle 0x2260f
movl -0x2c(%rbp), %r13d
xorl %r14d, %r14d
movq 0x18(%r12), %rax
movq (%rax,%r14,8), %rsi
movq %r15, %rdi
callq 0x4acce
testl %eax, %eax
jne 0x22675
incq %r14
cmpq %r14, %r13
jne 0x225f2
movl -0x2c(%rbp), %r13d
cmpl $0xffff, %r13d          # imm = 0xFFFF
jl 0x22634
leaq 0x3794d(%rip), %rsi     # 0x59f70
movq -0x38(%rbp), %r14
movq %r14, %rdi
callq 0x1bc9e
xorl %r13d, %r13d
jmp 0x2267c
movq 0x18(%r12), %rdi
testq %rdi, %rdi
movq -0x38(%rbp), %r14
je 0x2264c
movl -0x4(%rdi), %eax
incl %eax
cmpl -0x8(%rdi), %eax
jl 0x22660
movl $0x1, %esi
movl $0x8, %edx
callq 0x4c0b4
movq %rax, 0x18(%r12)
movq 0x18(%r12), %rax
movslq -0x4(%rax), %rcx
leal 0x1(%rcx), %edx
movl %edx, -0x4(%rax)
movq %r15, (%rax,%rcx,8)
jmp 0x2267c
movl %r14d, %r13d
movq -0x38(%rbp), %r14
shll $0x10, %r13d
shll $0x8, %ebx
orl %r13d, %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 0x21a88
cvttsd2si %xmm0, %eax
shll $0x10, %eax
shll $0x8, %ebx
orl %eax, %ebx
orl $0x2b, %ebx
jmp 0x2268c
nop