// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/compile.c
// Function: janetc_call
static JanetSlot janetc_call(JanetFopts opts, JanetSlot *slots, JanetSlot fun) {
    JanetSlot retslot;
    JanetCompiler *c = opts.compiler;
    int specialized = 0;
    if (fun.flags & JANET_SLOT_CONSTANT && !has_spliced(slots)) {
        if (janet_checktype(fun.constant, JANET_FUNCTION)) {
            JanetFunction *f = janet_unwrap_function(fun.constant);
            const JanetFunOptimizer *o = janetc_funopt(f->def->flags);
            if (o && (!o->can_optimize || o->can_optimize(opts, slots))) {
                specialized = 1;
                retslot = o->optimize(opts, slots);
            }
        }
        /* TODO janet function inlining (no c functions)*/
    }
    if (!specialized) {
        int32_t min_arity = janetc_pushslots(c, slots);
        /* Check for provably incorrect function calls */
        if (fun.flags & JANET_SLOT_CONSTANT) {

            /* Check for bad arity type if fun is a constant */
            switch (janet_type(fun.constant)) {
                case JANET_FUNCTION: {
                    JanetFunction *f = janet_unwrap_function(fun.constant);
                    int32_t min = f->def->min_arity;
                    int32_t max = f->def->max_arity;
                    if (min_arity < 0) {
                        /* Call has splices */
                        min_arity = -1 - min_arity;
                        if (min_arity > max && max >= 0) {
                            const uint8_t *es = janet_formatc(
                                                    "%v expects at most %d argument%s, got at least %d",
                                                    fun.constant, max, max == 1 ? "" : "s", min_arity);
                            janetc_error(c, es);
                        }
                    } else {
                        /* Call has no splices */
                        if (min_arity > max && max >= 0) {
                            const uint8_t *es = janet_formatc(
                                                    "%v expects at most %d argument%s, got %d",
                                                    fun.constant, max, max == 1 ? "" : "s", min_arity);
                            janetc_error(c, es);
                        }
                        if (min_arity < min) {
                            const uint8_t *es = janet_formatc(
                                                    "%v expects at least %d argument%s, got %d",
                                                    fun.constant, min, min == 1 ? "" : "s", min_arity);
                            janetc_error(c, es);
                        }
                    }
                }
                break;
                case JANET_CFUNCTION:
                case JANET_ABSTRACT:
                case JANET_NIL:
                    break;
                case JANET_KEYWORD:
                    if (min_arity == 0) {
                        const uint8_t *es = janet_formatc("%v expects at least 1 argument, got 0",
                                                          fun.constant);
                        janetc_error(c, es);
                    }
                    break;
                default:
                    if (min_arity > 1 || min_arity == 0) {
                        const uint8_t *es = janet_formatc("%v expects 1 argument, got %d",
                                                          fun.constant, min_arity);
                        janetc_error(c, es);
                    }
                    if (min_arity < -2) {
                        const uint8_t *es = janet_formatc("%v expects 1 argument, got at least %d",
                                                          fun.constant, -1 - min_arity);
                        janetc_error(c, es);
                    }
                    break;
            }
        }

        if ((opts.flags & JANET_FOPTS_TAIL) &&
                /* Prevent top level tail calls for better errors */
                !(c->scope->flags & JANET_SCOPE_TOP)) {
            janetc_emit_s(c, JOP_TAILCALL, fun, 0);
            retslot = janetc_cslot(janet_wrap_nil());
            retslot.flags = JANET_SLOT_RETURNED;
        } else {
            retslot = janetc_gettarget(opts);
            janetc_emit_ss(c, JOP_CALL, retslot, fun, 1);
        }
    }
    janetc_freeslots(c, slots);
    return retslot;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0xe0(%rbp)
movq %rdi, -0xd8(%rbp)
leaq 0x38(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq 0x10(%rbp), %rcx
movq %rcx, -0xc8(%rbp)
movq %rsi, -0x8(%rbp)
movq (%rcx), %rcx
movq %rcx, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl 0x10(%rax), %eax
andl $0x10000, %eax          # imm = 0x10000
cmpl $0x0, %eax
je 0x22c41
movq -0x8(%rbp), %rdi
callq 0x24880
cmpl $0x0, %eax
jne 0x22c41
xorl %eax, %eax
testb $0x1, %al
jne 0x22b1c
jmp 0x22b51
movq -0xd0(%rbp), %rax
movsd (%rax), %xmm0
ucomisd %xmm0, %xmm0
setp %al
testb $0x1, %al
jne 0x22b34
jmp 0x22b78
movq -0xd0(%rbp), %rax
movq (%rax), %rax
shrq $0x2f, %rax
andq $0xf, %rax
cmpq $0x0, %rax
je 0x22b78
jmp 0x22c3f
movq -0xd0(%rbp), %rcx
movabsq $-0x800000000000, %rax  # imm = 0xFFFF800000000000
andq (%rcx), %rax
movabsq $-0x2000000000000, %rcx # imm = 0xFFFE000000000000
cmpq %rcx, %rax
jne 0x22c3f
movq -0xd0(%rbp), %rax
movq (%rax), %rdi
callq 0x7b260
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x58(%rax), %edi
callq 0x1d780
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x22c3d
movq -0x28(%rbp), %rax
cmpq $0x0, (%rax)
je 0x22be6
movq -0xc8(%rbp), %rdx
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rdi
movq 0x20(%rdx), %rsi
movq %rsp, %rcx
movq %rsi, 0x20(%rcx)
movups (%rdx), %xmm0
movups 0x10(%rdx), %xmm1
movups %xmm1, 0x10(%rcx)
movups %xmm0, (%rcx)
callq *%rax
cmpl $0x0, %eax
je 0x22c3d
movq -0xc8(%rbp), %rdx
movl $0x1, -0x14(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rsi
movq 0x20(%rdx), %rdi
movq %rsp, %rcx
movq %rdi, 0x20(%rcx)
movups (%rdx), %xmm0
movups 0x10(%rdx), %xmm1
movups %xmm1, 0x10(%rcx)
movups %xmm0, (%rcx)
leaq -0x40(%rbp), %rdi
callq *%rax
movq -0xe0(%rbp), %rax
movq -0x40(%rbp), %rcx
movq %rcx, (%rax)
movq -0x38(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rcx
movq %rcx, 0x10(%rax)
jmp 0x22c3f
jmp 0x22c41
cmpl $0x0, -0x14(%rbp)
jne 0x23035
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x21f70
movl %eax, %ecx
movq -0xd0(%rbp), %rax
movl %ecx, -0x44(%rbp)
movl 0x10(%rax), %eax
andl $0x10000, %eax          # imm = 0x10000
cmpl $0x0, %eax
je 0x22ed9
movq -0xd0(%rbp), %rax
movsd (%rax), %xmm0
ucomisd %xmm0, %xmm0
setp %al
testb $0x1, %al
jne 0x22c8d
jmp 0x22ca7
movq -0xd0(%rbp), %rax
movq (%rax), %rax
shrq $0x2f, %rax
andq $0xf, %rax
movl %eax, -0xe4(%rbp)
jmp 0x22cb1
xorl %eax, %eax
movl %eax, -0xe4(%rbp)
jmp 0x22cb1
movl -0xe4(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0xf0(%rbp)
subl $0xd, %eax
ja 0x22e60
movq -0xf0(%rbp), %rax
leaq 0x5e69b(%rip), %rcx     # 0x81374
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0xd0(%rbp), %rax
movq (%rax), %rdi
callq 0x7b260
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x64(%rax), %eax
movl %eax, -0x54(%rbp)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x68(%rax), %eax
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x44(%rbp)
jge 0x22d7d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
subl -0x44(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x58(%rbp), %eax
jle 0x22d78
cmpl $0x0, -0x58(%rbp)
jl 0x22d78
movq -0xd0(%rbp), %rax
movl -0x58(%rbp), %edx
movl -0x58(%rbp), %edi
leaq 0x7261f(%rip), %rcx     # 0x95363
leaq 0x7673a(%rip), %rsi     # 0x99485
cmpl $0x1, %edi
cmoveq %rsi, %rcx
movl -0x44(%rbp), %r8d
movq (%rax), %rsi
leaq 0x5ea22(%rip), %rdi     # 0x81782
movb $0x0, %al
callq 0x5bdd0
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x1ffb0
jmp 0x22e25
movl -0x44(%rbp), %eax
cmpl -0x58(%rbp), %eax
jle 0x22dd3
cmpl $0x0, -0x58(%rbp)
jl 0x22dd3
movq -0xd0(%rbp), %rax
movl -0x58(%rbp), %edx
movl -0x58(%rbp), %edi
leaq 0x725c4(%rip), %rcx     # 0x95363
leaq 0x766df(%rip), %rsi     # 0x99485
cmpl $0x1, %edi
cmoveq %rsi, %rcx
movl -0x44(%rbp), %r8d
movq (%rax), %rsi
leaq 0x5e9f9(%rip), %rdi     # 0x817b4
movb $0x0, %al
callq 0x5bdd0
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x1ffb0
movl -0x44(%rbp), %eax
cmpl -0x54(%rbp), %eax
jge 0x22e23
movq -0xd0(%rbp), %rax
movl -0x54(%rbp), %edx
movl -0x54(%rbp), %edi
leaq 0x72574(%rip), %rcx     # 0x95363
leaq 0x7668f(%rip), %rsi     # 0x99485
cmpl $0x1, %edi
cmoveq %rsi, %rcx
movl -0x44(%rbp), %r8d
movq (%rax), %rsi
leaq 0x5e9d2(%rip), %rdi     # 0x817dd
movb $0x0, %al
callq 0x5bdd0
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x1ffb0
jmp 0x22e25
jmp 0x22ed7
jmp 0x22ed7
cmpl $0x0, -0x44(%rbp)
jne 0x22e5e
movq -0xd0(%rbp), %rax
movq (%rax), %rsi
leaq 0x5e9c1(%rip), %rdi     # 0x81807
movb $0x0, %al
callq 0x5bdd0
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x1ffb0
jmp 0x22ed7
cmpl $0x1, -0x44(%rbp)
jg 0x22e6c
cmpl $0x0, -0x44(%rbp)
jne 0x22e98
movq -0xd0(%rbp), %rax
movl -0x44(%rbp), %edx
movq (%rax), %rsi
leaq 0x5e9ad(%rip), %rdi     # 0x8182d
movb $0x0, %al
callq 0x5bdd0
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rdi
movq -0x80(%rbp), %rsi
callq 0x1ffb0
cmpl $-0x2, -0x44(%rbp)
jge 0x22ed5
movq -0xd0(%rbp), %rax
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
subl -0x44(%rbp), %edx
movq (%rax), %rsi
leaq 0x5e994(%rip), %rdi     # 0x8184b
movb $0x0, %al
callq 0x5bdd0
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0x1ffb0
jmp 0x22ed7
jmp 0x22ed9
movq -0xc8(%rbp), %rax
movl 0x20(%rax), %eax
andl $0x10000, %eax          # imm = 0x10000
cmpl $0x0, %eax
je 0x22f93
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x6c(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x22f93
movq -0xd0(%rbp), %rax
movq -0x10(%rbp), %rdi
movl $0x36, %esi
xorl %edx, %edx
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x29990
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x1ff40
movq -0xe0(%rbp), %rax
movq -0xa0(%rbp), %rcx
movq %rcx, (%rax)
movq -0x98(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x90(%rbp), %rcx
movq %rcx, 0x10(%rax)
movl $0x100000, 0x10(%rax)   # imm = 0x100000
jmp 0x23033
movq -0xc8(%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 -0xc0(%rbp), %rdi
callq 0x213c0
movq -0xe0(%rbp), %rcx
movq -0xd0(%rbp), %rax
movq -0xc0(%rbp), %rdx
movq %rdx, (%rcx)
movq -0xb8(%rbp), %rdx
movq %rdx, 0x8(%rcx)
movq -0xb0(%rbp), %rdx
movq %rdx, 0x10(%rcx)
movq -0x10(%rbp), %rdi
movl $0x35, %esi
movl $0x1, %edx
movq (%rcx), %r8
movq %r8, (%rsp)
movq 0x8(%rcx), %r8
movq %r8, 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 0x29e90
jmp 0x23035
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x22380
movq -0xd8(%rbp), %rax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw %cs:(%rax,%rax)