// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/fiber.c
// Function: janet_fiber_funcframe
int janet_fiber_funcframe(JanetFiber *fiber, JanetFunction *func) {
    JanetStackFrame *newframe;

    int32_t i;
    int32_t oldtop = fiber->stacktop;
    int32_t oldframe = fiber->frame;
    int32_t nextframe = fiber->stackstart;
    int32_t nextstacktop = nextframe + func->def->slotcount + JANET_FRAME_SIZE;
    int32_t next_arity = fiber->stacktop - fiber->stackstart;

    /* Check strict arity before messing with state */
    if (next_arity < func->def->min_arity) return 1;
    if (next_arity > func->def->max_arity) return 1;

    if (fiber->capacity < nextstacktop) {
        janet_fiber_setcapacity(fiber, 2 * nextstacktop);
#ifdef JANET_DEBUG
    } else {
        janet_fiber_refresh_memory(fiber);
#endif
    }

    /* Nil unset stack arguments (Needed for gc correctness) */
    for (i = fiber->stacktop; i < nextstacktop; ++i) {
        fiber->data[i] = janet_wrap_nil();
    }

    /* Set up the next frame */
    fiber->frame = nextframe;
    fiber->stacktop = fiber->stackstart = nextstacktop;
    newframe = janet_fiber_frame(fiber);
    newframe->prevframe = oldframe;
    newframe->pc = func->def->bytecode;
    newframe->func = func;
    newframe->env = NULL;
    newframe->flags = 0;

    /* Check varargs */
    if (func->def->flags & JANET_FUNCDEF_FLAG_VARARG) {
        int32_t tuplehead = fiber->frame + func->def->arity;
        int st = func->def->flags & JANET_FUNCDEF_FLAG_STRUCTARG;
        if (tuplehead >= oldtop) {
            fiber->data[tuplehead] = st
                                     ? make_struct_n(NULL, 0)
                                     : janet_wrap_tuple(janet_tuple_n(NULL, 0));
        } else {
            fiber->data[tuplehead] = st
                                     ? make_struct_n(
                                         fiber->data + tuplehead,
                                         oldtop - tuplehead)
                                     : janet_wrap_tuple(janet_tuple_n(
                                             fiber->data + tuplehead,
                                             oldtop - tuplehead));
        }
    }

    /* Good return */
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
addl 0x5c(%rcx), %eax
addl $0x4, %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movq -0x10(%rbp), %rcx
subl 0x18(%rcx), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
cmpl 0x64(%rcx), %eax
jge 0x361d2
movl $0x1, -0x4(%rbp)
jmp 0x36437
movl -0x38(%rbp), %eax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
cmpl 0x68(%rcx), %eax
jle 0x361ee
movl $0x1, -0x4(%rbp)
jmp 0x36437
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
cmpl -0x34(%rbp), %eax
jge 0x36208
movq -0x10(%rbp), %rdi
movl -0x34(%rbp), %esi
shll %esi
callq 0x360a0
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x3625f
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x70(%rbp)
movslq -0x24(%rbp), %rax
movq %rax, -0x78(%rbp)
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq -0x78(%rbp), %rcx
movq %rax, %rdx
movq -0x70(%rbp), %rax
movq %rdx, -0x40(%rbp)
movq -0x40(%rbp), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x36212
movl -0x30(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
movl -0x34(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x14(%rcx), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
addq $-0x20, %rax
movq %rax, -0x20(%rbp)
movl -0x2c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x28(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x1c(%rax)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x58(%rax), %eax
andl $0x10000, %eax          # imm = 0x10000
cmpl $0x0, %eax
je 0x36430
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
addl 0x60(%rcx), %eax
movl %eax, -0x44(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x58(%rax), %eax
andl $0x1000000, %eax        # imm = 0x1000000
movl %eax, -0x48(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x28(%rbp), %eax
jl 0x36392
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x44(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
cmpl $0x0, -0x48(%rbp)
je 0x3635e
xorl %eax, %eax
movl %eax, %edi
xorl %esi, %esi
callq 0x36820
movq %rax, %rcx
movq -0x80(%rbp), %rax
movq %rcx, -0x50(%rbp)
movq -0x50(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x3638d
xorl %eax, %eax
movl %eax, %edi
xorl %esi, %esi
callq 0x6a7d0
movq %rax, %rdi
movabsq $-0x4000000000000, %rsi # imm = 0xFFFC000000000000
callq 0x7b550
movq %rax, %rcx
movq -0x80(%rbp), %rax
movq %rcx, -0x58(%rbp)
movq -0x58(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x3642e
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x44(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
cmpl $0x0, -0x48(%rbp)
je 0x363e7
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movslq -0x44(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movl -0x28(%rbp), %esi
subl -0x44(%rbp), %esi
callq 0x36820
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, -0x60(%rbp)
movq -0x60(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x3642c
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movslq -0x44(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movl -0x28(%rbp), %esi
subl -0x44(%rbp), %esi
callq 0x6a7d0
movq %rax, %rdi
movabsq $-0x4000000000000, %rsi # imm = 0xFFFC000000000000
callq 0x7b550
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, -0x68(%rbp)
movq -0x68(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x3642e
jmp 0x36430
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)