// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %r15
leaq 0x1616b0(%rip), %rax    # 0x19bdd0
movq (%rax), %rsi
leaq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0xd6675
movq $0x0, 0x10(%r13)
leaq 0xf66b7(%rip), %rsi     # 0x130df6
movq %r14, %rdi
xorl %eax, %eax
callq 0xda80
testq %rax, %rax
jne 0x3a896
movq (%r12), %r13
leaq 0x15ad53(%rip), %rax    # 0x1954b0
movl 0x15ad4d(%rip), %ecx    # 0x1954b0
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x20(%rax,%rcx,8), %rdx
movq 0x18(%rax,%rcx,8), %rcx
andq %r13, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %r13, %rdx
je 0x3a7b7
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r13, %rdx
je 0x3a7b7
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r13, %rdx
je 0x3a7b7
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r13, %rdx
jne 0x3a7c0
movq (%rax,%rcx), %rbp
testq %rbp, %rbp
jne 0x3a7e7
movabsq $-0x3dfc7e0a250a30dc, %rdi # imm = 0xC20381F5DAF5CF24
movq %r13, %rsi
callq 0xe9bc5
movq %rax, %rbp
leaq 0x15acd4(%rip), %rdi    # 0x1954b0
movq %r13, %rsi
movq %rax, %rdx
callq 0x115fac
leaq 0xf6608(%rip), %rsi     # 0x130df6
movq %r12, %rdi
callq *0x20(%rbp)
testq %rax, %rax
jne 0x3a896
movq %rbx, (%rsp)
callq 0xffc0
leaq 0x8(%rsp), %rbp
movabsq $-0x641110359430e9c5, %rbx # imm = 0x9BEEEFCA6BCF163B
movq %rbp, %rdi
xorl %esi, %esi
movq %rbx, %rdx
movq %rax, %rcx
callq 0xd68a8
movq %rax, %r13
callq 0xffc0
movq %rbp, %rdi
xorl %esi, %esi
movq %rbx, %rdx
movq %rax, %rcx
callq 0xd68a8
movq %rax, %rbx
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x3a94e
testq %rax, %rax
jne 0x3a896
leaq 0xf665f(%rip), %rsi     # 0x130ebc
movq %r14, %rdi
xorl %eax, %eax
callq 0xda80
testq %rax, %rax
jne 0x3a896
leaq 0xf6649(%rip), %rsi     # 0x130ebc
movq %r12, %rdi
callq 0x328fe
testq %rax, %rax
jne 0x3a896
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x3a94e
testq %rax, %rax
je 0x3a8b5
movq %rax, %rbp
leaq 0x8(%rsp), %rdi
callq 0xd6d2c
movq %rbp, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%r13), %rsi
testq %rsi, %rsi
movq (%rsp), %r12
je 0x3a92a
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x3a92a
cmpq %rax, %rsi
je 0x3a903
movq %r15, %rdi
callq 0x31f9d
movq %rax, %rbp
movq 0x8(%rbx), %rsi
movq %r15, %rdi
callq 0x31f9d
leaq 0xf613a(%rip), %rsi     # 0x130a28
movq %r14, %rdi
movq %rbp, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xde10
testq %rax, %rax
jne 0x3a896
movq 0x20(%r13), %rdx
movq 0x20(%rbx), %rcx
cmpq %rcx, %rdx
je 0x3a92a
leaq 0xf6154(%rip), %rsi     # 0x130a6b
movq %r14, %rdi
xorl %eax, %eax
callq 0xde10
testq %rax, %rax
jne 0x3a896
testq %r12, %r12
je 0x3a947
cmpq $0x0, 0x8(%r13)
je 0x3a947
movq %r12, %rdi
movq %r13, %rsi
callq 0xfef3
movb $0x0, 0x2e(%r12)
xorl %ebp, %ebp
jmp 0x3a899