// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, %r15
movq %r8, 0x8(%rsp)
movq %rcx, %rbp
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, (%rsp)
leaq 0x16272c(%rip), %rax    # 0x19bdd0
movq (%rax), %rsi
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0xd6675
movq $0x0, 0x10(%rbx)
testq %r13, %r13
je 0x39820
movq %r15, 0x10(%rsp)
movq (%r12), %rbx
leaq 0x1635f3(%rip), %r15    # 0x19ccc8
movl (%r15), %eax
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%r15,%rax,8), %rcx
movq 0x18(%r15,%rax,8), %rdx
andq %rbx, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %rbx, %rdx
je 0x3972b
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbx, %rdx
je 0x3972b
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbx, %rdx
je 0x3972b
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbx, %rdx
jne 0x39734
movq (%rax,%rcx), %r14
testq %r14, %r14
jne 0x3975b
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %rbx, %rsi
callq 0xe9bc5
movq %rax, %r14
leaq 0x163578(%rip), %rdi    # 0x19ccc8
movq %rbx, %rsi
movq %rax, %rdx
callq 0x115fac
leaq 0xf3f7c(%rip), %rdx     # 0x12d6de
movq %r14, %rdi
movq %r12, %rsi
callq 0xffe2b
testb %al, %al
je 0x39948
movq (%r12), %rbx
movl (%r15), %eax
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%r15,%rax,8), %rcx
movq 0x18(%r15,%rax,8), %rdx
andq %rbx, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %rbx, %rdx
je 0x397cf
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbx, %rdx
je 0x397cf
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbx, %rdx
je 0x397cf
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbx, %rdx
jne 0x397d8
movq (%rax,%rcx), %r14
testq %r14, %r14
jne 0x397ff
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %rbx, %rsi
callq 0xe9bc5
movq %rax, %r14
leaq 0x1634d4(%rip), %rdi    # 0x19ccc8
movq %rbx, %rsi
movq %rax, %rdx
callq 0x115fac
leaq 0xf3ed8(%rip), %rdx     # 0x12d6de
movq %r14, %rdi
movq %r12, %rsi
callq 0xffe2b
testb %al, %al
je 0x39aad
xorl %ebx, %ebx
jmp 0x39ae5
leaq 0xf7e93(%rip), %rsi     # 0x1316ba
movq %r12, %rdi
xorl %eax, %eax
callq 0xda80
testq %rax, %rax
jne 0x39c80
callq 0x46f7e
leaq 0x28(%rsp), %rbx
movabsq $-0x7850996cdf80346a, %rdx # imm = 0x87AF6693207FCB96
movq %rbx, %rdi
xorl %esi, %esi
movq %rax, %rcx
callq 0xd68a8
movq %rax, %r13
callq 0xffc0
movabsq $-0x641110359430e9c5, %rdx # imm = 0x9BEEEFCA6BCF163B
movq %rbx, %rdi
xorl %esi, %esi
movq %rax, %rcx
callq 0xd68a8
movq %rax, %rbp
movq (%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0x3a94e
testq %rax, %rax
jne 0x39c80
movq %r15, 0x10(%rsp)
movq (%r12), %rbx
leaq 0x163420(%rip), %rax    # 0x19ccc8
movl (%rax), %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x20(%rax,%rcx,8), %rdx
movq 0x18(%rax,%rcx,8), %rcx
andq %rbx, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %rbx, %rdx
je 0x398fe
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbx, %rdx
je 0x398fe
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbx, %rdx
je 0x398fe
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbx, %rdx
jne 0x39907
movq (%rax,%rcx), %r14
testq %r14, %r14
jne 0x3992e
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %rbx, %rsi
callq 0xe9bc5
movq %rax, %r14
leaq 0x1633a5(%rip), %rdi    # 0x19ccc8
movq %rbx, %rsi
movq %rax, %rdx
callq 0x115fac
leaq 0xf5a25(%rip), %rdx     # 0x12f35a
movq %r14, %rdi
movq %r12, %rsi
callq 0xffe2b
movl %eax, %r15d
jmp 0x39aa7
leaq 0xf7d70(%rip), %rsi     # 0x1316bf
movq %r12, %rdi
xorl %eax, %eax
callq 0xda80
testq %rax, %rax
jne 0x39c80
movq 0x8(%rsp), %rdi
movq (%rdi), %rbx
leaq 0x15bb3f(%rip), %rax    # 0x1954b0
movl 0x15bb39(%rip), %ecx    # 0x1954b0
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x20(%rax,%rcx,8), %rdx
movq 0x18(%rax,%rcx,8), %rcx
andq %rbx, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %rbx, %rdx
je 0x399cb
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbx, %rdx
je 0x399cb
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbx, %rdx
je 0x399cb
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbx, %rdx
jne 0x399d4
movq (%rax,%rcx), %r14
testq %r14, %r14
jne 0x39a00
movabsq $-0x3dfc7e0a250a30dc, %rdi # imm = 0xC20381F5DAF5CF24
movq %rbx, %rsi
callq 0xe9bc5
movq %rax, %r14
leaq 0x15bac0(%rip), %rdi    # 0x1954b0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x115fac
movq 0x8(%rsp), %rdi
callq *0x10(%r14)
movq (%r12), %rbx
movl (%r15), %eax
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%r15,%rax,8), %rcx
movq 0x18(%r15,%rax,8), %rdx
andq %rbx, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %rbx, %rdx
je 0x39a5e
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbx, %rdx
je 0x39a5e
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbx, %rdx
je 0x39a5e
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbx, %rdx
jne 0x39a67
movq (%rax,%rcx), %r14
testq %r14, %r14
jne 0x39a8e
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %rbx, %rsi
callq 0xe9bc5
movq %rax, %r14
leaq 0x163245(%rip), %rdi    # 0x19ccc8
movq %rbx, %rsi
movq %rax, %rdx
callq 0x115fac
leaq 0xf3a5c(%rip), %rdx     # 0x12d4f1
movq %r14, %rdi
movq %r12, %rsi
callq 0xffe2b
movl %eax, %r15d
xorb $0x1, %r15b
movb $0x1, %cl
xorl %ebx, %ebx
jmp 0x39aea
movq (%rsp), %rcx
movq 0x28(%rcx), %rbx
testq %rbx, %rbx
setle %al
orb 0xf(%rcx), %al
jne 0x39ae5
movq 0x98(%rcx), %rax
movq 0xa0(%rcx), %rcx
movq -0x8(%rax,%rcx,8), %rax
cmpb $0x1, 0x12(%rax)
jne 0x39ae5
leaq 0xf7b43(%rip), %rsi     # 0x131623
jmp 0x39c76
xorl %ecx, %ecx
xorl %r15d, %r15d
cmpq $0x0, 0x8(%rbp)
je 0x39c66
movabsq $-0x12e90733f18038df, %rax # imm = 0xED16F8CC0E7FC721
cmpq %rax, 0x10(%rbp)
jne 0x39c6f
movq %rcx, 0x20(%rsp)
movq %rbp, %rdi
callq 0x10128
leaq 0x28(%rsp), %rdi
movabsq $-0x641110359430e9c5, %rdx # imm = 0x9BEEEFCA6BCF163B
xorl %esi, %esi
movq %rax, %rcx
callq 0xd68a8
movabsq $-0x2c53c3baa9910217, %rcx # imm = 0xD3AC3C45566EFDE9
movq %rax, 0x18(%rsp)
movq %rcx, 0x10(%rax)
movq 0x8(%rsp), %rdi
movq (%rdi), %r14
leaq 0x15b95f(%rip), %rax    # 0x1954b0
movl 0x15b959(%rip), %ecx    # 0x1954b0
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x20(%rax,%rcx,8), %rdx
movq 0x18(%rax,%rcx,8), %rcx
andq %r14, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %r14, %rdx
je 0x39bab
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r14, %rdx
je 0x39bab
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r14, %rdx
je 0x39bab
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r14, %rdx
jne 0x39bb4
movq (%rax,%rcx), %rbp
testq %rbp, %rbp
jne 0x39be0
movabsq $-0x3dfc7e0a250a30dc, %rdi # imm = 0xC20381F5DAF5CF24
movq %r14, %rsi
callq 0xe9bc5
movq %rax, %rbp
leaq 0x15b8e0(%rip), %rdi    # 0x1954b0
movq %r14, %rsi
movq %rax, %rdx
callq 0x115fac
movq 0x8(%rsp), %rdi
leaq 0xf79da(%rip), %rsi     # 0x1315c1
callq *0x20(%rbp)
testq %rax, %rax
jne 0x39c80
testb %r15b, %r15b
movq 0x10(%rsp), %r15
je 0x39cd9
leaq 0x109de5(%rip), %rsi    # 0x1439ed
movq %r12, %rdi
xorl %eax, %eax
callq 0xda80
testq %rax, %rax
jne 0x39c80
movq (%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x329d8
movq %rax, %rbx
addq $0x60, %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0xc8bf8
testb %al, %al
je 0x39c9f
movq %r14, %rdi
movq %rbx, %rsi
callq 0xc883f
testq %rax, %rax
je 0x39cce
movq (%rsp), %rcx
movq 0x48(%rcx), %rcx
movq (%rax), %rax
movq (%rcx,%rax,8), %rax
addq $0x8, %rax
jmp 0x39cc9
leaq 0xf7a56(%rip), %rsi     # 0x1316c3
jmp 0x39c76
leaq 0xf7a6e(%rip), %rsi     # 0x1316e4
movq %r12, %rdi
xorl %eax, %eax
callq 0xde10
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0xd6d2c
movq %r14, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movabsq $0x5e9151f1091c19ba, %rax # imm = 0x5E9151F1091C19BA
cmpq %rax, %rbx
je 0x39cd7
movabsq $-0x38096408726e4e99, %rax # imm = 0xC7F69BF78D91B167
cmpq %rax, %rbx
jne 0x39d73
movq (%rsp), %rax
addq $0x28, %rax
movq (%rax), %rbx
jmp 0x39cd9
movq $-0x1, %rbx
jmp 0x39cd9
xorl %ebx, %ebx
cmpb $0x0, 0x20(%rsp)
je 0x39cf6
leaq 0x11127d(%rip), %rsi    # 0x14af64
movq %r12, %rdi
xorl %eax, %eax
callq 0xda80
testq %rax, %rax
jne 0x39c80
movq 0x18(%rsp), %r14
cmpq $0x1, 0x20(%r14)
jne 0x39d15
cmpb $0x1, 0x2d(%r14)
jne 0x39d21
leaq 0xf7a5b(%rip), %rsi     # 0x13176b
jmp 0x39c76
leaq 0xf7a29(%rip), %rsi     # 0x131745
jmp 0x39c76
movq %r15, 0x10(%rsp)
movq (%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
movq 0x8(%rsp), %rdx
callq 0x32522
testq %rax, %rax
jne 0x39c80
movq %r14, %r15
movq 0x8(%r14), %rsi
movq 0x18(%rbp), %rdi
addq $0x50, %rdi
callq 0xca9a0
testb %al, %al
je 0x39d98
cmpb $0x1, 0x2b(%r15)
movq 0x8(%rsp), %rdi
jne 0x39dc2
leaq 0xf7a1e(%rip), %rsi     # 0x13178c
jmp 0x39c76
movq (%rsp), %rdi
movq %rbx, %rsi
callq 0x31f9d
leaq 0xf7984(%rip), %rsi     # 0x13170a
movq %r12, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde10
jmp 0x39c80
movq 0x8(%r15), %rsi
movq %rbp, %rdi
callq 0x31f9d
leaq 0xf7a66(%rip), %rsi     # 0x131811
movq 0x8(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x38f32
jmp 0x39dd6
leaq 0xf7a2d(%rip), %rsi     # 0x1317f6
movq %rbx, %rdx
xorl %eax, %eax
movq %rdi, %r12
callq 0x38f32
testq %rax, %rax
jne 0x39c80
movq %r12, %rdi
movq %r13, %rsi
callq 0x37b5f
leaq 0xf65ea(%rip), %rsi     # 0x1303db
movq %r12, %rdi
callq 0x328fe
testq %rax, %rax
jne 0x39c80
movq (%rsp), %rax
movq 0x98(%rax), %rax
movq (%rax,%rbx,8), %rax
movb $0x1, 0x10(%rax)
movq 0x10(%rsp), %rbx
testq %rbx, %rbx
je 0x39e30
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0xfef3
movb $0x1, 0x2d(%rbx)
xorl %r14d, %r14d
jmp 0x39c83