// File: /workspace/github_c_makefile_star2_O0/johsteffens[P]beth/xoico/src/xoico.xo.c
// Function: xoico_che_s_trans_typespec_array_subscript
er_t xoico_che_s_trans_typespec_array_subscript( xoico_che_s* o, x_source* source, xoico_che_result* result, const xoico_typespec_s* in_typespec, xoico_typespec_s* out_typespec )
{
    // xoico_che_trans_typespec.x:283:1
    BLM_INIT_LEVEL(0);
    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, NULL ))
    BLM_TRY(x_source_parse_fa(source,"]" ))
    BLM_TRY(xoico_che_result_a_push_sc(result,"]" ))
    
    xoico_typespec_s* typespec = ((xoico_typespec_s*)BLM_LEVEL_T_PUSH(0,xoico_typespec_s,xoico_typespec_s_clone(in_typespec)));
    
    if( typespec->indirection == 0 )
    {
        if( in_typespec->type == ((tp_t)(TYPEOF_sc_t)) || in_typespec->type == ((tp_t)(TYPEOF_sd_t)) )
        {
            typespec->type = ((tp_t)(TYPEOF_u0_t));
        }
        else
        {
            BLM_RETURNV(er_t, x_source_parse_error_fa(source,"Array subscript requires indirection >= 1." ))
        }
    }
    else
    {
        typespec->indirection--;
    }
    
    BLM_TRY(xoico_che_s_trans_typespec_expression(o,source, result, typespec, out_typespec ))
    
    BLM_RETURNV(er_t, 0)
}

er_t xoico_che_s_trans_typespec_create( xoico_che_s* o, x_source* source, xoico_che_result* result, const xoico_typespec_s* in_typespec, xoico_typespec_s* out_typespec )
{
    // xoico_che_trans_typespec.x:324:1
    BLM_INIT_LEVEL(0);
    BLM_TRY(x_source_parse_fa(source,"!" ))
    
    //ignore in case indirection is 0;
    if( in_typespec->indirection > 0 )
    {
        if( !( in_typespec->indirection == 1 && in_typespec->flag_addressable ) )
        {
            BLM_RETURNV(er_t, x_source_parse_error_fa(source,"Create-Operator requires lvalue with addressable indirection of 1." ))
        }
    
        if( xoico_che_s_is_group( o,in_typespec->type ) )
        {
            BLM_RETURNV(er_t, x_source_parse_error_fa(source,"Create-Operator: lvalue is a group." ))
        }
    
        xoico_che_result* result_arg_obj = ((xoico_che_result*)BLM_LEVEL_A_PUSH(0,xoico_che_result_a_clone(result)));
        xoico_che_result_a_clear(result);
    
        sc_t sc_type = xoico_che_s_nameof(o,in_typespec->type );
        BLM_TRY(xoico_che_result_push_fa(result,"BCORE_PASS_CREATE(#<sc_t>,", sc_type ))
        xoico_che_result_a_push_result_d(result,((xoico_che_result*)bcore_fork(result_arg_obj)) );
        BLM_TRY(xoico_che_result_a_push_sc(result,")" ))
    }
    
    BLM_TRY(xoico_che_s_trans_typespec_expression(o,source, result, in_typespec, out_typespec ))
    BLM_RETURNV(er_t, 0)
}

