// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/specials.c
// Function: janetc_if
static JanetSlot janetc_if(JanetFopts opts, int32_t argn, const Janet *argv) {
    JanetCompiler *c = opts.compiler;
    int32_t labelr, labeljr, labeld, labeljd;
    JanetFopts condopts, bodyopts;
    JanetSlot cond, left, right, target;
    Janet truebody, falsebody;
    JanetScope condscope, tempscope;
    const int tail = opts.flags & JANET_FOPTS_TAIL;
    const int drop = opts.flags & JANET_FOPTS_DROP;
    uint8_t ifnjmp = JOP_JUMP_IF_NOT;

    if (argn < 2 || argn > 3) {
        janetc_cerror(c, "expected 2 or 3 arguments to if");
        return janetc_cslot(janet_wrap_nil());
    }

    /* Get the bodies of the if expression */
    truebody = argv[1];
    falsebody = argn > 2 ? argv[2] : janet_wrap_nil();

    /* Get options */
    condopts = janetc_fopts_default(c);
    bodyopts = opts;
    bodyopts.flags &= ~JANET_FOPTS_ACCEPT_SPLICE;

    /* Set target for compilation */
    target = (drop || tail)
             ? janetc_cslot(janet_wrap_nil())
             : janetc_gettarget(opts);

    /* Compile condition */
    janetc_scope(&condscope, c, 0, "if");

    Janet condform = argv[0];
    if (janetc_check_nil_form(condform, &condform, JANET_FUN_EQ)) {
        ifnjmp = JOP_JUMP_IF_NOT_NIL;
    } else if (janetc_check_nil_form(condform, &condform, JANET_FUN_NEQ)) {
        ifnjmp = JOP_JUMP_IF_NIL;
    }

    cond = janetc_value(condopts, condform);

    /* Check constant condition. */
    /* TODO: Use type info for more short circuits */
    if (cond.flags & JANET_SLOT_CONSTANT) {
        int swap_condition = 0;
        if (ifnjmp == JOP_JUMP_IF_NOT && !janet_truthy(cond.constant)) swap_condition = 1;
        if (ifnjmp == JOP_JUMP_IF_NIL && janet_checktype(cond.constant, JANET_NIL)) swap_condition = 1;
        if (ifnjmp == JOP_JUMP_IF_NOT_NIL && !janet_checktype(cond.constant, JANET_NIL)) swap_condition = 1;
        if (swap_condition) {
            /* Swap the true and false bodies */
            Janet temp = falsebody;
            falsebody = truebody;
            truebody = temp;
        }
        janetc_scope(&tempscope, c, 0, "if-true");
        right = janetc_value(bodyopts, truebody);
        if (!drop && !tail) janetc_copy(c, target, right);
        janetc_popscope(c);
        if (!janet_checktype(falsebody, JANET_NIL)) {
            janetc_throwaway(bodyopts, falsebody);
        }
        janetc_popscope(c);
        return target;
    }

    /* Compile jump to right */
    labeljr = janetc_emit_si(c, ifnjmp, cond, 0, 0);

    /* Condition left body */
    janetc_scope(&tempscope, c, 0, "if-true");
    left = janetc_value(bodyopts, truebody);
    if (!drop && !tail) janetc_copy(c, target, left);
    janetc_popscope(c);

    /* Compile jump to done */
    labeljd = janet_v_count(c->buffer);
    if (!tail && !(drop && janet_checktype(falsebody, JANET_NIL))) janetc_emit(c, JOP_JUMP);

    /* Compile right body */
    labelr = janet_v_count(c->buffer);
    janetc_scope(&tempscope, c, 0, "if-false");
    right = janetc_value(bodyopts, falsebody);
    if (!drop && !tail) janetc_copy(c, target, right);
    janetc_popscope(c);

    /* Pop main scope */
    janetc_popscope(c);

    /* Write jumps - only add jump lengths if jump actually emitted */
    labeld = janet_v_count(c->buffer);
    c->buffer[labeljr] |= (labelr - labeljr) << 16;
    if (!tail) c->buffer[labeljd] |= (labeld - labeljd) << 8;

    if (tail) target.flags |= JANET_SLOT_RETURNED;
    return target;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x320, %rsp            # imm = 0x320
movq %rdi, -0x2d8(%rbp)
movq %rdi, -0x2d0(%rbp)
leaq 0x10(%rbp), %rax
movq %rax, -0x2c8(%rbp)
movl %esi, -0x4(%rbp)
movq %rdx, -0x10(%rbp)
movq (%rax), %rcx
movq %rcx, -0x18(%rbp)
movl 0x20(%rax), %ecx
andl $0x10000, %ecx          # imm = 0x10000
movl %ecx, -0x1cc(%rbp)
movl 0x20(%rax), %eax
andl $0x40000, %eax          # imm = 0x40000
movl %eax, -0x1d0(%rbp)
movb $0x1e, -0x1d1(%rbp)
cmpl $0x2, -0x4(%rbp)
jl 0x603a2
cmpl $0x3, -0x4(%rbp)
jle 0x603e0
movq -0x18(%rbp), %rdi
leaq 0x35c04(%rip), %rsi     # 0x95fb1
callq 0x1fff0
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq -0x2d8(%rbp), %rdi
movq %rax, -0x1e0(%rbp)
movq -0x1e0(%rbp), %rsi
callq 0x1ff40
jmp 0x60ce4
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xe0(%rbp)
cmpl $0x2, -0x4(%rbp)
jle 0x60406
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xe8(%rbp)
jmp 0x6042a
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq %rax, -0x1e8(%rbp)
movq -0x1e8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x210(%rbp), %rdi
callq 0x1fed0
leaq -0x50(%rbp), %rdi
leaq -0x210(%rbp), %rsi
movl $0x28, %edx
callq 0x12680
movq -0x2c8(%rbp), %rsi
leaq -0x78(%rbp), %rdi
movl $0x28, %edx
callq 0x12680
movl -0x58(%rbp), %eax
andl $0xfff7ffff, %eax       # imm = 0xFFF7FFFF
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x1d0(%rbp)
jne 0x60481
cmpl $0x0, -0x1cc(%rbp)
je 0x604d6
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq %rax, -0x230(%rbp)
movq -0x230(%rbp), %rsi
leaq -0x228(%rbp), %rdi
callq 0x1ff40
movq -0x228(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x220(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x218(%rbp), %rax
movq %rax, -0xc8(%rbp)
jmp 0x6052c
movq -0x2c8(%rbp), %rcx
movq 0x20(%rcx), %rdx
movq %rsp, %rax
movq %rdx, 0x20(%rax)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0x248(%rbp), %rdi
callq 0x213c0
movq -0x248(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x240(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x238(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x158(%rbp), %rdi
xorl %edx, %edx
leaq 0x35a8e(%rip), %rcx     # 0x95fce
callq 0x204d0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x250(%rbp)
movq -0x250(%rbp), %rdi
leaq -0x250(%rbp), %rsi
movl $0x18, %edx
callq 0x63790
cmpl $0x0, %eax
je 0x60579
movb $0x20, -0x1d1(%rbp)
jmp 0x6059f
movq -0x250(%rbp), %rdi
leaq -0x250(%rbp), %rsi
movl $0x19, %edx
callq 0x63790
cmpl $0x0, %eax
je 0x6059d
movb $0x1f, -0x1d1(%rbp)
jmp 0x6059f
movq -0x250(%rbp), %rsi
movq -0x30(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x20(%rax)
movups -0x50(%rbp), %xmm0
movups -0x40(%rbp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0x268(%rbp), %rdi
callq 0x21590
movq -0x268(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x260(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x258(%rbp), %rax
movq %rax, -0x80(%rbp)
movl -0x80(%rbp), %eax
andl $0x10000, %eax          # imm = 0x10000
cmpl $0x0, %eax
je 0x60973
movl $0x0, -0x26c(%rbp)
movzbl -0x1d1(%rbp), %eax
cmpl $0x1e, %eax
jne 0x606e8
xorl %eax, %eax
testb $0x1, %al
jne 0x60626
jmp 0x60659
movsd -0x90(%rbp), %xmm0
ucomisd %xmm0, %xmm0
setp %al
testb $0x1, %al
jne 0x6063e
jmp 0x606de
movq -0x90(%rbp), %rax
shrq $0x2f, %rax
andq $0xf, %rax
cmpq $0x0, %rax
je 0x606de
jmp 0x60679
movabsq $-0x800000000000, %rax  # imm = 0xFFFF800000000000
andq -0x90(%rbp), %rax
movabsq $-0x7800000000000, %rcx # imm = 0xFFF8800000000000
cmpq %rcx, %rax
je 0x606de
xorl %eax, %eax
testb $0x1, %al
jne 0x60681
jmp 0x606ad
movsd -0x90(%rbp), %xmm0
ucomisd %xmm0, %xmm0
setp %al
testb $0x1, %al
jne 0x60696
jmp 0x606cd
movq -0x90(%rbp), %rax
shrq $0x2f, %rax
andq $0xf, %rax
cmpq $0x0, %rax
je 0x606cd
jmp 0x606e8
movabsq $-0x800000000000, %rax  # imm = 0xFFFF800000000000
andq -0x90(%rbp), %rax
movabsq $-0x7000000000000, %rcx # imm = 0xFFF9000000000000
cmpq %rcx, %rax
jne 0x606e8
movq -0x90(%rbp), %rax
andq $0x1, %rax
cmpq $0x0, %rax
jne 0x606e8
movl $0x1, -0x26c(%rbp)
movzbl -0x1d1(%rbp), %eax
cmpl $0x1f, %eax
jne 0x60752
xorl %eax, %eax
testb $0x1, %al
jne 0x606fc
jmp 0x60728
movsd -0x90(%rbp), %xmm0
ucomisd %xmm0, %xmm0
setp %al
testb $0x1, %al
jne 0x60711
jmp 0x60748
movq -0x90(%rbp), %rax
shrq $0x2f, %rax
andq $0xf, %rax
cmpq $0x0, %rax
je 0x60748
jmp 0x60752
movabsq $-0x800000000000, %rax  # imm = 0xFFFF800000000000
andq -0x90(%rbp), %rax
movabsq $-0x7800000000000, %rcx # imm = 0xFFF8800000000000
cmpq %rcx, %rax
jne 0x60752
movl $0x1, -0x26c(%rbp)
movzbl -0x1d1(%rbp), %eax
cmpl $0x20, %eax
jne 0x607bc
xorl %eax, %eax
testb $0x1, %al
jne 0x60766
jmp 0x60792
movsd -0x90(%rbp), %xmm0
ucomisd %xmm0, %xmm0
setp %al
testb $0x1, %al
jne 0x6077b
jmp 0x607bc
movq -0x90(%rbp), %rax
shrq $0x2f, %rax
andq $0xf, %rax
cmpq $0x0, %rax
je 0x607bc
jmp 0x607b2
movabsq $-0x800000000000, %rax  # imm = 0xFFFF800000000000
andq -0x90(%rbp), %rax
movabsq $-0x7800000000000, %rcx # imm = 0xFFF8800000000000
cmpq %rcx, %rax
je 0x607bc
movl $0x1, -0x26c(%rbp)
cmpl $0x0, -0x26c(%rbp)
je 0x607ef
movq -0xe8(%rbp), %rax
movq %rax, -0x278(%rbp)
movq -0xe0(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x278(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
xorl %edx, %edx
leaq 0x357ce(%rip), %rcx     # 0x95fd1
callq 0x204d0
movq -0xe0(%rbp), %rsi
movq -0x58(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x20(%rax)
movups -0x78(%rbp), %xmm0
movups -0x68(%rbp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0x290(%rbp), %rdi
callq 0x21590
movq -0x290(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x288(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x280(%rbp), %rax
movq %rax, -0xb0(%rbp)
cmpl $0x0, -0x1d0(%rbp)
jne 0x608bb
cmpl $0x0, -0x1cc(%rbp)
jne 0x608bb
movq -0x18(%rbp), %rdi
leaq -0xd8(%rbp), %rcx
leaq -0xc0(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, (%rsp)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rsp)
movq (%rax), %rcx
movq %rcx, 0x18(%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x20(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x28(%rsp)
callq 0x295a0
movq -0x18(%rbp), %rdi
callq 0x20600
xorl %eax, %eax
testb $0x1, %al
jne 0x608cc
jmp 0x608f8
movsd -0xe8(%rbp), %xmm0
ucomisd %xmm0, %xmm0
setp %al
testb $0x1, %al
jne 0x608e1
jmp 0x6093e
movq -0xe8(%rbp), %rax
shrq $0x2f, %rax
andq $0xf, %rax
cmpq $0x0, %rax
je 0x6093e
jmp 0x60918
movabsq $-0x800000000000, %rax  # imm = 0xFFFF800000000000
andq -0xe8(%rbp), %rax
movabsq $-0x7800000000000, %rcx # imm = 0xFFF8800000000000
cmpq %rcx, %rax
je 0x6093e
movq -0xe8(%rbp), %rdi
movq -0x58(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x20(%rax)
movups -0x78(%rbp), %xmm0
movups -0x68(%rbp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x22420
movq -0x18(%rbp), %rdi
callq 0x20600
movq -0x2d8(%rbp), %rax
movq -0xd8(%rbp), %rcx
movq %rcx, (%rax)
movq -0xd0(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0xc8(%rbp), %rcx
movq %rcx, 0x10(%rax)
jmp 0x60ce4
movq -0x18(%rbp), %rdi
leaq -0x90(%rbp), %rax
xorl %ecx, %ecx
movzbl -0x1d1(%rbp), %esi
movq (%rax), %rdx
movq %rdx, (%rsp)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
movl %ecx, %edx
callq 0x29dd0
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
xorl %edx, %edx
leaq 0x35613(%rip), %rcx     # 0x95fd1
callq 0x204d0
movq -0xe0(%rbp), %rsi
movq -0x58(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x20(%rax)
movups -0x78(%rbp), %xmm0
movups -0x68(%rbp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0x2a8(%rbp), %rdi
callq 0x21590
movq -0x2a8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x2a0(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x298(%rbp), %rax
movq %rax, -0x98(%rbp)
cmpl $0x0, -0x1d0(%rbp)
jne 0x60a76
cmpl $0x0, -0x1cc(%rbp)
jne 0x60a76
movq -0x18(%rbp), %rdi
leaq -0xd8(%rbp), %rcx
leaq -0xa8(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, (%rsp)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rsp)
movq (%rax), %rcx
movq %rcx, 0x18(%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x20(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x28(%rsp)
callq 0x295a0
movq -0x18(%rbp), %rdi
callq 0x20600
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x60a9d
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x4(%rax), %eax
movl %eax, -0x2dc(%rbp)
jmp 0x60aa7
xorl %eax, %eax
movl %eax, -0x2dc(%rbp)
jmp 0x60aa7
movl -0x2dc(%rbp), %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x1cc(%rbp)
jne 0x60b24
cmpl $0x0, -0x1d0(%rbp)
je 0x60b16
xorl %eax, %eax
testb $0x1, %al
jne 0x60aca
jmp 0x60af6
movsd -0xe8(%rbp), %xmm0
ucomisd %xmm0, %xmm0
setp %al
testb $0x1, %al
jne 0x60adf
jmp 0x60b24
movq -0xe8(%rbp), %rax
shrq $0x2f, %rax
andq $0xf, %rax
cmpq $0x0, %rax
je 0x60b24
jmp 0x60b16
movabsq $-0x800000000000, %rax  # imm = 0xFFFF800000000000
andq -0xe8(%rbp), %rax
movabsq $-0x7800000000000, %rcx # imm = 0xFFF8800000000000
cmpq %rcx, %rax
je 0x60b24
movq -0x18(%rbp), %rdi
movl $0x1c, %esi
callq 0x29410
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x60b42
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x4(%rax), %eax
movl %eax, -0x2e0(%rbp)
jmp 0x60b4c
xorl %eax, %eax
movl %eax, -0x2e0(%rbp)
jmp 0x60b4c
movl -0x2e0(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
xorl %edx, %edx
leaq 0x35470(%rip), %rcx     # 0x95fd9
callq 0x204d0
movq -0xe8(%rbp), %rsi
movq -0x58(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x20(%rax)
movups -0x78(%rbp), %xmm0
movups -0x68(%rbp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0x2c0(%rbp), %rdi
callq 0x21590
movq -0x2c0(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x2b8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x2b0(%rbp), %rax
movq %rax, -0xb0(%rbp)
cmpl $0x0, -0x1d0(%rbp)
jne 0x60c21
cmpl $0x0, -0x1cc(%rbp)
jne 0x60c21
movq -0x18(%rbp), %rdi
leaq -0xd8(%rbp), %rcx
leaq -0xc0(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, (%rsp)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rsp)
movq (%rax), %rcx
movq %rcx, 0x18(%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x20(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x28(%rsp)
callq 0x295a0
movq -0x18(%rbp), %rdi
callq 0x20600
movq -0x18(%rbp), %rdi
callq 0x20600
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x60c51
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x4(%rax), %eax
movl %eax, -0x2e4(%rbp)
jmp 0x60c5b
xorl %eax, %eax
movl %eax, -0x2e4(%rbp)
jmp 0x60c5b
movl -0x2e4(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x1c(%rbp), %edx
subl -0x20(%rbp), %edx
shll $0x10, %edx
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x20(%rbp), %rcx
orl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
cmpl $0x0, -0x1cc(%rbp)
jne 0x60ca3
movl -0x24(%rbp), %edx
subl -0x28(%rbp), %edx
shll $0x8, %edx
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x28(%rbp), %rcx
orl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
cmpl $0x0, -0x1cc(%rbp)
je 0x60cbd
movl -0xc8(%rbp), %eax
orl $0x100000, %eax         # imm = 0x100000
movl %eax, -0xc8(%rbp)
movq -0x2d8(%rbp), %rax
movq -0xd8(%rbp), %rcx
movq %rcx, (%rax)
movq -0xd0(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0xc8(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x2d0(%rbp), %rax
addq $0x320, %rsp            # imm = 0x320
popq %rbp
retq
nopw %cs:(%rax,%rax)