// File: /workspace/github_c_makefile_star2_O1/janet-lang[P]janet/src/core/marsh.c
// Function: unmarshal_one_def
static const uint8_t *unmarshal_one_def(
    UnmarshalState *st,
    const uint8_t *data,
    JanetFuncDef **out,
    int flags) {
    MARSH_EOS(st, data);
    if (*data == LB_FUNCDEF_REF) {
        data++;
        int32_t index = readint(st, &data);
        if (index < 0 || index >= janet_v_count(st->lookup_defs))
            janet_panicf("invalid funcdef reference %d", index);
        *out = st->lookup_defs[index];
    } else {
        /* Initialize with values that will not break garbage collection
         * if unmarshalling fails. */
        JanetFuncDef *def = janet_gcalloc(JANET_MEMORY_FUNCDEF, sizeof(JanetFuncDef));
        def->environments_length = 0;
        def->defs_length = 0;
        def->constants_length = 0;
        def->bytecode_length = 0;
        def->name = NULL;
        def->source = NULL;
        def->closure_bitset = NULL;
        def->defs = NULL;
        def->environments = NULL;
        def->constants = NULL;
        def->bytecode = NULL;
        def->sourcemap = NULL;
        def->symbolmap = NULL;
        def->symbolmap_length = 0;
        janet_v_push(st->lookup_defs, def);

        /* Set default lengths to zero */
        int32_t bytecode_length = 0;
        int32_t constants_length = 0;
        int32_t environments_length = 0;
        int32_t defs_length = 0;
        int32_t symbolmap_length = 0;

        /* Read flags and other fixed values */
        def->flags = readint(st, &data);
        def->slotcount = readnat(st, &data);
        def->arity = readnat(st, &data);
        def->min_arity = readnat(st, &data);
        def->max_arity = readnat(st, &data);

        /* Read some lengths */
        constants_length = readnat(st, &data);
        bytecode_length = readnat(st, &data);
        if (def->flags & JANET_FUNCDEF_FLAG_HASENVS)
            environments_length = readnat(st, &data);
        if (def->flags & JANET_FUNCDEF_FLAG_HASDEFS)
            defs_length = readnat(st, &data);
        if (def->flags & JANET_FUNCDEF_FLAG_HASSYMBOLMAP)
            symbolmap_length = readnat(st, &data);

        /* Check name and source (optional) */
        if (def->flags & JANET_FUNCDEF_FLAG_HASNAME) {
            Janet x;
            data = unmarshal_one(st, data, &x, flags + 1);
            janet_asserttype(x, JANET_STRING, st);
            def->name = janet_unwrap_string(x);
        }
        if (def->flags & JANET_FUNCDEF_FLAG_HASSOURCE) {
            Janet x;
            data = unmarshal_one(st, data, &x, flags + 1);
            janet_asserttype(x, JANET_STRING, st);
            def->source = janet_unwrap_string(x);
        }

        /* Unmarshal constants */
        if (constants_length) {
            def->constants = janet_malloc(sizeof(Janet) * constants_length);
            if (!def->constants) {
                JANET_OUT_OF_MEMORY;
            }
            for (int32_t i = 0; i < constants_length; i++)
                data = unmarshal_one(st, data, def->constants + i, flags + 1);
        } else {
            def->constants = NULL;
        }
        def->constants_length = constants_length;

        /* Unmarshal symbol map, if needed */
        if (def->flags & JANET_FUNCDEF_FLAG_HASSYMBOLMAP) {
            size_t size = sizeof(JanetSymbolMap) * symbolmap_length;
            def->symbolmap = janet_malloc(size);
            if (def->symbolmap == NULL) {
                JANET_OUT_OF_MEMORY;
            }
            for (int32_t i = 0; i < symbolmap_length; i++) {
                def->symbolmap[i].birth_pc = (uint32_t) readint(st, &data);
                def->symbolmap[i].death_pc = (uint32_t) readint(st, &data);
                def->symbolmap[i].slot_index = (uint32_t) readint(st, &data);
                Janet value;
                data = unmarshal_one(st, data, &value, flags + 1);
                if (!janet_checktype(value, JANET_SYMBOL)) {
                    janet_panicf("corrupted symbolmap when unmarshalling debug info, got %v", value);
                }
                def->symbolmap[i].symbol = janet_unwrap_symbol(value);
            }
            def->symbolmap_length = (uint32_t) symbolmap_length;
        }

        /* Unmarshal bytecode */
        def->bytecode = janet_malloc(sizeof(uint32_t) * bytecode_length);
        if (!def->bytecode) {
            JANET_OUT_OF_MEMORY;
        }
        data = janet_unmarshal_u32s(st, data, def->bytecode, bytecode_length);
        def->bytecode_length = bytecode_length;

        /* Unmarshal environments */
        if (def->flags & JANET_FUNCDEF_FLAG_HASENVS) {
            def->environments = janet_calloc(1, sizeof(int32_t) * (size_t) environments_length);
            if (!def->environments) {
                JANET_OUT_OF_MEMORY;
            }
            for (int32_t i = 0; i < environments_length; i++) {
                def->environments[i] = readint(st, &data);
            }
        } else {
            def->environments = NULL;
        }
        def->environments_length = environments_length;

        /* Unmarshal sub funcdefs */
        if (def->flags & JANET_FUNCDEF_FLAG_HASDEFS) {
            def->defs = janet_calloc(1, sizeof(JanetFuncDef *) * (size_t) defs_length);
            if (!def->defs) {
                JANET_OUT_OF_MEMORY;
            }
            for (int32_t i = 0; i < defs_length; i++) {
                data = unmarshal_one_def(st, data, def->defs + i, flags + 1);
            }
        } else {
            def->defs = NULL;
        }
        def->defs_length = defs_length;

        /* Unmarshal source maps if needed */
        if (def->flags & JANET_FUNCDEF_FLAG_HASSOURCEMAP) {
            int32_t current = 0;
            def->sourcemap = janet_malloc(sizeof(JanetSourceMapping) * (size_t) bytecode_length);
            if (!def->sourcemap) {
                JANET_OUT_OF_MEMORY;
            }
            for (int32_t i = 0; i < bytecode_length; i++) {
                current += readint(st, &data);
                def->sourcemap[i].line = current;
                def->sourcemap[i].column = readint(st, &data);
            }
        } else {
            def->sourcemap = NULL;
        }

        /* Unmarshal closure bitset if needed */
        if (def->flags & JANET_FUNCDEF_FLAG_HASCLOBITSET) {
            int32_t n = (def->slotcount + 31) >> 5;
            def->closure_bitset = janet_malloc(sizeof(uint32_t) * (size_t) n);
            if (NULL == def->closure_bitset) {
                JANET_OUT_OF_MEMORY;
            }
            data = janet_unmarshal_u32s(st, data, def->closure_bitset, n);
        }

        /* Validate */
        if (janet_verify(def))
            janet_panic("funcdef has invalid bytecode");

        /* Set def */
        *out = def;
    }
    return data;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, -0x30(%rbp)
movq %rdi, -0x38(%rbp)
cmpq %rsi, 0xf0(%rdi)
jbe 0x32c03
movq %rdx, %rbx
cmpb $-0x24, (%rsi)
jne 0x32674
incq %rsi
leaq -0x30(%rbp), %rax
movq %rsi, (%rax)
movq -0x38(%rbp), %rdi
movq %rax, %rsi
callq 0x30618
testl %eax, %eax
js 0x32c0f
movq -0x38(%rbp), %rcx
movq 0xe0(%rcx), %rcx
testq %rcx, %rcx
je 0x32bd3
movl -0x4(%rcx), %edx
jmp 0x32bd5
movl %ecx, %r13d
movq %rbx, -0x70(%rbp)
movl $0x80, %esi
movl $0xc, %edi
callq 0x2bb18
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x40(%rax)
movq $0x0, 0x50(%rax)
movups %xmm0, 0x6c(%rax)
movl $0x0, 0x7c(%rax)
movq -0x38(%rbp), %rax
movq 0xe0(%rax), %rdi
testq %rdi, %rdi
je 0x326cd
movl -0x4(%rdi), %eax
incl %eax
cmpl -0x8(%rdi), %eax
jl 0x326e7
movl $0x1, %esi
movl $0x8, %edx
callq 0x4c0b4
movq -0x38(%rbp), %rcx
movq %rax, 0xe0(%rcx)
movq -0x38(%rbp), %r14
movq 0xe0(%r14), %rax
movslq -0x4(%rax), %rcx
leal 0x1(%rcx), %edx
movl %edx, -0x4(%rax)
movq %r15, (%rax,%rcx,8)
leaq -0x30(%rbp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x30618
movl %eax, 0x58(%r15)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x320ce
movl %eax, 0x5c(%r15)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x320ce
movl %eax, 0x60(%r15)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x320ce
movl %eax, 0x64(%r15)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x320ce
movl %eax, 0x68(%r15)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x320ce
movl %eax, -0x48(%rbp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x320ce
movl %eax, %r12d
movl $0x0, -0x3c(%rbp)
testb $0x40, 0x5a(%r15)
movl $0x0, %eax
je 0x3278b
leaq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdi
callq 0x320ce
movl %eax, -0x54(%rbp)
testb $0x20, 0x5a(%r15)
je 0x327a5
leaq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdi
callq 0x320ce
movl %eax, -0x3c(%rbp)
movl $0x0, -0x4c(%rbp)
testb $0x4, 0x5a(%r15)
je 0x327c3
leaq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdi
callq 0x320ce
movl %eax, -0x4c(%rbp)
testb $0x8, 0x5a(%r15)
je 0x32818
movq -0x30(%rbp), %rsi
leal 0x1(%r13), %ecx
leaq -0x60(%rbp), %rbx
movq -0x38(%rbp), %rdi
movq %rbx, %rdx
callq 0x30822
movq %rax, -0x30(%rbp)
movq (%rbx), %rdx
movq %rdx, %rax
movabsq $-0x800000000000, %rcx  # imm = 0xFFFF800000000000
andq %rcx, %rax
movabsq $-0x6000000000000, %rcx # imm = 0xFFFA000000000000
cmpq %rcx, %rax
jne 0x32c1f
movq %rdx, %rdi
callq 0x4f838
movq %rax, 0x48(%r15)
testb $0x10, 0x5a(%r15)
je 0x3286d
movq -0x30(%rbp), %rsi
leal 0x1(%r13), %ecx
leaq -0x60(%rbp), %rbx
movq -0x38(%rbp), %rdi
movq %rbx, %rdx
callq 0x30822
movq %rax, -0x30(%rbp)
movq (%rbx), %rdx
movq %rdx, %rax
movabsq $-0x800000000000, %rcx  # imm = 0xFFFF800000000000
andq %rcx, %rax
movabsq $-0x6000000000000, %rcx # imm = 0xFFFA000000000000
cmpq %rcx, %rax
jne 0x32c1f
movq %rdx, %rdi
callq 0x4f838
movq %rax, 0x40(%r15)
movl -0x48(%rbp), %eax
testl %eax, %eax
movq %r13, -0x68(%rbp)
movl %r12d, -0x50(%rbp)
je 0x328d3
movl %eax, %r12d
leaq (,%r12,8), %rdi
callq 0x12770
movq %rax, 0x18(%r15)
testq %rax, %rax
je 0x32c37
leal 0x1(%r13), %ebx
movq -0x30(%rbp), %rax
shlq $0x3, %r12
xorl %r13d, %r13d
movq 0x18(%r15), %rdx
addq %r13, %rdx
movq -0x38(%rbp), %rdi
movq %rax, %rsi
movl %ebx, %ecx
callq 0x30822
addq $0x8, %r13
cmpq %r13, %r12
jne 0x328a8
movq %rax, -0x30(%rbp)
movl -0x50(%rbp), %r12d
movl -0x48(%rbp), %eax
jmp 0x328db
movq $0x0, 0x18(%r15)
movl %eax, 0x6c(%r15)
testb $0x4, 0x5a(%r15)
je 0x329d6
movl -0x4c(%rbp), %r12d
movl %r12d, %ebx
leaq (,%rbx,8), %rax
leaq (%rax,%rax,2), %rdi
callq 0x12770
movq %rax, 0x50(%r15)
testq %rax, %rax
je 0x32c3c
testl %r12d, %r12d
je 0x329cb
movq -0x68(%rbp), %rax
incl %eax
movl %eax, -0x48(%rbp)
shlq $0x3, %rbx
leaq (%rbx,%rbx,2), %r12
xorl %r13d, %r13d
leaq -0x30(%rbp), %rbx
movq -0x38(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x30618
movq 0x50(%r15), %rcx
movl %eax, (%rcx,%r13)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x30618
movq 0x50(%r15), %rcx
movl %eax, 0x4(%rcx,%r13)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x30618
movq 0x50(%r15), %rcx
movl %eax, 0x8(%rcx,%r13)
movq -0x30(%rbp), %rsi
movq %r14, %rdi
leaq -0x60(%rbp), %rdx
movl -0x48(%rbp), %ecx
callq 0x30822
movq %rax, -0x30(%rbp)
movq -0x60(%rbp), %rsi
movq %rsi, %rax
movabsq $-0x800000000000, %rcx  # imm = 0xFFFF800000000000
andq %rcx, %rax
movabsq $-0x5800000000000, %rcx # imm = 0xFFFA800000000000
cmpq %rcx, %rax
jne 0x32bf5
movq %rsi, %rdi
callq 0x4f838
movq 0x50(%r15), %rcx
movq %rax, 0x10(%rcx,%r13)
addq $0x18, %r13
cmpq %r13, %r12
jne 0x32934
movl -0x4c(%rbp), %eax
movl %eax, 0x7c(%r15)
movl -0x50(%rbp), %r12d
movl %r12d, %ebx
leaq (,%rbx,4), %rdi
callq 0x12770
movq %rax, 0x28(%r15)
testq %rax, %rax
je 0x32c32
movq %rbx, -0x48(%rbp)
movq %r15, %r13
addq $0x10, %r13
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdi
movq %rax, %rdx
movl %r12d, %ecx
callq 0x32f19
movq %rax, -0x30(%rbp)
movl %r12d, 0x70(%r15)
testb $0x40, 0x5a(%r15)
jne 0x32a2a
movq $0x0, (%r13)
jmp 0x32a74
movl -0x54(%rbp), %ebx
movl %ebx, %r12d
leaq (,%r12,4), %rsi
movl $0x1, %edi
callq 0x125a0
movq %rax, (%r13)
testq %rax, %rax
je 0x32c41
testl %ebx, %ebx
je 0x32a74
xorl %ebx, %ebx
leaq -0x30(%rbp), %r14
movq -0x38(%rbp), %rdi
movq %r14, %rsi
callq 0x30618
movq (%r13), %rcx
movl %eax, (%rcx,%rbx,4)
incq %rbx
cmpq %rbx, %r12
jne 0x32a59
movl -0x54(%rbp), %eax
movl %eax, 0x74(%r15)
testb $0x20, 0x5a(%r15)
jne 0x32a8c
movq $0x0, 0x20(%r15)
jmp 0x32aec
movl -0x3c(%rbp), %r12d
movl %r12d, %ebx
leaq (,%rbx,8), %rsi
movl $0x1, %edi
callq 0x125a0
movq %rax, 0x20(%r15)
testq %rax, %rax
je 0x32c46
movq -0x30(%rbp), %rax
testl %r12d, %r12d
movq -0x68(%rbp), %r13
je 0x32ae8
incl %r13d
shlq $0x3, %rbx
xorl %r12d, %r12d
movq 0x20(%r15), %rdx
addq %r12, %rdx
movq -0x38(%rbp), %rdi
movq %rax, %rsi
movl %r13d, %ecx
callq 0x3260c
addq $0x8, %r12
cmpq %r12, %rbx
jne 0x32ac9
movq %rax, -0x30(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, 0x78(%r15)
testb $-0x80, 0x5a(%r15)
movl -0x50(%rbp), %ebx
jne 0x32b07
movq $0x0, 0x38(%r15)
jmp 0x32b77
movq -0x48(%rbp), %rax
leaq (,%rax,8), %rdi
callq 0x12770
movq %rax, 0x38(%r15)
testq %rax, %rax
je 0x32c4b
testl %ebx, %ebx
movq -0x48(%rbp), %rax
je 0x32b77
xorl %r12d, %r12d
xorl %r13d, %r13d
movq -0x38(%rbp), %rdi
movq %r15, %rbx
movq %rdi, %r15
leaq -0x30(%rbp), %rsi
movq %rax, %r14
callq 0x30618
addl %eax, %r13d
movq 0x38(%rbx), %rax
movl %r13d, (%rax,%r12,8)
movq %r15, %rdi
leaq -0x30(%rbp), %rsi
movq %rbx, %r15
callq 0x30618
movq 0x38(%rbx), %rcx
movl %eax, 0x4(%rcx,%r12,8)
movq %r14, %rax
incq %r12
cmpq %r12, %r14
jne 0x32b33
testb $0x2, 0x5b(%r15)
je 0x32bb7
movl 0x5c(%r15), %ebx
addl $0x1f, %ebx
sarl $0x5, %ebx
movslq %ebx, %rdi
shlq $0x2, %rdi
callq 0x12770
movq %rax, 0x30(%r15)
testq %rax, %rax
je 0x32c50
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdi
movq %rax, %rdx
movl %ebx, %ecx
callq 0x32f19
movq %rax, -0x30(%rbp)
movq %r15, %rdi
callq 0x18ddf
testl %eax, %eax
movq -0x70(%rbp), %rbx
je 0x32bdf
leaq 0x2e37d(%rip), %rdi     # 0x60f4b
callq 0x19263
xorl %edx, %edx
cmpl %edx, %eax
jge 0x32c0f
movl %eax, %eax
movq (%rcx,%rax,8), %r15
movq %r15, (%rbx)
movq -0x30(%rbp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2e315(%rip), %rdi     # 0x60f11
xorl %eax, %eax
callq 0x1917b
leaq 0x2df82(%rip), %rdi     # 0x60b8c
callq 0x19263
leaq 0x2e2de(%rip), %rdi     # 0x60ef4
movl %eax, %esi
xorl %eax, %eax
callq 0x1917b
leaq 0x2e3fc(%rip), %rdi     # 0x61022
movl $0x10, %esi
xorl %eax, %eax
callq 0x1917b
callq 0x13bcc
callq 0x13aac
callq 0x13adc
callq 0x13b0c
callq 0x13b3c
callq 0x13b6c
callq 0x13b9c