// File: /workspace/github_c_makefile_star2_O0/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
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl -0x14(%rbp), %eax
andl $0xffff, %eax           # imm = 0xFFFF
cmpl $0x400, %eax            # imm = 0x400
jle 0x443ae
leaq 0x45b6a(%rip), %rdi     # 0x89f13
callq 0x1ad60
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x443ce
movl -0x18(%rbp), %eax
orl $0x20000000, %eax       # imm = 0x20000000
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x443e4
movl -0x18(%rbp), %eax
orl $0x40000000, %eax       # imm = 0x40000000
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x36a40
cmpl $0xf, %eax
jne 0x443fe
leaq 0x488d5(%rip), %rdi     # 0x8ccce
callq 0x1ad60
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x405d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x14(%rax), %esi
callq 0x405d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x18(%rax), %esi
callq 0x405d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %esi
callq 0x405d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x24(%rax), %esi
callq 0x405d0
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
subl $0x4, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x1c(%rbp)
jle 0x445cc
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
addq $-0x20, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x444a1
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %ecx
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, 0x1c(%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x444d8
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
movabsq $-0x1800000000000, %rsi # imm = 0xFFFE800000000000
callq 0x7b610
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rsi
leaq 0x48818(%rip), %rdi     # 0x8cce9
movb $0x0, %al
callq 0x1ac40
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %esi
callq 0x405d0
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x18(%rax), %esi
callq 0x405d0
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rcx
movq 0x10(%rcx), %rcx
movq 0x28(%rcx), %rcx
subq %rcx, %rax
sarq $0x2, %rax
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x405d0
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movabsq $-0x2000000000000, %rsi # imm = 0xFFFE000000000000
callq 0x7b610
movq -0x60(%rbp), %rdi
movq %rax, -0x40(%rbp)
movl -0x14(%rbp), %edx
addl $0x1, %edx
movq -0x40(%rbp), %rsi
callq 0x40840
movq -0x28(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x4457c
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rsi
movl -0x14(%rbp), %edx
addl $0x1, %edx
callq 0x440c0
movl -0x1c(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x445b4
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x44(%rbp), %rcx
movl -0x14(%rbp), %edx
addl $0x1, %edx
movq (%rax,%rcx,8), %rsi
callq 0x40840
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x44582
movl -0x1c(%rbp), %eax
subl $0x4, %eax
movl %eax, -0x20(%rbp)
movq -0x28(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x1c(%rbp)
jmp 0x44461
movq -0x10(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x4460d
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movabsq $-0x3800000000000, %rsi # imm = 0xFFFC800000000000
callq 0x7b610
movq -0x68(%rbp), %rdi
movq %rax, -0x50(%rbp)
movl -0x14(%rbp), %edx
addl $0x1, %edx
movq -0x50(%rbp), %rsi
callq 0x40840
movq -0x10(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x4464e
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
movabsq $-0x6800000000000, %rsi # imm = 0xFFF9800000000000
callq 0x7b610
movq -0x70(%rbp), %rdi
movq %rax, -0x58(%rbp)
movl -0x14(%rbp), %edx
addl $0x1, %edx
movq -0x58(%rbp), %rsi
callq 0x40840
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %edx
addl $0x1, %edx
movq 0x40(%rax), %rsi
callq 0x40840
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)