// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/marsh.c
// Function: marshal_one_env
static void marshal_one_env(MarshalState *st, JanetFuncEnv *env, int flags) {
    MARSH_STACKCHECK;
    for (int32_t i = 0; i < janet_v_count(st->seen_envs); i++) {
        if (st->seen_envs[i] == env) {
            pushbyte(st, LB_FUNCENV_REF);
            pushint(st, i);
            return;
        }
    }
    janet_env_valid(env);
    janet_v_push(st->seen_envs, env);

    /* Special case for early detachment */
    if (env->offset > 0 && fiber_cannot_be_marshalled(env->as.fiber)) {
        pushint(st, 0);
        pushint(st, env->length);
        Janet *values = env->as.fiber->data + env->offset;
        uint32_t *bitset = janet_stack_frame(values)->func->def->closure_bitset;
        for (int32_t i = 0; i < env->length; i++) {
            if (1 & (bitset[i >> 5] >> (i & 0x1F))) {
                marshal_one(st, values[i], flags + 1);
            } else {
                pushbyte(st, LB_NIL);
            }
        }
    } else {
        janet_env_maybe_detach(env);
        pushint(st, env->offset);
        pushint(st, env->length);
        if (env->offset > 0) {
            /* On stack variant */
            marshal_one(st, janet_wrap_fiber(env->as.fiber), flags + 1);
        } else {
            /* Off stack variant */
            for (int32_t i = 0; i < env->length; i++)
                marshal_one(st, env->as.values[i], flags + 1);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %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 0x440ee
leaq 0x45e2a(%rip), %rdi     # 0x89f13
callq 0x1ad60
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x40(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x44116
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movl -0x4(%rax), %eax
movl %eax, -0x44(%rbp)
jmp 0x4411d
xorl %eax, %eax
movl %eax, -0x44(%rbp)
jmp 0x4411d
movl -0x40(%rbp), %eax
movl -0x44(%rbp), %ecx
cmpl %ecx, %eax
jge 0x44169
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq -0x10(%rbp), %rax
jne 0x4415c
movq -0x8(%rbp), %rdi
movl $0xdb, %esi
callq 0x40750
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x405d0
jmp 0x44372
jmp 0x4415e
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x440f5
movq -0x10(%rbp), %rdi
callq 0x368b0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x44198
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movl -0x4(%rax), %eax
addl $0x1, %eax
movq -0x8(%rbp), %rcx
movq 0x40(%rcx), %rcx
cmpl -0x8(%rcx), %eax
jl 0x441bc
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rdi
movl $0x1, %esi
movl $0x8, %edx
callq 0x70760
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x40(%rax)
jmp 0x441be
jmp 0x441be
movq -0x10(%rbp), %rdx
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x40(%rcx), %rsi
movl -0x4(%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, -0x4(%rsi)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
jle 0x442c6
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x44730
cmpl $0x0, %eax
je 0x442c6
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x405d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x18(%rax), %esi
callq 0x405d0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x30(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x1c(%rcx), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x20(%rax), %rax
movq 0x10(%rax), %rax
movq 0x30(%rax), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jge 0x442c1
movq -0x28(%rbp), %rax
movl -0x2c(%rbp), %ecx
sarl $0x5, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl -0x2c(%rbp), %ecx
andl $0x1f, %ecx
shrl %cl, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x442a6
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl -0x14(%rbp), %edx
addl $0x1, %edx
movq (%rax,%rcx,8), %rsi
callq 0x40840
jmp 0x442b4
movq -0x8(%rbp), %rdi
movl $0xc9, %esi
callq 0x40750
jmp 0x442b6
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x4425d
jmp 0x44372
movq -0x10(%rbp), %rdi
callq 0x369a0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %esi
callq 0x405d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x18(%rax), %esi
callq 0x405d0
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
jle 0x44331
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movabsq $-0x6800000000000, %rsi # imm = 0xFFF9800000000000
callq 0x7b610
movq -0x50(%rbp), %rdi
movq %rax, -0x38(%rbp)
movl -0x14(%rbp), %edx
addl $0x1, %edx
movq -0x38(%rbp), %rsi
callq 0x40840
jmp 0x44370
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jge 0x4436e
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
movl -0x14(%rbp), %edx
addl $0x1, %edx
movq (%rax,%rcx,8), %rsi
callq 0x40840
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x44338
jmp 0x44370
jmp 0x44372
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)