// File: /workspace/github_c_makefile_star2_O0/johsteffens[P]beth/xoico/src/xoico.xo.c
// Function: xoico_che_s_adapt_expression
er_t xoico_che_s_adapt_expression( xoico_che_s* o, x_source* source, const xoico_typespec_s* typespec_expr, const xoico_typespec_s* typespec_target, const xoico_che_result* result_expr, xoico_che_result* result )
{
    // xoico_che.x:812:1
    BLM_INIT_LEVEL(0);
    if( !typespec_expr->type )
    {
        BLM_RETURNV(er_t, x_source_parse_error_fa(source,"xoico_che_s_adapt_expression: no expression type specified.",
            typespec_expr->indirection,
            typespec_target->indirection
        ))
    }
    
    if( !typespec_target->type )
    {
        BLM_RETURNV(er_t, x_source_parse_error_fa(source,"xoico_che_s_adapt_expression: no target type specified.",
            typespec_expr->indirection,
            typespec_target->indirection
        ))
    }
    
    if( typespec_target->type == ((tp_t)(TYPEOF_type_deduce)) ) BLM_RETURNV(er_t, x_source_parse_error_fa(source,"adapt_expression: typespec_target is 'type_deduce'" ))
    if( typespec_target->type == ((tp_t)(TYPEOF_type_object)) ) BLM_RETURNV(er_t, x_source_parse_error_fa(source,"adapt_expression: typespec_target is 'type_object'" ))
    if( typespec_expr->type == ((tp_t)(TYPEOF_type_deduce)) ) BLM_RETURNV(er_t, x_source_parse_error_fa(source,"adapt_expression: typespec_expr is 'type_deduce'" ))
    if( typespec_expr->type == ((tp_t)(TYPEOF_type_object)) ) BLM_RETURNV(er_t, x_source_parse_error_fa(source,"adapt_expression: typespec_expr is 'type_object'" ))
    
    bl_t discarding_const =
        ( typespec_expr->access_class == TYPEOF_const && typespec_expr->access_class != typespec_target->access_class ) &&
        ( typespec_expr->indirection > 0 && typespec_target->indirection > 0 );
    
    if( discarding_const ) BLM_RETURNV(er_t, x_source_parse_error_fa(source,"Discarding 'const' qualifier." ))
    
    if( typespec_target->access_class == TYPEOF_discardable && typespec_expr->access_class != TYPEOF_discardable )
    {
        BLM_RETURNV(er_t, x_source_parse_error_fa(source,"Discardable expression expected." ))
    }
    
    if( xoico_typespec_s_converts_to(typespec_expr,typespec_target ) )
    {
        xoico_che_result_a_push_result_c(result,result_expr );
    }
    else
    {BLM_INIT_LEVEL(1);
        bl_t implicit_cast = false;
        st_s* fail_msg = NULL;
        if( typespec_target->type != typespec_expr->type )
        {
            if( xoico_che_s_is_group(o,typespec_target->type ) && typespec_target->indirection == 1 )
            {
                if( xoico_che_s_is_group(o,typespec_expr->type ) )
                {
                    implicit_cast = true;
                }
                else if( xoico_che_s_is_stamp(o,typespec_expr->type ) )
                {
                    const xoico_stamp_s* stamp = xoico_che_s_get_stamp(o,typespec_expr->type );
                    if( stamp->is_aware || typespec_target->flag_obliv )
                    {
                        implicit_cast = true;
                    }
                    else
                    {
                        fail_msg = ((st_s*)BLM_LEVEL_T_PUSH(0,st_s,st_s_create_fa("'#<sc_t>' is obliv but the target typespec does not explicitly tolerate obliv objects.", xoico_che_s_nameof(o,typespec_expr->type ) )));
                    }
                }
                else if( xoico_che_s_is_type(o,typespec_expr->type ) )
                {
                    if( typespec_target->flag_obliv )
                    {
                        implicit_cast = true;
                    }
                    else
                    {
                        fail_msg = ((st_s*)BLM_LEVEL_T_PUSH(0,st_s,st_s_create_fa("'#<sc_t>' is presumed obliv but the target typespec does not explicitly tolerate obliv objects.", xoico_che_s_nameof(o,typespec_expr->type ) )));
                    }
                }
                else
                {
                    fail_msg = ((st_s*)BLM_LEVEL_T_PUSH(0,st_s,st_s_create_fa("Source type cannot be classified." )));
                }
            }
            else
            {
                fail_msg = ((st_s*)BLM_LEVEL_T_PUSH(0,st_s,st_s_create_fa("Target is not a group or target indirection is != 1." )));
            }
        }
    
        if( fail_msg )
        {
            st_s* st_typespec_expr = ((st_s*)BLM_LEVEL_T_PUSH(0,st_s,st_s_create()));
            st_s* st_typespec_target = ((st_s*)BLM_LEVEL_T_PUSH(0,st_s,st_s_create()));
            xoico_che_s_typespec_to_sink(o,typespec_expr,((x_sink*)( st_typespec_expr )));
            xoico_che_s_typespec_to_sink(o,typespec_target,((x_sink*)( st_typespec_target )));
            st_s* msg = ((st_s*)BLM_LEVEL_T_PUSH(0,st_s,st_s_create()));
            st_s_push_fa(msg,"Implicit cast from '#<sc_t>' to '#<sc_t>' is not allowed. ", st_typespec_expr->sc, st_typespec_target->sc );
            st_s_push_fa(msg,"Reason: #<st_s*>\n", fail_msg );
            BLM_RETURNV(er_t, x_source_parse_error_fa(source,"#<st_s*>", msg ))
        }
    
        xoico_che_result* result_expression =((xoico_che_result*)( ((xoico_che_result_arr_s*)BLM_LEVEL_T_PUSH(1,xoico_che_result_arr_s,xoico_che_result_arr_s_create()))));
        BLM_TRY(xoico_che_s_adapt_expression_indirection(o,source, typespec_expr, typespec_target->indirection, result_expr, result_expression ))
    
        if( implicit_cast )
        {
            xoico_che_result_a_push_result_d(result,((xoico_che_result*)(xoico_che_result_cast_s_reduce(xoico_che_result_cast_s__(xoico_che_result_cast_s_create(),o, xoico_typespec_s_clone(typespec_target), ((xoico_che_result*)bcore_fork(result_expression)) )) )));
        }
        else
        {
            xoico_che_result_a_push_result_d(result,((xoico_che_result*)bcore_fork(result_expression)) );
        }
    
    BLM_DOWN();}
    BLM_RETURNV(er_t, 0)
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1d0, %rsp            # imm = 0x1D0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
leaq 0x18d446(%rip), %rax    # 0x1b2330
movq (%rax), %rax
movq %rax, -0x40(%rbp)
leaq -0x70(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0xbfe80
movq -0x78(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x24f61
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rdx
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rcx
leaq 0x11193d(%rip), %rsi    # 0x13687d
movb $0x0, %al
callq 0x4c80
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0x80(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2572e
movq -0x28(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x24fae
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rdx
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rcx
leaq 0x111932(%rip), %rsi    # 0x1368b9
movb $0x0, %al
callq 0x4c80
movq %rax, -0x88(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0x88(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2572e
movq -0x28(%rbp), %rax
movabsq $-0x59040ffc58933ff2, %rcx # imm = 0xA6FBF003A76CC00E
cmpq %rcx, 0x8(%rax)
jne 0x24ff4
movq -0x18(%rbp), %rdi
leaq 0x111924(%rip), %rsi    # 0x1368f1
movb $0x0, %al
callq 0x4c80
movq %rax, -0x90(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0x90(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2572e
movq -0x28(%rbp), %rax
movabsq $0x213393bef2495d15, %rcx # imm = 0x213393BEF2495D15
cmpq %rcx, 0x8(%rax)
jne 0x2503a
movq -0x18(%rbp), %rdi
leaq 0x111911(%rip), %rsi    # 0x136924
movb $0x0, %al
callq 0x4c80
movq %rax, -0x98(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0x98(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2572e
movq -0x20(%rbp), %rax
movabsq $-0x59040ffc58933ff2, %rcx # imm = 0xA6FBF003A76CC00E
cmpq %rcx, 0x8(%rax)
jne 0x25080
movq -0x18(%rbp), %rdi
leaq 0x1118fe(%rip), %rsi    # 0x136957
movb $0x0, %al
callq 0x4c80
movq %rax, -0xa0(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0xa0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2572e
movq -0x20(%rbp), %rax
movabsq $0x213393bef2495d15, %rcx # imm = 0x213393BEF2495D15
cmpq %rcx, 0x8(%rax)
jne 0x250c6
movq -0x18(%rbp), %rdi
leaq 0x1118e9(%rip), %rsi    # 0x136988
movb $0x0, %al
callq 0x4c80
movq %rax, -0xa8(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0xa8(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2572e
movq -0x20(%rbp), %rcx
xorl %eax, %eax
movabsq $0x65c9718e19e3df34, %rdx # imm = 0x65C9718E19E3DF34
cmpq %rdx, 0x10(%rcx)
movb %al, -0x159(%rbp)
jne 0x2512d
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x28(%rbp), %rdx
xorl %eax, %eax
cmpq 0x10(%rdx), %rcx
movb %al, -0x159(%rbp)
je 0x2512d
movq -0x20(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x20(%rcx)
movb %al, -0x15a(%rbp)
jle 0x25121
movq -0x28(%rbp), %rax
cmpq $0x0, 0x20(%rax)
setg %al
movb %al, -0x15a(%rbp)
movb -0x15a(%rbp), %al
movb %al, -0x159(%rbp)
movb -0x159(%rbp), %al
andb $0x1, %al
movb %al, -0xa9(%rbp)
testb $0x1, -0xa9(%rbp)
je 0x25176
movq -0x18(%rbp), %rdi
leaq 0x11186a(%rip), %rsi    # 0x1369b9
movb $0x0, %al
callq 0x4c80
movq %rax, -0xb8(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0xb8(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2572e
movq -0x28(%rbp), %rax
movabsq $-0x12e90733f18038df, %rcx # imm = 0xED16F8CC0E7FC721
cmpq %rcx, 0x10(%rax)
jne 0x251d0
movq -0x20(%rbp), %rax
movabsq $-0x12e90733f18038df, %rcx # imm = 0xED16F8CC0E7FC721
cmpq %rcx, 0x10(%rax)
je 0x251d0
movq -0x18(%rbp), %rdi
leaq 0x11182e(%rip), %rsi    # 0x1369d7
movb $0x0, %al
callq 0x4c80
movq %rax, -0xc0(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0xc0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2572e
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x6e80
testb $0x1, %al
jne 0x251e3
jmp 0x251f5
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x24e80
jmp 0x2570f
movq -0x78(%rbp), %rax
movq %rax, -0xc8(%rbp)
leaq -0xf8(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x100(%rbp), %rdi
movq -0xc8(%rbp), %rsi
callq 0xbfe80
movq -0x100(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movq $0x1, 0x10(%rax)
movb $0x0, -0x101(%rbp)
movq $0x0, -0x110(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x8(%rcx), %rax
je 0x25465
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x25740
testb $0x1, %al
jne 0x25280
jmp 0x25423
movq -0x28(%rbp), %rax
cmpq $0x1, 0x20(%rax)
jne 0x25423
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x25740
testb $0x1, %al
jne 0x252a6
jmp 0x252b2
movb $0x1, -0x101(%rbp)
jmp 0x25421
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x25770
testb $0x1, %al
jne 0x252cc
jmp 0x2535d
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x257a0
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rax
testb $0x1, 0x38(%rax)
jne 0x252fb
movq -0x28(%rbp), %rax
testb $0x1, 0x2b(%rax)
je 0x25304
movb $0x1, -0x101(%rbp)
jmp 0x25358
movq -0xc8(%rbp), %rax
movq %rax, -0x168(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x22840
movq %rax, %rsi
leaq 0x1116cb(%rip), %rdi    # 0x1369f8
movb $0x0, %al
callq 0xff430
movq -0x168(%rbp), %rdi
movq %rax, %rcx
xorl %eax, %eax
movl %eax, %esi
movabsq $-0x503db0e6e1c2e704, %rdx # imm = 0xAFC24F191E3D18FC
callq 0xc01a0
movq %rax, -0x110(%rbp)
jmp 0x2541f
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x257d0
testb $0x1, %al
jne 0x25374
jmp 0x253dd
movq -0x28(%rbp), %rax
testb $0x1, 0x2b(%rax)
je 0x25387
movb $0x1, -0x101(%rbp)
jmp 0x253db
movq -0xc8(%rbp), %rax
movq %rax, -0x170(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x22840
movq %rax, %rsi
leaq 0x11169f(%rip), %rdi    # 0x136a4f
movb $0x0, %al
callq 0xff430
movq -0x170(%rbp), %rdi
movq %rax, %rcx
xorl %eax, %eax
movl %eax, %esi
movabsq $-0x503db0e6e1c2e704, %rdx # imm = 0xAFC24F191E3D18FC
callq 0xc01a0
movq %rax, -0x110(%rbp)
jmp 0x2541d
movq -0xc8(%rbp), %rax
movq %rax, -0x178(%rbp)
leaq 0x1116bd(%rip), %rdi    # 0x136aaf
movb $0x0, %al
callq 0xff430
movq -0x178(%rbp), %rdi
movq %rax, %rcx
xorl %eax, %eax
movl %eax, %esi
movabsq $-0x503db0e6e1c2e704, %rdx # imm = 0xAFC24F191E3D18FC
callq 0xc01a0
movq %rax, -0x110(%rbp)
jmp 0x2541f
jmp 0x25421
jmp 0x25463
movq -0xc8(%rbp), %rax
movq %rax, -0x180(%rbp)
leaq 0x111699(%rip), %rdi    # 0x136ad1
movb $0x0, %al
callq 0xff430
movq -0x180(%rbp), %rdi
movq %rax, %rcx
xorl %eax, %eax
movl %eax, %esi
movabsq $-0x503db0e6e1c2e704, %rdx # imm = 0xAFC24F191E3D18FC
callq 0xc01a0
movq %rax, -0x110(%rbp)
jmp 0x25465
cmpq $0x0, -0x110(%rbp)
je 0x255c9
movq -0xc8(%rbp), %rax
movq %rax, -0x198(%rbp)
movb $0x0, %al
callq 0xff2e0
movq -0x198(%rbp), %rdi
movq %rax, %rcx
xorl %eax, %eax
movl %eax, %esi
movabsq $-0x503db0e6e1c2e704, %rdx # imm = 0xAFC24F191E3D18FC
callq 0xc01a0
movq %rax, -0x120(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0x190(%rbp)
movb $0x0, %al
callq 0xff2e0
movq -0x190(%rbp), %rdi
movq %rax, %rcx
xorl %eax, %eax
movl %eax, %esi
movabsq $-0x503db0e6e1c2e704, %rdx # imm = 0xAFC24F191E3D18FC
callq 0xc01a0
movq %rax, -0x128(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x120(%rbp), %rdx
callq 0x22d10
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x128(%rbp), %rdx
callq 0x22d10
movq -0xc8(%rbp), %rax
movq %rax, -0x188(%rbp)
movb $0x0, %al
callq 0xff2e0
movq -0x188(%rbp), %rdi
movq %rax, %rcx
xorl %eax, %eax
movl %eax, %esi
movabsq $-0x503db0e6e1c2e704, %rdx # imm = 0xAFC24F191E3D18FC
callq 0xc01a0
movq %rax, -0x130(%rbp)
movq -0x130(%rbp), %rdi
movq -0x120(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x128(%rbp), %rax
movq 0x8(%rax), %rcx
leaq 0x11159c(%rip), %rsi    # 0x136b06
movb $0x0, %al
callq 0x100210
movq -0x130(%rbp), %rdi
movq -0x110(%rbp), %rdx
leaq 0x1115bb(%rip), %rsi    # 0x136b41
movb $0x0, %al
callq 0x100210
movq -0x18(%rbp), %rdi
movq -0x130(%rbp), %rdx
leaq 0x119d43(%rip), %rsi    # 0x13f2e2
movb $0x0, %al
callq 0x4c80
movq %rax, -0x138(%rbp)
movq -0x100(%rbp), %rdi
callq 0xc0720
movq -0x138(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2572e
movq -0xc8(%rbp), %rax
movq %rax, -0x1a0(%rbp)
callq 0x35ee0
movq -0x1a0(%rbp), %rdi
movq %rax, %rcx
movl $0x1, %esi
movabsq $-0x7850996cdf80346a, %rdx # imm = 0x87AF6693207FCB96
callq 0xc01a0
movq %rax, -0x140(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x30(%rbp), %r8
movq -0x140(%rbp), %r9
callq 0x24c10
movq %rax, -0x148(%rbp)
cmpq $0x0, -0x148(%rbp)
je 0x25660
movq -0x148(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x100(%rbp), %rdi
callq 0xc0720
movq -0x150(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2572e
testb $0x1, -0x101(%rbp)
je 0x256dd
movq -0x38(%rbp), %rax
movq %rax, -0x1a8(%rbp)
callq 0x36690
movq %rax, -0x1c0(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movq -0x28(%rbp), %rdi
callq 0x5d70
movq %rax, -0x1b0(%rbp)
movq -0x140(%rbp), %rdi
callq 0x9d3d0
movq -0x1c0(%rbp), %rdi
movq -0x1b8(%rbp), %rsi
movq -0x1b0(%rbp), %rdx
movq %rax, %rcx
callq 0x25860
movq %rax, %rdi
callq 0x25800
movq -0x1a8(%rbp), %rdi
movq %rax, %rsi
callq 0x24290
jmp 0x25703
movq -0x38(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movq -0x140(%rbp), %rdi
callq 0x9d3d0
movq -0x1c8(%rbp), %rdi
movq %rax, %rsi
callq 0x24290
leaq -0x100(%rbp), %rdi
callq 0xc06e0
movq $0x0, -0x158(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0x158(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq
nopl (%rax,%rax)