// File: /workspace/github_c_makefile_star2_O2/johsteffens[P]beth/lib/bcore/bcore.xo.c
// Function: x_bcml_t_translate_recursive
void x_bcml_t_translate_recursive( const x_bcml* o, tp_t t, bl_t push_existence, bl_t push_type, bl_t shelve, x_sink* sink )
{
    // bcore_x_bcml.h:391:1
    
    // shelving obj_l
    if( o && shelve && bcore_via_call_t_defines_shelve(t ) )
    {
        x_bcml* o_clone =((x_bcml*)( x_inst_t_clone(((const x_inst*)(o)),t ))); // no scoping (o_clone is obliv)
        x_stamp_t_shelve(((x_stamp*)(o_clone)),t );
        x_bcml_t_translate_recursive(o_clone,t, push_existence, push_type, false, sink );
        x_inst_discard(((x_inst*)(o_clone)));
        return ;
    }
    
    if( push_type )      x_bcml_push_type(sink, t );
    if( push_existence ) x_bcml_push_flag(sink, o != NULL );
    
    if( o )
    {
        if( x_bcml_t_defines_bcml_body_to_sink(t ) )
        {
            x_bcml_t_bcml_body_to_sink(o,t, sink );
        }
        else if( t == TYPEOF_st_s ) // strings
        {
            const st_s* string = ((const st_s*)(o));
            x_sink_push_data(sink,( vc_t )string->data, string->size + 1 ); // push string including terminating 0
        }
        else if( x_stamp_t_is_leaf(t ) )
        {
            x_bcml_push_leaf(sink, t,((const x_inst*)( o )));
        }
        else
        {
            if( x_stamp_t_is_pure_array(t ) )
            {
                const x_array* arr =((const x_array*)( o));
                if( x_array_t_is_mutable_mono_typed(t ) ) x_bcml_push_type(sink, x_array_t_get_mono_type(arr,t ) );
                sz_t size = x_array_t_size(arr,t );
                x_bcml_push_size(sink, size );
                bl_t is_of_links = x_array_t_is_of_links(t );
                tp_t static_type = x_array_t_get_static_type(t );
    
                if( ( !is_of_links ) && ( static_type != 0 ) && x_stamp_t_is_leaf(static_type ) )
                {
                    x_bcml_push_leaf_arr(sink, static_type, x_array_t_get_data_c(arr,t ), size );
                }
                else
                {
                    for(sz_t i = 0; i < size; i++ )
                    {
                        sr_s sr = x_array_t_c_get_sr(arr,t, i );
                        x_bcml_t_translate_recursive(((const x_bcml*)( sr.o)),sr_s_o_type(&(sr)), is_of_links, static_type == 0, true, sink );
                        sr_down( sr );
                    }
                }
            }
            else
            {
                const x_stamp* stamp =((const x_stamp*)( o));
                sz_t size = x_stamp_t_size(t );
                for(sz_t i = 0; i < size; i++ )
                {
                    sr_s sr = x_stamp_t_c_get_sr_i(stamp,t, i );
                    x_bcml_t_translate_recursive(((const x_bcml*)( sr.o)),sr_s_o_type(&(sr)), x_stamp_t_is_link_i(t, i ), !x_stamp_t_is_static_i(t, i ), true, sink );
                    sr_down( sr );
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, %rbx
movl %ecx, %r12d
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
xorb $0x1, %r8b
testq %rdi, %rdi
sete %al
orb %r8b, %al
jne 0x3881f
movq %r14, %rdi
callq 0x37093
testb %al, %al
je 0x3881f
movq %r14, %rdi
movq %r15, %rsi
callq 0x2de39
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x370b1
movzbl %bpl, %edx
movzbl %r12b, %ecx
movq %r15, %rdi
movq %r14, %rsi
xorl %r8d, %r8d
movq %rbx, %r9
callq 0x387a0
movq %r15, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5850d
testb %r12b, %r12b
je 0x3882f
movq %rbx, %rdi
movq %r14, %rsi
callq 0x39631
testb %bpl, %bpl
je 0x38845
xorl %esi, %esi
testq %r15, %r15
setne %sil
movq %rbx, %rdi
callq 0x39645
testq %r15, %r15
je 0x38ab2
movq %r14, %rdi
callq 0x58736
cmpq $0x0, 0x18(%rax)
je 0x3887f
movq %r14, %rdi
callq 0x58736
movq 0x18(%rax), %rax
movq %r15, %rdi
movq %rbx, %rsi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movabsq $-0x503db0e6e1c2e704, %rax # imm = 0xAFC24F191E3D18FC
cmpq %rax, %r14
jne 0x388af
movq 0x8(%r15), %rsi
movq 0x10(%r15), %rdx
incq %rdx
movq %rbx, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x345bc
movq %r14, %rdi
callq 0x36f05
testb %al, %al
je 0x388d7
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x39288
movq %r14, %rdi
callq 0x36f22
movq %r14, %rdi
testb %al, %al
je 0x38985
callq 0x36f27
testb %al, %al
je 0x38909
movq %r15, %rdi
movq %r14, %rsi
callq 0x36f9c
movq %rbx, %rdi
movq %rax, %rsi
callq 0x39631
movq %r15, %rdi
movq %r14, %rsi
callq 0x36fc4
movq %rbx, %rdi
movq %rax, 0x20(%rsp)
movq %rax, %rsi
callq 0x3965b
movq %r14, %rdi
callq 0x391df
movl %eax, %r12d
movq %r14, %rdi
callq 0x391ea
movq %rax, %r13
testq %rax, %rax
sete %al
orb %r12b, %al
jne 0x38a2e
movq %r13, %rdi
callq 0x36f05
testb %al, %al
je 0x38a2e
movq %r15, %rdi
movq %r14, %rsi
callq 0x3966f
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
movq 0x20(%rsp), %rcx
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x39434
callq 0x32e3b
xorl %r13d, %r13d
testq %rax, %rax
cmovleq %r13, %rax
movq %rax, 0x28(%rsp)
movq %rbx, 0x20(%rsp)
cmpq %r13, 0x28(%rsp)
je 0x38ab2
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %r13, %rcx
callq 0x2f9bc
movq 0x38(%rsp), %rax
testq %rax, %rax
je 0x389cc
movq 0x8(%rax), %rbp
jmp 0x389ce
xorl %ebp, %ebp
movq 0x30(%rsp), %r12
movq %r14, %rdi
movq %r13, %rsi
callq 0x39271
movl %eax, %ebx
movq %r14, %rdi
movq %r13, %rsi
callq 0x39233
xorb $0x1, %al
movzbl %bl, %edx
movzbl %al, %ecx
movq %r12, %rdi
movq %rbp, %rsi
pushq $0x1
popq %r8
movq 0x20(%rsp), %r9
callq 0x387a0
testb $0x2, 0x40(%rsp)
je 0x38a26
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x8cdc1
incq %r13
jmp 0x3899e
movq %r13, 0x28(%rsp)
xorl %ebp, %ebp
movq 0x20(%rsp), %r13
testq %r13, %r13
cmovleq %rbp, %r13
movzbl %r12b, %r12d
cmpq %rbp, %r13
je 0x38ab2
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x2ec2c
movq 0x38(%rsp), %rax
testq %rax, %rax
je 0x38a6d
movq 0x8(%rax), %rsi
jmp 0x38a6f
xorl %esi, %esi
movq 0x30(%rsp), %rdi
xorl %ecx, %ecx
cmpq $0x0, 0x28(%rsp)
sete %cl
movl %r12d, %edx
pushq $0x1
popq %r8
movq %rbx, %r9
callq 0x387a0
testb $0x2, 0x40(%rsp)
je 0x38aad
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x8cdc1
incq %rbp
jmp 0x38a45
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq