// File: /workspace/github_c_makefile_star2_O2/janet-lang[P]janet/src/core/marsh.c
// Function: unmarshal_one_env
static const uint8_t *unmarshal_one_env(
    UnmarshalState *st,
    const uint8_t *data,
    JanetFuncEnv **out,
    int flags) {
    MARSH_EOS(st, data);
    if (*data == LB_FUNCENV_REF) {
        data++;
        int32_t index = readint(st, &data);
        if (index < 0 || index >= janet_v_count(st->lookup_envs))
            janet_panicf("invalid funcenv reference %d", index);
        *out = st->lookup_envs[index];
    } else {
        JanetFuncEnv *env = janet_gcalloc(JANET_MEMORY_FUNCENV, sizeof(JanetFuncEnv));
        env->length = 0;
        env->offset = 0;
        env->as.values = NULL;
        janet_v_push(st->lookup_envs, env);
        int32_t offset = readnat(st, &data);
        int32_t length = readnat(st, &data);
        if (offset > 0) {
            Janet fiberv;
            /* On stack variant */
            data = unmarshal_one(st, data, &fiberv, flags);
            janet_asserttype(fiberv, JANET_FIBER, st);
            env->as.fiber = janet_unwrap_fiber(fiberv);
            /* Negative offset indicates untrusted input */
            env->offset = -offset;
        } else {
            /* Off stack variant */
            if (length == 0) {
                janet_panic("invalid funcenv length");
            }
            env->as.values = janet_malloc(sizeof(Janet) * (size_t) length);
            if (!env->as.values) {
                JANET_OUT_OF_MEMORY;
            }
            env->offset = 0;
            for (int32_t i = 0; i < length; i++)
                data = unmarshal_one(st, data, env->as.values + i, flags);
        }
        env->length = length;
        *out = env;
    }
    return data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, -0x34(%rbp)
movq %rsi, -0x30(%rbp)
cmpq %rsi, 0xf0(%rdi)
jbe 0x2fe73
movq %rdx, %r14
movq %rdi, %r15
cmpb $-0x25, (%rsi)
jne 0x2fd29
incq %rsi
leaq -0x30(%rbp), %rax
movq %rsi, (%rax)
movq %r15, %rdi
movq %rax, %rsi
callq 0x2da62
testl %eax, %eax
js 0x2fe63
movq 0xd8(%r15), %rcx
testq %rcx, %rcx
je 0x2fe63
cmpl -0x4(%rcx), %eax
jge 0x2fe63
movl %eax, %eax
movq (%rcx,%rax,8), %r12
movq -0x30(%rbp), %rbx
jmp 0x2fe4e
pushq $0xb
popq %rdi
pushq $0x20
popq %rsi
callq 0x291a0
movq %rax, %r12
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movq 0xd8(%r15), %rax
testq %rax, %rax
je 0x2fd55
movl -0x4(%rax), %ecx
leal 0x1(%rcx), %edx
cmpl -0x8(%rax), %edx
jl 0x2fd70
pushq $0x1
popq %rsi
pushq $0x8
popq %rdx
movq %rax, %rdi
callq 0x4799c
movq %rax, 0xd8(%r15)
movl -0x4(%rax), %ecx
leal 0x1(%rcx), %edx
movl %edx, -0x4(%rax)
movslq %ecx, %rcx
movq %r12, (%rax,%rcx,8)
leaq -0x30(%rbp), %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2f64c
movl %eax, %r13d
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2f64c
testl %r13d, %r13d
movl %eax, -0x38(%rbp)
je 0x2fddd
movq -0x30(%rbp), %rsi
leaq -0x50(%rbp), %rdx
movq %r15, %rdi
movq %rdx, %r15
movl -0x34(%rbp), %ecx
callq 0x2dc5b
movq %rax, %rbx
movq (%r15), %r15
pushq $0x3
popq %rsi
movq %r15, %rdi
callq 0x2feb7
movq %r15, %rdi
callq 0x4b1f1
movq %rax, 0x10(%r12)
negl %r13d
movl %r13d, 0x1c(%r12)
jmp 0x2fe46
testl %eax, %eax
je 0x2fe7f
movq %r14, -0x48(%rbp)
movq %r12, %r14
addq $0x10, %r14
movl %eax, %r13d
shlq $0x3, %r13
movq %r13, %rdi
callq 0x12760
movq %rax, (%r14)
testq %rax, %rax
je 0x2fe8b
movq %r12, -0x40(%rbp)
andl $0x0, 0x1c(%r12)
movq -0x30(%rbp), %rbx
xorl %r12d, %r12d
cmpq %r12, %r13
je 0x2fe3e
movq (%r14), %rdx
addq %r12, %rdx
movq %r15, %rdi
movq %rbx, %rsi
movl -0x34(%rbp), %ecx
callq 0x2dc5b
movq %rax, %rbx
addq $0x8, %r12
jmp 0x2fe1c
movq -0x48(%rbp), %r14
movq -0x40(%rbp), %r12
movl -0x38(%rbp), %eax
movl %eax, 0x18(%r12)
movq %r12, (%r14)
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2c0fe(%rip), %rdi     # 0x5bf68
movl %eax, %esi
xorl %eax, %eax
callq 0x176c9
leaq 0x2bd12(%rip), %rdi     # 0x5bb8c
callq 0x177b1
leaq 0x2c0ff(%rip), %rdi     # 0x5bf85
callq 0x177b1
movq 0x5015e(%rip), %rax     # 0x7fff0
movq (%rax), %rdi
leaq 0x1d168(%rip), %rsi     # 0x4d004
leaq 0x2bd7d(%rip), %rdx     # 0x5bc20
movl $0x35c, %ecx            # imm = 0x35C
xorl %eax, %eax
callq 0x125e0
pushq $0x1
popq %rdi
callq 0x12a60