// File: /workspace/github_c_makefile_star2_O0/johsteffens[P]beth/xoico/src/xoico.xo.c
// Function: xoico_che_s_trans_builtin_scope
er_t xoico_che_s_trans_builtin_scope( xoico_che_s* o, x_source* source, const xoico_che_result* result_expr, const xoico_typespec_s* typespec_expr, xoico_che_result* result_out, xoico_typespec_s* typespec_out )
{
    // xoico_che_builtin.x:156:1
    BLM_INIT_LEVEL(0);
    bl_t has_arg = false;
    bl_t closing_bracket = true;
    
    sz_t level = 0;
    
    if( result_expr ) // member call
    {
        if( x_source_parse_bl(source,"#?'^'" ) )
        {
            level = x_source_parse_bl(source,"#?'^'" ) ? 0 : o->block_level;
    
            if( !o->waive_local_scope_operator_creates_implicit_block )
            {
                if( level > 0 && xoico_che_s_stack_block_get_top_unit(o)->statement_wrapped_as_block )
                {
                    BLM_RETURNV(er_t, x_source_parse_error_fa(source,"Scope operator '^' creates an implicit block. Please use an explicit block  '{ ... }' or choose a different scope operator to clarify your intention ." ))
                }
            }
            closing_bracket = false;
        }
        else
        {
            BLM_TRY(x_source_parse_fa(source," ( " ))
            xoico_che_result_a_clear(result_out);
            has_arg = !x_source_parse_bl(source,"#=?')'" );
        }
    }
    else // direct call
    {
        BLM_TRY(x_source_parse_fa(source,"scope ( " ))
        xoico_che_result_arr_s* result = ((xoico_che_result_arr_s*)BLM_LEVEL_T_PUSH(0,xoico_che_result_arr_s,xoico_che_result_arr_s_create()));
        xoico_typespec_s* typespec = ((xoico_typespec_s*)BLM_LEVEL_T_PUSH(0,xoico_typespec_s,xoico_typespec_s_create()));
        BLM_TRY(xoico_che_s_trans_expression(o,source,((xoico_che_result*)( result)), typespec ))
        typespec_expr = typespec;
        result_expr =((const xoico_che_result*)( result));
        has_arg = x_source_parse_bl(source,"#?','" );
    }
    
    if( typespec_expr->type == 0 ) BLM_RETURNV(er_t, x_source_parse_error_fa(source,"scope: Expression not tractable." ))
    if( typespec_expr->access_class != TYPEOF_discardable ) BLM_RETURNV(er_t, x_source_parse_error_fa(source,"scope: Expression is not discardable." ))
    xoico_typespec_s* typespec_scope = ((xoico_typespec_s*)BLM_LEVEL_T_PUSH(0,xoico_typespec_s,xoico_typespec_s_clone(typespec_expr)));
    typespec_scope->access_class = TYPEOF_mutable;
    
    BLM_TRY(xoico_che_result_a_push_sc(result_out,"((" ))
    
    if( has_arg )
    {
        BLM_TRY(x_source_parse_fa(source," " ))
        tp_t tp_identifier = xoico_che_s_get_identifier(o,source, true );
    
        if( xoico_che_s_is_var(o,tp_identifier ) )
        {
            level = xoico_che_stack_var_s_get_level(&(o->stack_var),tp_identifier );
        }
        else if( tp_identifier == ((tp_t)(TYPEOF_scope_local)) )
        {
            level = o->block_level;
        }
        else if( tp_identifier == ((tp_t)(TYPEOF_scope_func)) )
        {
            level = 0;
        }
        else
        {
            BLM_RETURNV(er_t, x_source_parse_error_fa(source,"scope: identifier '#<sc_t>' does not represent a variable.", xoico_che_s_nameof(o,tp_identifier ) ))
        }
    }
    
    if( closing_bracket ) BLM_TRY(x_source_parse_fa(source," )" ))
    
    if( typespec_scope->indirection != 1 ) BLM_RETURNV(er_t, x_source_parse_error_fa(source,"scope: Expression's indirection != 1." ))
    if( typespec_scope->flag_scope )       BLM_RETURNV(er_t, x_source_parse_error_fa(source,"scope: Target is already scoped." ))
    
    BLM_TRY(xoico_che_s_push_typespec(o,typespec_scope, result_out ))
    
    if( xoico_che_s_is_group(o,typespec_scope->type ) )
    {
        if( typespec_scope->flag_obliv )
        {
            BLM_RETURNV(er_t, x_source_parse_error_fa(source,"scope: Expression yields an oblivious typespec of a group. Use t_scope to clarify which type is intended." ))
        }
        BLM_TRY(xoico_che_result_push_fa(result_out,")BLM_LEVEL_A_PUSH(#<sz_t>,", level ))
        xoico_che_result_a_push_result_c(result_out,result_expr );
        BLM_TRY(xoico_che_result_a_push_sc(result_out,"))" ))
    }
    else
    {
        BLM_TRY(xoico_che_result_push_fa(result_out,")BLM_LEVEL_T_PUSH(#<sz_t>,#<sc_t>,", level, xoico_che_s_nameof(o,typespec_scope->type ) ))
        xoico_che_result_a_push_result_c(result_out,result_expr );
        BLM_TRY(xoico_che_result_a_push_sc(result_out,"))" ))
    }
    
    o->stack_block.adl.data[ level ]->use_blm = true;
    
    if( typespec_out )
    {
        xoico_typespec_s_copy(typespec_out,typespec_scope );
        typespec_out->flag_scope = true;
    }
    
    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 0x18bb76(%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)
movb $0x0, -0x79(%rbp)
movb $0x1, -0x7a(%rbp)
movq $0x0, -0x88(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x2692b
movq -0x18(%rbp), %rdi
leaq 0x10d223(%rip), %rsi    # 0x133a36
callq 0x6700
testb $0x1, %al
jne 0x26821
jmp 0x268bc
movq -0x18(%rbp), %rdi
leaq 0x10d20a(%rip), %rsi    # 0x133a36
callq 0x6700
testb $0x1, %al
jne 0x26837
jmp 0x26842
xorl %eax, %eax
movq %rax, -0x1a0(%rbp)
jmp 0x26851
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x1a0(%rbp)
movq -0x1a0(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rax
testb $0x1, 0xf(%rax)
jne 0x268b6
cmpq $0x0, -0x88(%rbp)
jle 0x268b4
movq -0x10(%rbp), %rdi
callq 0x22980
testb $0x1, 0x12(%rax)
je 0x268b4
movq -0x18(%rbp), %rdi
leaq 0x1110a1(%rip), %rsi    # 0x13792e
movb $0x0, %al
callq 0x4c80
movq %rax, -0x90(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0x90(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x27007
jmp 0x268b6
movb $0x0, -0x7a(%rbp)
jmp 0x26926
movq -0x18(%rbp), %rdi
leaq 0x111103(%rip), %rsi    # 0x1379ca
movb $0x0, %al
callq 0x4a20
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x98(%rbp)
je 0x26906
movq -0x98(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0xa0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x27007
movq -0x30(%rbp), %rdi
callq 0x2f780
movq -0x18(%rbp), %rdi
leaq 0x10cf2f(%rip), %rsi    # 0x133849
callq 0x6700
xorb $-0x1, %al
andb $0x1, %al
movb %al, -0x79(%rbp)
jmp 0x26a5b
movq -0x18(%rbp), %rdi
leaq 0x11108f(%rip), %rsi    # 0x1379c5
movb $0x0, %al
callq 0x4a20
movq %rax, -0xa8(%rbp)
cmpq $0x0, -0xa8(%rbp)
je 0x26975
movq -0xa8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0xb0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x27007
movq -0x40(%rbp), %rax
movq %rax, -0x1b0(%rbp)
callq 0x35ee0
movq -0x1b0(%rbp), %rdi
movq %rax, %rcx
xorl %eax, %eax
movl %eax, %esi
movabsq $-0x7850996cdf80346a, %rdx # imm = 0x87AF6693207FCB96
callq 0xc01a0
movq %rax, -0xb8(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x1a8(%rbp)
callq 0x5d20
movq -0x1a8(%rbp), %rdi
movq %rax, %rcx
xorl %eax, %eax
movl %eax, %esi
movabsq $-0x641110359430e9c5, %rdx # imm = 0x9BEEEFCA6BCF163B
callq 0xc01a0
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0xb8(%rbp), %rdx
movq -0xc0(%rbp), %rcx
callq 0x27f50
movq %rax, -0xc8(%rbp)
cmpq $0x0, -0xc8(%rbp)
je 0x26a30
movq -0xc8(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0xd0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x27007
movq -0xc0(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x10ec1c(%rip), %rsi    # 0x13566d
callq 0x6700
andb $0x1, %al
movb %al, -0x79(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x26a98
movq -0x18(%rbp), %rdi
leaq 0x110f5d(%rip), %rsi    # 0x1379ce
movb $0x0, %al
callq 0x4c80
movq %rax, -0xd8(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0xd8(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x27007
movq -0x28(%rbp), %rax
movabsq $-0x12e90733f18038df, %rcx # imm = 0xED16F8CC0E7FC721
cmpq %rcx, 0x10(%rax)
je 0x26ade
movq -0x18(%rbp), %rdi
leaq 0x110f38(%rip), %rsi    # 0x1379ef
movb $0x0, %al
callq 0x4c80
movq %rax, -0xe0(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0xe0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x27007
movq -0x40(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movq -0x28(%rbp), %rdi
callq 0x5d70
movq -0x1b8(%rbp), %rdi
movq %rax, %rcx
xorl %eax, %eax
movl %eax, %esi
movabsq $-0x641110359430e9c5, %rdx # imm = 0x9BEEEFCA6BCF163B
callq 0xc01a0
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rax
movabsq $-0x2c53c3baa9910217, %rcx # imm = 0xD3AC3C45566EFDE9
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rdi
leaq 0x110d96(%rip), %rsi    # 0x1378cc
callq 0x23300
movq %rax, -0xf0(%rbp)
cmpq $0x0, -0xf0(%rbp)
je 0x26b73
movq -0xf0(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0xf8(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x27007
testb $0x1, -0x79(%rbp)
je 0x26cb3
movq -0x18(%rbp), %rdi
leaq 0x126ff9(%rip), %rsi    # 0x14db81
movb $0x0, %al
callq 0x4a20
movq %rax, -0x100(%rbp)
cmpq $0x0, -0x100(%rbp)
je 0x26bc7
movq -0x100(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0x108(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x27007
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x1, %edx
callq 0x23380
movq %rax, -0x110(%rbp)
movq -0x10(%rbp), %rdi
movq -0x110(%rbp), %rsi
callq 0x29aa0
testb $0x1, %al
jne 0x26bf6
jmp 0x26c16
movq -0x10(%rbp), %rdi
addq $0x38, %rdi
movq -0x110(%rbp), %rsi
callq 0x33220
movq %rax, -0x88(%rbp)
jmp 0x26cb1
movabsq $-0x38096408726e4e99, %rax # imm = 0xC7F69BF78D91B167
cmpq %rax, -0x110(%rbp)
jne 0x26c3a
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x88(%rbp)
jmp 0x26caf
movabsq $0x5e9151f1091c19ba, %rax # imm = 0x5E9151F1091C19BA
cmpq %rax, -0x110(%rbp)
jne 0x26c5a
movq $0x0, -0x88(%rbp)
jmp 0x26cad
movq -0x18(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movq -0x10(%rbp), %rdi
movq -0x110(%rbp), %rsi
callq 0x22840
movq -0x1c0(%rbp), %rdi
movq %rax, %rdx
leaq 0x110d8f(%rip), %rsi    # 0x137a15
movb $0x0, %al
callq 0x4c80
movq %rax, -0x118(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0x118(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x27007
jmp 0x26caf
jmp 0x26cb1
jmp 0x26cb3
testb $0x1, -0x7a(%rbp)
je 0x26d05
movq -0x18(%rbp), %rdi
leaq 0x12e686(%rip), %rsi    # 0x15534a
movb $0x0, %al
callq 0x4a20
movq %rax, -0x120(%rbp)
cmpq $0x0, -0x120(%rbp)
je 0x26d03
movq -0x120(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0x128(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x27007
jmp 0x26d05
movq -0xe8(%rbp), %rax
cmpq $0x1, 0x20(%rax)
je 0x26d45
movq -0x18(%rbp), %rdi
leaq 0x110d32(%rip), %rsi    # 0x137a50
movb $0x0, %al
callq 0x4c80
movq %rax, -0x130(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0x130(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x27007
movq -0xe8(%rbp), %rax
testb $0x1, 0x2d(%rax)
je 0x26d84
movq -0x18(%rbp), %rdi
leaq 0x110d19(%rip), %rsi    # 0x137a76
movb $0x0, %al
callq 0x4c80
movq %rax, -0x138(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0x138(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x27007
movq -0x10(%rbp), %rdi
movq -0xe8(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x22e00
movq %rax, -0x140(%rbp)
cmpq $0x0, -0x140(%rbp)
je 0x26dd0
movq -0x140(%rbp), %rax
movq %rax, -0x148(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0x148(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x27007
movq -0x10(%rbp), %rdi
movq -0xe8(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x25740
testb $0x1, %al
jne 0x26ded
jmp 0x26ed7
movq -0xe8(%rbp), %rax
testb $0x1, 0x2b(%rax)
je 0x26e2c
movq -0x18(%rbp), %rdi
leaq 0x110c92(%rip), %rsi    # 0x137a97
movb $0x0, %al
callq 0x4c80
movq %rax, -0x150(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0x150(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x27007
movq -0x30(%rbp), %rdi
movq -0x88(%rbp), %rdx
leaq 0x110cc3(%rip), %rsi    # 0x137b01
movb $0x0, %al
callq 0x261b0
movq %rax, -0x158(%rbp)
cmpq $0x0, -0x158(%rbp)
je 0x26e7d
movq -0x158(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0x160(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x27007
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x24e80
movq -0x30(%rbp), %rdi
leaq 0x10f851(%rip), %rsi    # 0x1366e6
callq 0x23300
movq %rax, -0x168(%rbp)
cmpq $0x0, -0x168(%rbp)
je 0x26ed2
movq -0x168(%rbp), %rax
movq %rax, -0x170(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0x170(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x27007
jmp 0x26faf
movq -0x30(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movq -0x10(%rbp), %rdi
movq -0xe8(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x22840
movq -0x1d0(%rbp), %rdi
movq -0x1c8(%rbp), %rdx
movq %rax, %rcx
leaq 0x110c00(%rip), %rsi    # 0x137b1c
movb $0x0, %al
callq 0x261b0
movq %rax, -0x178(%rbp)
cmpq $0x0, -0x178(%rbp)
je 0x26f5b
movq -0x178(%rbp), %rax
movq %rax, -0x180(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0x180(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x27007
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x24e80
movq -0x30(%rbp), %rdi
leaq 0x10f773(%rip), %rsi    # 0x1366e6
callq 0x23300
movq %rax, -0x188(%rbp)
cmpq $0x0, -0x188(%rbp)
je 0x26fad
movq -0x188(%rbp), %rax
movq %rax, -0x190(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0x190(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x27007
jmp 0x26faf
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
movq -0x88(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movb $0x1, 0x10(%rax)
cmpq $0x0, -0x38(%rbp)
je 0x26fe8
movq -0x38(%rbp), %rdi
movq -0xe8(%rbp), %rsi
callq 0x5ce0
movq -0x38(%rbp), %rax
movb $0x1, 0x2d(%rax)
movq $0x0, -0x198(%rbp)
movq -0x78(%rbp), %rdi
callq 0xc0720
movq -0x198(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq
nopw %cs:(%rax,%rax)