// File: /workspace/github_c_makefile_star2_O1/johsteffens[P]beth/xoico/src/xoico.xo.c
// Function: xoico_che_s_trans_ternary_branch
er_t xoico_che_s_trans_ternary_branch( xoico_che_s* o, x_source* source, xoico_che_result* result, xoico_typespec_s* out_typespec )
{
    // xoico_che.x:1258:1
    BLM_INIT_LEVEL(0);
    BLM_TRY(x_source_parse_fa(source,"?" ))
    BLM_TRY(xoico_che_result_a_push_sc(result,"?" ))
    xoico_typespec_s* typespec_true  = ((xoico_typespec_s*)BLM_LEVEL_T_PUSH(0,xoico_typespec_s,xoico_typespec_s_create()));
    xoico_typespec_s* typespec_false = ((xoico_typespec_s*)BLM_LEVEL_T_PUSH(0,xoico_typespec_s,xoico_typespec_s_create()));
    
    BLM_TRY(xoico_che_s_trans_expression(o,source, result, typespec_true ))
    BLM_TRY(x_source_parse_fa(source,": " ))
    BLM_TRY(xoico_che_result_a_push_sc(result,": " ))
    BLM_TRY(xoico_che_s_trans_expression(o,source, result, typespec_false ))
    
    if( typespec_true->type && typespec_false->type )
    {
        if( typespec_true->type != typespec_false->type )
        {
            BLM_TRY(x_source_parse_error_fa(source,"Ternary operator: Branches differ in type: ('#<sc_t>' : '#<sc_t>')",
                xoico_che_s_nameof(o,typespec_true->type ),
                xoico_che_s_nameof(o,typespec_false->type )
            ))
        }
    
        if( typespec_true->indirection != typespec_false->indirection )
        {
            BLM_TRY(x_source_parse_error_fa(source,"Ternary operator: Branches differ in levels of indirection: ('#<sz_t>' : '#<sz_t>')",
                typespec_true->indirection,
                typespec_false->indirection
            ))
        }
    }
    
    if( out_typespec && typespec_true->type )
    {
        xoico_typespec_s_copy(out_typespec,typespec_true );
        out_typespec->flag_addressable = false;
    }
    BLM_RETURNV(er_t, 0)
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, %rbp
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %r12
leaq 0x16b529(%rip), %rax    # 0x1a8dd0
movq (%rax), %rsi
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0xe0431
movq $0x0, 0x10(%rbx)
leaq 0xfe530(%rip), %rsi     # 0x13bdf6
movq %r14, %rdi
xorl %eax, %eax
callq 0xda10
movq %rax, %r15
testq %rax, %rax
je 0x3d8e7
leaq 0x28(%rsp), %rdi
callq 0xe0b30
jmp 0x3dabc
movq %rbp, 0x20(%rsp)
movq (%r13), %rbp
leaq 0x164bb9(%rip), %rax    # 0x1a24b0
movl 0x164bb3(%rip), %ecx    # 0x1a24b0
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x20(%rax,%rcx,8), %rdx
movq 0x18(%rax,%rcx,8), %rcx
andq %rbp, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %rbp, %rdx
je 0x3d955
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbp, %rdx
je 0x3d955
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbp, %rdx
je 0x3d955
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbp, %rdx
jne 0x3dace
movq (%rax,%rcx), %rbx
testq %rbx, %rbx
jne 0x3d985
movabsq $-0x3dfc7e0a250a30dc, %rdi # imm = 0xC20381F5DAF5CF24
movq %rbp, %rsi
callq 0xf3f85
movq %rax, %rbx
leaq 0x164b36(%rip), %rdi    # 0x1a24b0
movq %rbp, %rsi
movq %rax, %rdx
callq 0x12128c
leaq 0xfe46a(%rip), %rsi     # 0x13bdf6
movq %r13, %rdi
callq *0x20(%rbx)
movq %rax, %rbx
testq %rax, %rax
je 0x3d9a7
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %rbx, %r15
testq %rbx, %rbx
jne 0x3dabc
callq 0x10060
leaq 0x28(%rsp), %rbx
movabsq $-0x641110359430e9c5, %rdx # imm = 0x9BEEEFCA6BCF163B
movq %rbx, %rdi
xorl %esi, %esi
movq %rax, %rcx
callq 0xe0676
movq %rax, %rbp
callq 0x10060
movq %rbx, %rdi
xorl %esi, %esi
movabsq $-0x641110359430e9c5, %rdx # imm = 0x9BEEEFCA6BCF163B
movq %rax, %rcx
callq 0xe0676
movq %rax, 0x10(%rsp)
movq %r12, 0x18(%rsp)
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %rbp, 0x8(%rsp)
movq %rbp, %rcx
callq 0x3dbae
movq %rax, %rbx
testq %rax, %rax
je 0x3da25
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %rbx, %r15
testq %rbx, %rbx
movq 0x20(%rsp), %rbp
jne 0x3dabc
leaq 0xfe482(%rip), %rsi     # 0x13bebc
movq %r14, %rdi
xorl %eax, %eax
callq 0xda10
movq %rax, %rbx
testq %rax, %rax
je 0x3da59
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %rbx, %r15
testq %rbx, %rbx
movq 0x18(%rsp), %r12
jne 0x3dabc
leaq 0xfe452(%rip), %rsi     # 0x13bebc
movq %r13, %rdi
callq 0x34bcc
movq %rax, %rbx
testq %rax, %rax
je 0x3da87
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %rbx, %r15
testq %rbx, %rbx
jne 0x3dabc
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
movq 0x10(%rsp), %r13
movq %r13, %rcx
callq 0x3dbae
movq %rax, %rbx
testq %rax, %rax
je 0x3dab7
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %rbx, %r15
testq %rbx, %rbx
je 0x3dad5
movq %r15, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
jmp 0x3d959
movq 0x8(%rsp), %r8
movq 0x8(%r8), %rsi
testq %rsi, %rsi
je 0x3db8b
movq 0x8(%r13), %rax
testq %rax, %rax
je 0x3db8b
cmpq %rax, %rsi
je 0x3db4a
movq %r12, %rdi
callq 0x3417e
movq %rax, %rbx
movq 0x8(%r13), %rsi
movq %r12, %rdi
callq 0x3417e
leaq 0xfdf11(%rip), %rsi     # 0x13ba28
movq %r14, %rdi
movq %rbx, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xddb2
movq %rax, %rbx
testq %rax, %rax
je 0x3db3c
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %rbx, %r15
testq %rbx, %rbx
movq 0x8(%rsp), %r8
jne 0x3dabc
movq 0x20(%r8), %rdx
movq 0x20(%r13), %rcx
cmpq %rcx, %rdx
je 0x3db8b
leaq 0xfdf0d(%rip), %rsi     # 0x13ba6b
movq %r14, %rdi
xorl %eax, %eax
callq 0xddb2
movq %rax, %rbx
testq %rax, %rax
je 0x3db7d
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %rbx, %r15
testq %rbx, %rbx
movq 0x8(%rsp), %r8
jne 0x3dabc
testq %rbp, %rbp
je 0x3dba6
cmpq $0x0, 0x8(%r8)
je 0x3dba6
movq %rbp, %rdi
movq %r8, %rsi
callq 0xff8e
movb $0x0, 0x2e(%rbp)
xorl %r15d, %r15d
jmp 0x3d8d8