er_t xoico_che_s_trans_typespec_test_presence( xoico_che_s* o, x_source* source, xoico_che_result* result, const xoico_typespec_s* in_typespec, xoico_typespec_s* out_typespec )
{
    // xoico_che_trans_typespec.x:363:1
    BLM_INIT_LEVEL(0);
    BLM_TRY(x_source_parse_fa(source,"?" ))
    
    //ignore in case indirection is 0;
    if( in_typespec->indirection > 0 )
    {
        if( in_typespec->indirection != 1 )
        {
            BLM_RETURNV(er_t, x_source_parse_error_fa(source,"Test-Operator requires lvalue with indirection of 1." ))
        }
    
        xoico_che_result* result_arg_obj = ((xoico_che_result*)BLM_LEVEL_A_PUSH(0,xoico_che_result_a_clone(result)));
        xoico_che_result_a_clear(result);
    
        sc_t sc_type = xoico_che_s_nameof(o,in_typespec->type );
        BLM_TRY(xoico_che_result_push_fa(result,"BCORE_PASS_TEST(#<sc_t>,", sc_type ))
        xoico_che_result_a_push_result_d(result,((xoico_che_result*)bcore_fork(result_arg_obj)) );
        BLM_TRY(xoico_che_result_a_push_sc(result,")" ))
    }
    
    BLM_TRY(xoico_che_s_trans_typespec_expression(o,source, result, in_typespec, out_typespec ))
    BLM_RETURNV(er_t, 0)
}

