// File: /workspace/github_c_makefile_star2_O1/janet-lang[P]janet/src/core/marsh.c
// Function: marshal_one_fiber
static void marshal_one_fiber(MarshalState *st, JanetFiber *fiber, int flags) {
    MARSH_STACKCHECK;
    int32_t fflags = fiber->flags;
    if (fiber->child) fflags |= JANET_FIBER_FLAG_HASCHILD;
    if (fiber->env) fflags |= JANET_FIBER_FLAG_HASENV;
    if (janet_fiber_status(fiber) == JANET_STATUS_ALIVE)
        janet_panic("cannot marshal alive fiber");
    pushint(st, fflags);
    pushint(st, fiber->frame);
    pushint(st, fiber->stackstart);
    pushint(st, fiber->stacktop);
    pushint(st, fiber->maxstack);
    /* Do frames */
    int32_t i = fiber->frame;
    int32_t j = fiber->stackstart - JANET_FRAME_SIZE;
    while (i > 0) {
        JanetStackFrame *frame = (JanetStackFrame *)(fiber->data + i - JANET_FRAME_SIZE);
        if (frame->env) frame->flags |= JANET_STACKFRAME_HASENV;
        if (!frame->func) janet_panicf("cannot marshal fiber with c stackframe (%v)", janet_wrap_cfunction((JanetCFunction) frame->pc));
        pushint(st, frame->flags);
        pushint(st, frame->prevframe);
        int32_t pcdiff = (int32_t)(frame->pc - frame->func->def->bytecode);
        pushint(st, pcdiff);
        marshal_one(st, janet_wrap_function(frame->func), flags + 1);
        if (frame->env) marshal_one_env(st, frame->env, flags + 1);
        /* Marshal all values in the stack frame */
        for (int32_t k = i; k < j; k++)
            marshal_one(st, fiber->data[k], flags + 1);
        j = i - JANET_FRAME_SIZE;
        i = frame->prevframe;
    }
    if (fiber->env) {
        marshal_one(st, janet_wrap_table(fiber->env), flags + 1);
    }
    if (fiber->child)
        marshal_one(st, janet_wrap_fiber(fiber->child), flags + 1);
    marshal_one(st, fiber->last_value, flags + 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movzwl %dx, %eax
cmpl $0x401, %eax            # imm = 0x401
jae 0x32053
movq %rsi, %r13
movq %rdi, %r12
movq %rdx, -0x40(%rbp)
movl 0x10(%rsi), %r14d
movq 0x38(%rsi), %r15
movq 0x28(%rsi), %rbx
movq %rsi, %rdi
callq 0x29e47
cmpl $0xf, %eax
je 0x3205f
movl %r14d, %eax
orl $0x20000000, %eax       # imm = 0x20000000
testq %r15, %r15
cmovel %r14d, %eax
movl %eax, %esi
orl $0x40000000, %esi       # imm = 0x40000000
testq %rbx, %rbx
cmovel %eax, %esi
movq %r12, %r15
movq %r12, %rdi
callq 0x2fa79
movl 0x14(%r13), %esi
movq %r12, %rdi
callq 0x2fa79
movl 0x18(%r13), %esi
movq %r12, %rdi
callq 0x2fa79
movl 0x1c(%r13), %esi
movq %r12, %rdi
callq 0x2fa79
movl 0x24(%r13), %esi
movq %r12, %rdi
callq 0x2fa79
movl 0x14(%r13), %eax
testl %eax, %eax
jle 0x31fc0
movl 0x18(%r13), %ebx
movq -0x40(%rbp), %rcx
leal 0x1(%rcx), %r12d
movq %r13, -0x48(%rbp)
movq 0x30(%r13), %r14
movl %eax, %ecx
cmpq $0x0, -0x10(%r14,%rcx,8)
je 0x31eec
orb $-0x80, -0x1(%r14,%rcx,8)
cmpq $0x0, -0x20(%r14,%rcx,8)
je 0x3202e
movl %eax, -0x34(%rbp)
movq %rcx, %r13
movl -0x4(%r14,%rcx,8), %esi
movq %r15, %rdi
callq 0x2fa79
movl -0x8(%r14,%r13,8), %esi
movq %r15, %rdi
callq 0x2fa79
movq -0x20(%r14,%r13,8), %rax
movq -0x18(%r14,%r13,8), %rsi
movq 0x10(%rax), %rax
subq 0x28(%rax), %rsi
shrq $0x2, %rsi
movq %r15, %rdi
callq 0x2fa79
movq -0x20(%r14,%r13,8), %rdi
movabsq $-0x2000000000000, %rsi # imm = 0xFFFE000000000000
callq 0x4f9f2
movq %r15, %rdi
movq %rax, %rsi
movl %r12d, %edx
callq 0x2fb6f
movq %r14, -0x50(%rbp)
movq %r13, -0x30(%rbp)
movq -0x10(%r14,%r13,8), %rsi
testq %rsi, %rsi
je 0x31f75
movq %r15, %rdi
movl %r12d, %edx
callq 0x31c12
addl $-0x4, %ebx
cmpl %ebx, -0x30(%rbp)
movq %r15, %r13
movq -0x48(%rbp), %r14
jge 0x31fa3
movq -0x30(%rbp), %r15
movq 0x30(%r14), %rax
movq (%rax,%r15,8), %rsi
movq %r13, %rdi
movl %r12d, %edx
callq 0x2fb6f
incq %r15
cmpl %r15d, %ebx
jg 0x31f88
movq -0x50(%rbp), %rax
movq -0x30(%rbp), %rcx
movl -0x8(%rax,%rcx,8), %eax
testl %eax, %eax
movq %r13, %r15
movq %r14, %r13
movl -0x34(%rbp), %ebx
jg 0x31ed8
movq 0x28(%r13), %rdi
testq %rdi, %rdi
movq -0x40(%rbp), %rbx
je 0x31fea
movabsq $-0x3800000000000, %rsi # imm = 0xFFFC800000000000
callq 0x4f9f2
leal 0x1(%rbx), %edx
movq %r15, %rdi
movq %rax, %rsi
callq 0x2fb6f
movq 0x38(%r13), %rdi
testq %rdi, %rdi
je 0x32010
movabsq $-0x6800000000000, %rsi # imm = 0xFFF9800000000000
callq 0x4f9f2
leal 0x1(%rbx), %edx
movq %r15, %rdi
movq %rax, %rsi
callq 0x2fb6f
incl %ebx
movq 0x40(%r13), %rsi
movq %r15, %rdi
movl %ebx, %edx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2fb6f
movq -0x18(%r14,%rcx,8), %rdi
movabsq $-0x1800000000000, %rsi # imm = 0xFFFE800000000000
callq 0x4f9f2
leaq 0x2ec40(%rip), %rdi     # 0x60c89
movq %rax, %rsi
xorl %eax, %eax
callq 0x1917b
leaq 0x2be99(%rip), %rdi     # 0x5def3
callq 0x19263
leaq 0x2ec08(%rip), %rdi     # 0x60c6e
callq 0x19263