// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/vm.c
// Function: janet_call
Janet janet_call(JanetFunction *fun, int32_t argc, const Janet *argv) {
    /* Check entry conditions */
    if (!janet_vm.fiber)
        janet_panic("janet_call failed because there is no current fiber");
    if (janet_vm.stackn >= JANET_RECURSION_GUARD)
        janet_panic("C stack recursed too deeply");

    /* Dirty stack */
    int32_t dirty_stack = janet_vm.fiber->stacktop - janet_vm.fiber->stackstart;
    if (dirty_stack) {
        janet_fiber_cframe(janet_vm.fiber, void_cfunction);
    }

    /* Tracing */
    if (fun->gc.flags & JANET_FUNCFLAG_TRACE) {
        janet_vm.stackn++;
        vm_do_trace(fun, argc, argv);
        janet_vm.stackn--;
    }

    /* Push frame */
    janet_fiber_pushn(janet_vm.fiber, argv, argc);
    if (janet_fiber_funcframe(janet_vm.fiber, fun)) {
        int32_t min = fun->def->min_arity;
        int32_t max = fun->def->max_arity;
        Janet funv = janet_wrap_function(fun);
        if (min == max && min != argc)
            janet_panicf("arity mismatch in %v, expected %d, got %d", funv, min, argc);
        if (min >= 0 && argc < min)
            janet_panicf("arity mismatch in %v, expected at least %d, got %d", funv, min, argc);
        janet_panicf("arity mismatch in %v, expected at most %d, got %d", funv, max, argc);
    }
    janet_fiber_frame(janet_vm.fiber)->flags |= JANET_STACKFRAME_ENTRANCE;

    /* Set up */
    int32_t oldn = janet_vm.stackn++;
    int handle = janet_gclock();

    /* Run vm */
    janet_vm.fiber->flags |= JANET_FIBER_RESUME_NO_USEVAL | JANET_FIBER_RESUME_NO_SKIP;
    int old_coerce_error = janet_vm.coerce_error;
    janet_vm.coerce_error = 1;
    JanetSignal signal = run_vm(janet_vm.fiber, janet_wrap_nil());
    janet_vm.coerce_error = old_coerce_error;

    /* Teardown */
    janet_vm.stackn = oldn;
    janet_gcunlock(handle);
    if (dirty_stack) {
        janet_fiber_popframe(janet_vm.fiber);
        janet_vm.fiber->stacktop += dirty_stack;
    }

    if (signal != JANET_SIGNAL_OK) {
        /* Should match logic in janet_signalv */
#ifdef JANET_EV
        if (janet_vm.root_fiber != NULL && signal == JANET_SIGNAL_EVENT) {
            janet_vm.root_fiber->sched_id++;
        }
#endif
        if (signal != JANET_SIGNAL_ERROR) {
            *janet_vm.return_reg = janet_wrap_string(janet_formatc("%v coerced from %s to error", *janet_vm.return_reg, janet_signal_names[signal]));
        }
        janet_panicv(*janet_vm.return_reg);
    }

    return *janet_vm.return_reg;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
cmpq $0x0, 0x20(%rax)
jne 0x70b19
leaq 0x28336(%rip), %rdi     # 0x98e4a
callq 0x1ad60
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
cmpl $0x400, 0x18(%rax)      # imm = 0x400
jl 0x70b3e
leaq 0x28345(%rip), %rdi     # 0x98e7e
callq 0x1ad60
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x20(%rax), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x5c(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq %rax, %rcx
movl -0x5c(%rbp), %eax
movq 0x20(%rcx), %rcx
subl 0x18(%rcx), %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x70b9e
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x20(%rax), %rdi
leaq 0x3b7(%rip), %rsi       # 0x70f50
callq 0x37060
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x10000, %eax          # imm = 0x10000
cmpl $0x0, %eax
je 0x70bf0
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
callq 0x70f70
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movl 0x18(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x18(%rax)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x20(%rax), %rdi
movq -0x20(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x36790
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x36160
cmpl $0x0, %eax
je 0x70ccf
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x64(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x68(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
movabsq $-0x2000000000000, %rsi # imm = 0xFFFE000000000000
callq 0x7b610
movq %rax, -0x38(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jne 0x70c91
movl -0x28(%rbp), %eax
cmpl -0x14(%rbp), %eax
je 0x70c91
movl -0x28(%rbp), %edx
movl -0x14(%rbp), %ecx
movq -0x38(%rbp), %rsi
leaq 0x28210(%rip), %rdi     # 0x98e9a
movb $0x0, %al
callq 0x1ac40
cmpl $0x0, -0x28(%rbp)
jl 0x70cb7
movl -0x14(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x70cb7
movl -0x28(%rbp), %edx
movl -0x14(%rbp), %ecx
movq -0x38(%rbp), %rsi
leaq 0x28214(%rip), %rdi     # 0x98ec4
movb $0x0, %al
callq 0x1ac40
movl -0x2c(%rbp), %edx
movl -0x14(%rbp), %ecx
movq -0x38(%rbp), %rsi
leaq 0x2822f(%rip), %rdi     # 0x98ef7
movb $0x0, %al
callq 0x1ac40
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x20(%rax), %rax
movq 0x30(%rax), %rax
movq %rax, -0x78(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq %rax, %rcx
movq -0x78(%rbp), %rax
movq 0x20(%rcx), %rcx
movslq 0x14(%rcx), %rcx
movl -0x4(%rax,%rcx,8), %edx
orl $0x2, %edx
movl %edx, -0x4(%rax,%rcx,8)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq %rax, %rcx
movl 0x18(%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x18(%rcx)
movl %eax, -0x3c(%rbp)
callq 0x3a810
movl %eax, -0x40(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x20(%rax), %rax
movl 0x10(%rax), %ecx
orl $0x6000000, %ecx        # imm = 0x6000000
movl %ecx, 0x10(%rax)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movl 0x40(%rax), %eax
movl %eax, -0x44(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movl $0x1, 0x40(%rax)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x20(%rax), %rax
movq %rax, -0x70(%rbp)
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq -0x70(%rbp), %rdi
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rsi
callq 0x71070
movl %eax, -0x48(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x64(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movl -0x64(%rbp), %ecx
movl %ecx, 0x40(%rax)
movl -0x3c(%rbp), %eax
movl %eax, -0x60(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movl -0x60(%rbp), %ecx
movl %ecx, 0x18(%rax)
movl -0x40(%rbp), %edi
callq 0x3a840
cmpl $0x0, -0x24(%rbp)
je 0x70e48
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x20(%rax), %rdi
callq 0x37130
movl -0x24(%rbp), %eax
movl %eax, -0x7c(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movl -0x7c(%rbp), %ecx
movq 0x20(%rax), %rax
addl 0x1c(%rax), %ecx
movl %ecx, 0x1c(%rax)
cmpl $0x0, -0x48(%rbp)
je 0x70f25
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
cmpq $0x0, 0x28(%rax)
je 0x70e8c
cmpl $0xd, -0x48(%rbp)
jne 0x70e8c
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x28(%rax), %rax
movl 0x48(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x48(%rax)
cmpl $0x1, -0x48(%rbp)
je 0x70f09
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x38(%rax), %rax
movq %rax, -0x88(%rbp)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x38(%rax), %rax
movl -0x48(%rbp), %ecx
movl %ecx, %edx
leaq 0x3ede3(%rip), %rcx     # 0xafcb0
movq (%rcx,%rdx,8), %rdx
movq (%rax), %rsi
leaq 0x101c5(%rip), %rdi     # 0x810a0
movb $0x0, %al
callq 0x5bdd0
movq %rax, %rdi
movabsq $-0x6000000000000, %rsi # imm = 0xFFFA000000000000
callq 0x7b550
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, -0x58(%rbp)
movq -0x58(%rbp), %rcx
movq %rcx, (%rax)
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x38(%rax), %rax
movq (%rax), %rdi
callq 0x1ac20
movq %fs:0x0, %rax
leaq -0x348(%rax), %rax
movq 0x38(%rax), %rax
movq (%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)