// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/fiber.c
// Function: janet_fiber_funcframe_tail
int janet_fiber_funcframe_tail(JanetFiber *fiber, JanetFunction *func) {
    int32_t i;
    int32_t nextframetop = fiber->frame + func->def->slotcount;
    int32_t nextstacktop = nextframetop + JANET_FRAME_SIZE;
    int32_t next_arity = fiber->stacktop - fiber->stackstart;
    int32_t stacksize;

    /* 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
    }

    Janet *stack = fiber->data + fiber->frame;
    Janet *args = fiber->data + fiber->stackstart;

    /* Detach old function */
    if (NULL != janet_fiber_frame(fiber)->func)
        janet_env_detach(janet_fiber_frame(fiber)->env);
    janet_fiber_frame(fiber)->env = NULL;

    /* Check varargs */
    if (func->def->flags & JANET_FUNCDEF_FLAG_VARARG) {
        int32_t tuplehead = fiber->stackstart + func->def->arity;
        int st = func->def->flags & JANET_FUNCDEF_FLAG_STRUCTARG;
        if (tuplehead >= fiber->stacktop) {
            if (tuplehead >= fiber->capacity) janet_fiber_setcapacity(fiber, 2 * (tuplehead + 1));
            for (i = fiber->stacktop; i < tuplehead; ++i) fiber->data[i] = janet_wrap_nil();
            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,
                                         fiber->stacktop - tuplehead)
                                     : janet_wrap_tuple(janet_tuple_n(
                                             fiber->data + tuplehead,
                                             fiber->stacktop - tuplehead));
        }
        stacksize = tuplehead - fiber->stackstart + 1;
    } else {
        stacksize = fiber->stacktop - fiber->stackstart;
    }

    if (stacksize) memmove(stack, args, stacksize * sizeof(Janet));

    /* Nil unset locals (Needed for functional correctness) */
    for (i = fiber->frame + stacksize; i < nextframetop; ++i)
        fiber->data[i] = janet_wrap_nil();

    /* Set stack stuff */
    fiber->stacktop = fiber->stackstart = nextstacktop;

    /* Set frame stuff */
    janet_fiber_frame(fiber)->func = func;
    janet_fiber_frame(fiber)->pc = func->def->bytecode;
    janet_fiber_frame(fiber)->flags |= JANET_STACKFRAME_TAILCALL;

    /* Good return */
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
addl 0x5c(%rcx), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movq -0x10(%rbp), %rcx
subl 0x18(%rcx), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
cmpl 0x64(%rcx), %eax
jge 0x36c9e
movl $0x1, -0x4(%rbp)
jmp 0x3704f
movl -0x28(%rbp), %eax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
cmpl 0x68(%rcx), %eax
jle 0x36cba
movl $0x1, -0x4(%rbp)
jmp 0x3704f
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
cmpl -0x24(%rbp), %eax
jge 0x36cd4
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
shll %esi
callq 0x360a0
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x14(%rcx), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x18(%rcx), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rcx
movq -0x10(%rbp), %rax
movslq 0x14(%rax), %rdx
xorl %eax, %eax
cmpq -0x20(%rcx,%rdx,8), %rax
je 0x36d3d
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x14(%rcx), %rcx
movq -0x10(%rax,%rcx,8), %rdi
callq 0x36a60
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x14(%rcx), %rcx
movq $0x0, -0x10(%rax,%rcx,8)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x58(%rax), %eax
andl $0x10000, %eax          # imm = 0x10000
cmpl $0x0, %eax
je 0x36f50
movq -0x10(%rbp), %rax
movl 0x18(%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
movq -0x10(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jl 0x36e9a
movl -0x44(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x20(%rcx), %eax
jl 0x36dc4
movq -0x10(%rbp), %rdi
movl -0x44(%rbp), %esi
addl $0x1, %esi
shll %esi
callq 0x360a0
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0x36e21
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x80(%rbp)
movslq -0x1c(%rbp), %rax
movq %rax, -0x88(%rbp)
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq -0x88(%rbp), %rcx
movq %rax, %rdx
movq -0x80(%rbp), %rax
movq %rdx, -0x50(%rbp)
movq -0x50(%rbp), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x36dce
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x44(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x90(%rbp)
cmpl $0x0, -0x48(%rbp)
je 0x36e63
xorl %eax, %eax
movl %eax, %edi
xorl %esi, %esi
callq 0x36820
movq %rax, %rcx
movq -0x90(%rbp), %rax
movq %rcx, -0x58(%rbp)
movq -0x58(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x36e95
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 -0x90(%rbp), %rax
movq %rcx, -0x60(%rbp)
movq -0x60(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x36f3e
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x44(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x98(%rbp)
cmpl $0x0, -0x48(%rbp)
je 0x36ef3
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movslq -0x44(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %esi
subl -0x44(%rbp), %esi
callq 0x36820
movq %rax, %rcx
movq -0x98(%rbp), %rax
movq %rcx, -0x68(%rbp)
movq -0x68(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x36f3c
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movslq -0x44(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %esi
subl -0x44(%rbp), %esi
callq 0x6a7d0
movq %rax, %rdi
movabsq $-0x4000000000000, %rsi # imm = 0xFFFC000000000000
callq 0x7b550
movq %rax, %rcx
movq -0x98(%rbp), %rax
movq %rcx, -0x70(%rbp)
movq -0x70(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x36f3e
movl -0x44(%rbp), %eax
movq -0x10(%rbp), %rcx
subl 0x18(%rcx), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x36f61
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
movq -0x10(%rbp), %rcx
subl 0x18(%rcx), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x36f7c
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movslq -0x2c(%rbp), %rdx
shlq $0x3, %rdx
callq 0x12930
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x36fe2
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0xa0(%rbp)
movslq -0x1c(%rbp), %rax
movq %rax, -0xa8(%rbp)
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq -0xa8(%rbp), %rcx
movq %rax, %rdx
movq -0xa0(%rbp), %rax
movq %rdx, -0x78(%rbp)
movq -0x78(%rbp), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x36f89
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x18(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x14(%rcx), %rcx
movq %rdx, -0x20(%rax,%rcx,8)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x28(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x14(%rcx), %rcx
movq %rdx, -0x18(%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x14(%rcx), %rcx
movl -0x4(%rax,%rcx,8), %edx
orl $0x1, %edx
movl %edx, -0x4(%rax,%rcx,8)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax,%rax)