// File: /workspace/github_c_makefile_star2_O2/janet-lang[P]janet/src/core/marsh.c
// Function: marshal_one_def
static void marshal_one_def(MarshalState *st, JanetFuncDef *def, int flags) {
    MARSH_STACKCHECK;
    for (int32_t i = 0; i < janet_v_count(st->seen_defs); i++) {
        if (st->seen_defs[i] == def) {
            pushbyte(st, LB_FUNCDEF_REF);
            pushint(st, i);
            return;
        }
    }
    /* Add to lookup */
    janet_v_push(st->seen_defs, def);

    pushint(st, def->flags);
    pushint(st, def->slotcount);
    pushint(st, def->arity);
    pushint(st, def->min_arity);
    pushint(st, def->max_arity);
    pushint(st, def->constants_length);
    pushint(st, def->bytecode_length);
    if (def->flags & JANET_FUNCDEF_FLAG_HASENVS)
        pushint(st, def->environments_length);
    if (def->flags & JANET_FUNCDEF_FLAG_HASDEFS)
        pushint(st, def->defs_length);
    if (def->flags & JANET_FUNCDEF_FLAG_HASSYMBOLMAP)
        pushint(st, def->symbolmap_length);
    if (def->flags & JANET_FUNCDEF_FLAG_HASNAME)
        marshal_one(st, janet_wrap_string(def->name), flags);
    if (def->flags & JANET_FUNCDEF_FLAG_HASSOURCE)
        marshal_one(st, janet_wrap_string(def->source), flags);

    /* marshal constants */
    for (int32_t i = 0; i < def->constants_length; i++)
        marshal_one(st, def->constants[i], flags + 1);

    /* Marshal symbol map, if needed */
    for (int32_t i = 0; i < def->symbolmap_length; i++) {
        pushint(st, (int32_t) def->symbolmap[i].birth_pc);
        pushint(st, (int32_t) def->symbolmap[i].death_pc);
        pushint(st, (int32_t) def->symbolmap[i].slot_index);
        marshal_one(st, janet_wrap_symbol(def->symbolmap[i].symbol), flags + 1);
    }

    /* marshal the bytecode */
    janet_marshal_u32s(st, def->bytecode, def->bytecode_length);

    /* marshal the environments if needed */
    for (int32_t i = 0; i < def->environments_length; i++)
        pushint(st, def->environments[i]);

    /* marshal the sub funcdefs if needed */
    for (int32_t i = 0; i < def->defs_length; i++)
        marshal_one_def(st, def->defs[i], flags + 1);

    /* marshal source maps if needed */
    if (def->flags & JANET_FUNCDEF_FLAG_HASSOURCEMAP) {
        int32_t current = 0;
        for (int32_t i = 0; i < def->bytecode_length; i++) {
            JanetSourceMapping map = def->sourcemap[i];
            pushint(st, map.line - current);
            pushint(st, map.column);
            current = map.line;
        }
    }

    /* Marshal closure bitset, if needed */
    if (def->flags & JANET_FUNCDEF_FLAG_HASCLOBITSET) {
        janet_marshal_u32s(st, def->closure_bitset, ((def->slotcount + 31) >> 5));
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r15d
movzwl %r15w, %eax
cmpl $0x400, %eax            # imm = 0x400
ja 0x2f3d5
movq %rsi, %r14
movq %rdi, %rbx
movq 0x48(%rdi), %rax
xorl %r12d, %r12d
testq %rax, %rax
je 0x2f137
movslq -0x4(%rax), %rcx
cmpq %rcx, %r12
jge 0x2f12c
cmpq %r14, (%rax,%r12,8)
je 0x2f3af
incq %r12
jmp 0x2f10f
movl -0x4(%rax), %ecx
leal 0x1(%rcx), %edx
cmpl -0x8(%rax), %edx
jl 0x2f14f
pushq $0x1
popq %rsi
pushq $0x8
popq %rdx
movq %rax, %rdi
callq 0x4799c
movq %rax, 0x48(%rbx)
movl -0x4(%rax), %ecx
leal 0x1(%rcx), %edx
movl %edx, -0x4(%rax)
movslq %ecx, %rcx
movq %r14, (%rax,%rcx,8)
movl 0x58(%r14), %esi
movq %rbx, %rdi
callq 0x2ccd8
movl 0x5c(%r14), %esi
movq %rbx, %rdi
callq 0x2ccd8
movl 0x60(%r14), %esi
movq %rbx, %rdi
callq 0x2ccd8
movl 0x64(%r14), %esi
movq %rbx, %rdi
callq 0x2ccd8
movl 0x68(%r14), %esi
movq %rbx, %rdi
callq 0x2ccd8
movl 0x6c(%r14), %esi
movq %rbx, %rdi
callq 0x2ccd8
movl 0x70(%r14), %esi
movq %rbx, %rdi
callq 0x2ccd8
movl 0x58(%r14), %eax
btl $0x16, %eax
jae 0x2f1c7
movl 0x74(%r14), %esi
movq %rbx, %rdi
callq 0x2ccd8
movl 0x58(%r14), %eax
btl $0x15, %eax
jae 0x2f1dd
movl 0x78(%r14), %esi
movq %rbx, %rdi
callq 0x2ccd8
movl 0x58(%r14), %eax
btl $0x12, %eax
jae 0x2f1f3
movl 0x7c(%r14), %esi
movq %rbx, %rdi
callq 0x2ccd8
movl 0x58(%r14), %eax
movabsq $-0x6000000000000, %r12 # imm = 0xFFFA000000000000
btl $0x13, %eax
jae 0x2f221
movq 0x48(%r14), %rdi
movq %r12, %rsi
callq 0x4b366
movq %rbx, %rdi
movq %rax, %rsi
movl %r15d, %edx
callq 0x2cddb
movl 0x58(%r14), %eax
btl $0x14, %eax
jae 0x2f241
movq 0x40(%r14), %rdi
movq %r12, %rsi
callq 0x4b366
movq %rbx, %rdi
movq %rax, %rsi
movl %r15d, %edx
callq 0x2cddb
incl %r15d
xorl %r12d, %r12d
movslq 0x6c(%r14), %rax
cmpq %rax, %r12
jge 0x2f268
movq 0x18(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %rbx, %rdi
movl %r15d, %edx
callq 0x2cddb
incq %r12
jmp 0x2f247
xorl %r13d, %r13d
xorl %r12d, %r12d
movslq 0x7c(%r14), %rax
cmpq %rax, %r12
jge 0x2f2d8
movq 0x50(%r14), %rax
movl (%rax,%r13), %esi
movq %rbx, %rdi
callq 0x2ccd8
movq 0x50(%r14), %rax
movl 0x4(%rax,%r13), %esi
movq %rbx, %rdi
callq 0x2ccd8
movq 0x50(%r14), %rax
movl 0x8(%rax,%r13), %esi
movq %rbx, %rdi
callq 0x2ccd8
movq 0x50(%r14), %rax
movq 0x10(%rax,%r13), %rdi
movabsq $-0x5800000000000, %rsi # imm = 0xFFFA800000000000
callq 0x4b366
movq %rbx, %rdi
movq %rax, %rsi
movl %r15d, %edx
callq 0x2cddb
incq %r12
addq $0x18, %r13
jmp 0x2f26e
movq 0x28(%r14), %rsi
movl 0x70(%r14), %edx
movq %rbx, %rdi
callq 0x2f5e6
xorl %r12d, %r12d
movslq 0x74(%r14), %rax
cmpq %rax, %r12
jge 0x2f309
movq 0x10(%r14), %rax
movl (%rax,%r12,4), %esi
movq %rbx, %rdi
callq 0x2ccd8
incq %r12
jmp 0x2f2eb
xorl %r12d, %r12d
movslq 0x78(%r14), %rax
cmpq %rax, %r12
jge 0x2f32d
movq 0x20(%r14), %rax
movq (%rax,%r12,8), %rsi
movq %rbx, %rdi
movl %r15d, %edx
callq 0x2f0e2
incq %r12
jmp 0x2f30c
movl 0x58(%r14), %eax
btl $0x17, %eax
jae 0x2f376
xorl %r12d, %r12d
xorl %eax, %eax
movslq 0x70(%r14), %rcx
cmpq %rcx, %r12
jge 0x2f372
movq 0x38(%r14), %rcx
movl (%rcx,%r12,8), %r13d
movl 0x4(%rcx,%r12,8), %r15d
movl %r13d, %esi
subl %eax, %esi
movq %rbx, %rdi
callq 0x2ccd8
movq %rbx, %rdi
movl %r15d, %esi
callq 0x2ccd8
incq %r12
movl %r13d, %eax
jmp 0x2f33c
movl 0x58(%r14), %eax
btl $0x19, %eax
jb 0x2f38b
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x30(%r14), %rsi
movl 0x5c(%r14), %edx
addl $0x1f, %edx
sarl $0x5, %edx
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2f5e6
movq %rbx, %rdi
movl $0xdc, %esi
callq 0x2cd91
movq %rbx, %rdi
movl %r12d, %esi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2ccd8
leaq 0x29b17(%rip), %rdi     # 0x58ef3
callq 0x177b1