er_t xoico_che_s_trans_typespec_attach( xoico_che_s* o, x_source* source, xoico_che_result* result, const xoico_typespec_s* in_typespec, xoico_typespec_s* out_typespec )
{
    // xoico_che_trans_typespec.x:397:1
    BLM_INIT_LEVEL(0);
    if( in_typespec->indirection != 1 )
    {
        BLM_RETURNV(er_t, x_source_parse_error_fa(source,"Attach-Operator: lvalue with indirection of 1 expected." ))
    }
    
    if( !in_typespec->flag_addressable )
    {
        BLM_RETURNV(er_t, x_source_parse_error_fa(source,"Attach-Operator: Addressable lvalue expected." ))
    }
    
    BLM_TRY(x_source_parse_fa(source,"=<" ))
    
    xoico_che_result* result_arg_obj = ((xoico_che_result*)BLM_LEVEL_A_PUSH(0,xoico_che_result_a_clone(result)));
    xoico_che_result_a_clear(result);
    
    sc_t sc_type = xoico_che_s_nameof(o,in_typespec->type );
    BLM_TRY(xoico_che_result_push_fa(result,"#<sc_t>", sc_type ))
    
    xoico_typespec_s* typespec_rval = ((xoico_typespec_s*)BLM_LEVEL_T_PUSH(0,xoico_typespec_s,xoico_typespec_s_create()));
    if( xoico_che_s_is_group(o,in_typespec->type ) )
    {
        BLM_TRY(xoico_che_result_a_push_sc(result,"_a" ))
        BLM_TRY(xoico_che_result_a_push_sc(result,"_attach( &(" ))
        xoico_che_result_a_push_result_d(result,((xoico_che_result*)bcore_fork(result_arg_obj)) );
        BLM_TRY(xoico_che_result_push_fa(result,"), (#<sc_t>*)", sc_type ))
        BLM_TRY(xoico_che_result_a_push_sc(result,"(" ))
        BLM_TRY(xoico_che_s_trans_expression(o,source, result, typespec_rval ))
        BLM_TRY(xoico_che_result_a_push_sc(result,"))" ))
    }
    else
    {
        BLM_TRY(xoico_che_result_a_push_sc(result,"_attach( &(" ))
        xoico_che_result_a_push_result_d(result,((xoico_che_result*)bcore_fork(result_arg_obj)) );
        BLM_TRY(xoico_che_result_a_push_sc(result,"), " ))
        BLM_TRY(xoico_che_s_trans_expression(o,source, result, typespec_rval ))
        BLM_TRY(xoico_che_result_a_push_sc(result,")" ))
    }
    
    if( typespec_rval->type )
    {
        if( typespec_rval->indirection != 1 )
        {
            BLM_RETURNV(er_t, x_source_parse_error_fa(source,"Attach operator: rvalue with indirection '1' expected." ))
        }
    
        if( typespec_rval->access_class != TYPEOF_discardable )
        {
            BLM_RETURNV(er_t, x_source_parse_error_fa(source,"Attach operator: Discardable rvalue expected." ))
        }
    }
    
    if( out_typespec ) xoico_typespec_s_copy(out_typespec,in_typespec );
    BLM_RETURNV(er_t, 0)
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
leaq 0x182a2a(%rip), %rax    # 0x1b2330
movq (%rax), %rax
movq %rax, -0x38(%rbp)
leaq -0x68(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0xbfe80
movq -0x70(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x18(%rbp), %rdi
leaq 0x107bac(%rip), %rsi    # 0x1374ed
movb $0x0, %al
callq 0x4a20
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0x2f971
movq -0x78(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x70(%rbp), %rdi
callq 0xc0720
movq -0x80(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2fbd4
movq -0x20(%rbp), %rdi
leaq 0x107b71(%rip), %rsi    # 0x1374ed
callq 0x23300
movq %rax, -0x88(%rbp)
cmpq $0x0, -0x88(%rbp)
je 0x2f9b9
movq -0x88(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x70(%rbp), %rdi
callq 0xc0720
movq -0x90(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2fbd4
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x27f50
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x98(%rbp)
je 0x2fa06
movq -0x98(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x70(%rbp), %rdi
callq 0xc0720
movq -0xa0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2fbd4
movq -0x18(%rbp), %rdi
leaq 0x10fee6(%rip), %rsi    # 0x13f8f7
movb $0x0, %al
callq 0x4a20
movq %rax, -0xa8(%rbp)
cmpq $0x0, -0xa8(%rbp)
je 0x2fa50
movq -0xa8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x70(%rbp), %rdi
callq 0xc0720
movq -0xb0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2fbd4
movq -0x20(%rbp), %rdi
leaq 0x10fe9c(%rip), %rsi    # 0x13f8f7
callq 0x23300
movq %rax, -0xb8(%rbp)
cmpq $0x0, -0xb8(%rbp)
je 0x2fa98
movq -0xb8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x70(%rbp), %rdi
callq 0xc0720
movq -0xc0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2fbd4
movq -0x38(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x28(%rbp), %rdi
callq 0x5d70
movq -0xf0(%rbp), %rdi
movq %rax, %rcx
xorl %eax, %eax
movl %eax, %esi
movabsq $-0x641110359430e9c5, %rdx # imm = 0x9BEEEFCA6BCF163B
callq 0xc01a0
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x2fb51
movq -0x28(%rbp), %rax
movabsq $-0x84b14e74a9e1ff0, %rcx # imm = 0xF7B4EB18B561E010
cmpq %rcx, 0x8(%rax)
je 0x2fb06
movq -0x28(%rbp), %rax
movabsq $0x230abe18cdeefc99, %rcx # imm = 0x230ABE18CDEEFC99
cmpq %rcx, 0x8(%rax)
jne 0x2fb1d
movq -0xc8(%rbp), %rax
movabsq $-0x73f6ae1ad309fd45, %rcx # imm = 0x8C0951E52CF602BB
movq %rcx, 0x8(%rax)
jmp 0x2fb4f
movq -0x18(%rbp), %rdi
leaq 0x107ab5(%rip), %rsi    # 0x1375dd
movb $0x0, %al
callq 0x4c80
movq %rax, -0xd0(%rbp)
movq -0x70(%rbp), %rdi
callq 0xc0720
movq -0xd0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2fbd4
jmp 0x2fb64
movq -0xc8(%rbp), %rax
movq 0x20(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0xc8(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x27020
movq %rax, -0xd8(%rbp)
cmpq $0x0, -0xd8(%rbp)
je 0x2fbb5
movq -0xd8(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x70(%rbp), %rdi
callq 0xc0720
movq -0xe0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x2fbd4
movq $0x0, -0xe8(%rbp)
movq -0x70(%rbp), %rdi
callq 0xc0720
movq -0xe8(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xf0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)