// File: /workspace/github_c_makefile_star2_O2/johsteffens[P]beth/lib/bcore/bcore.xo.c
// Function: x_bbml_t_translate_recursive
void x_bbml_t_translate_recursive( const x_bbml* o, tp_t t, tp_t name, bl_t shelve, x_sink* sink )
{
    // bcore_x_bbml.h:356:1
    
    // shelving obj_l
    if( o && shelve && bcore_via_call_t_defines_shelve(t ) )
    {
        x_bbml* o_clone =((x_bbml*)( 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_bbml_t_translate_recursive(o_clone,t, name, false, sink );
        x_inst_discard(((x_inst*)(o_clone)));
        return ;
    }
    
    if( name ) x_bbml_push_type(sink, name );
    
    x_bbml_push_type(sink, t );
    x_bbml_push_flag(sink, o != NULL );
    
    if( o )
    {
        if( x_bbml_t_defines_bbml_body_to_sink(t ) )
        {
            x_bbml_t_bbml_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_bbml_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_bbml_push_type(sink, x_array_t_get_mono_type(arr,t ) );
                sz_t size = x_array_t_size(arr,t );
                x_bbml_push_size(sink, size );
                for(sz_t i = 0; i < size; i++ )
                {
                    sr_s sr = x_array_t_c_get_sr(arr,t, i );
                    x_bbml_t_translate_recursive(((const x_bbml*)( sr.o)),sr_s_o_type(&(sr)), 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 );
                    tp_t name = x_stamp_t_name(t, i );
                    x_bbml_t_translate_recursive(((const x_bbml*)( sr.o)),sr_s_o_type(&(sr)), name, true, sink );
                    sr_down( sr );
                }
    
                /// we push a terminating '0' to indicate the end of the parameter list
                x_bbml_push_type(sink, 0 );
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, %rbx
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %r15
xorb $0x1, %cl
testq %rdi, %rdi
sete %al
orb %cl, %al
jne 0x3769d
movq %r14, %rdi
callq 0x37093
testb %al, %al
je 0x3769d
movq %r14, %rdi
movq %r15, %rsi
callq 0x2de39
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x370b1
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
movq %rbx, %r8
callq 0x37628
movq %r15, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5850d
testq %r12, %r12
je 0x376ad
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3827f
xorl %ebp, %ebp
testq %r15, %r15
setne %bpl
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3827f
movq %rbx, %rdi
movl %ebp, %esi
callq 0x38293
testq %r15, %r15
je 0x378a2
movq %r14, %rdi
callq 0x586c1
cmpq $0x0, 0x18(%rax)
je 0x37705
movq %r14, %rdi
callq 0x586c1
movq 0x18(%rax), %rax
movq %r15, %rdi
movq %rbx, %rsi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movabsq $-0x503db0e6e1c2e704, %rax # imm = 0xAFC24F191E3D18FC
cmpq %rax, %r14
jne 0x37735
movq 0x8(%r15), %rsi
movq 0x10(%r15), %rdx
incq %rdx
movq %rbx, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x345bc
movq %r14, %rdi
callq 0x36f05
testb %al, %al
je 0x3775d
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x37f82
movq %r14, %rdi
callq 0x36f22
movq %r14, %rdi
testb %al, %al
je 0x37818
callq 0x36f27
testb %al, %al
je 0x3778f
movq %r15, %rdi
movq %r14, %rsi
callq 0x36f9c
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3827f
movq %r15, %rdi
movq %r14, %rsi
callq 0x36fc4
movq %rax, %r12
movq %rbx, %rdi
movq %rax, %rsi
callq 0x382a9
xorl %r13d, %r13d
testq %r12, %r12
cmovleq %r13, %r12
pushq $0x1
popq %rbp
cmpq %r13, %r12
je 0x378a2
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %r13, %rcx
callq 0x2ec2c
movq 0x28(%rsp), %rax
testq %rax, %rax
je 0x377e1
movq 0x8(%rax), %rsi
jmp 0x377e3
xorl %esi, %esi
movq 0x20(%rsp), %rdi
xorl %edx, %edx
movl %ebp, %ecx
movq %rbx, %r8
callq 0x37628
testb $0x2, 0x30(%rsp)
je 0x37813
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x8cdc1
incq %r13
jmp 0x377b5
callq 0x32e3b
movq %rax, %r12
xorl %r13d, %r13d
testq %rax, %rax
cmovleq %r13, %r12
pushq $0x1
popq %rbp
cmpq %r13, %r12
je 0x37898
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %r13, %rcx
callq 0x2f9bc
movq %r14, %rdi
movq %r13, %rsi
callq 0x32e47
movq 0x28(%rsp), %rcx
testq %rcx, %rcx
je 0x37860
movq 0x8(%rcx), %rsi
jmp 0x37862
xorl %esi, %esi
movq 0x20(%rsp), %rdi
movq %rax, %rdx
movl %ebp, %ecx
movq %rbx, %r8
callq 0x37628
testb $0x2, 0x30(%rsp)
je 0x37893
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x8cdc1
incq %r13
jmp 0x3782d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3827f
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq