// File: /workspace/github_c_makefile_star2_O3/johsteffens[P]beth/xoico/src/xoico.xo.c
// Function: xoico_che_s_trans_builtin_t_scope
er_t xoico_che_s_trans_builtin_t_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:271:1
    BLM_INIT_LEVEL(0);
    bl_t has_arg = false;
    bl_t closing_bracket = true;
    
    sz_t level = 0;
    
    xoico_che_result_arr_s* result_type_expr = ((xoico_che_result_arr_s*)BLM_LEVEL_T_PUSH(0,xoico_che_result_arr_s,xoico_che_result_arr_s_create()));
    
    if( result_expr ) // member call
    {
        BLM_TRY(x_source_parse_fa(source," ( " ))
        xoico_che_result_a_clear(result_out);
        BLM_TRY(xoico_che_s_trans_expression(o,source,((xoico_che_result*)( result_type_expr)), NULL ))
        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));
    
        BLM_TRY(x_source_parse_fa(source," , " ))
        BLM_TRY(xoico_che_s_trans_expression(o,source,((xoico_che_result*)( result_type_expr)), NULL ))
    
        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 ))
    
    BLM_TRY(xoico_che_result_push_fa(result_out,")BLM_LEVEL_TV_PUSH(#<sz_t>,", level ))
    xoico_che_result_a_push_result_c(result_out,((const xoico_che_result*)(result_type_expr )));
    BLM_TRY(xoico_che_result_push_fa(result_out,"," ))
    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, 0x20(%rsp)
movq %r8, %r15
movq %rcx, %rbx
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, 0x8(%rsp)
movabsq $-0x7850996cdf80346a, %r14 # imm = 0x87AF6693207FCB96
leaq 0x15824b(%rip), %rax    # 0x19bdd0
movq (%rax), %rsi
leaq 0x28(%rsp), %rbp
movq %rbp, %rdi
callq 0xd6675
movq $0x0, 0x10(%rbp)
callq 0x46f7e
movq %rbp, %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %rax, %rcx
callq 0xd68a8
movq %rax, 0x18(%rsp)
testq %r13, %r13
je 0x43eb9
leaq 0xedaf8(%rip), %rsi     # 0x1316bf
movq %r12, %rdi
xorl %eax, %eax
callq 0xda80
testq %rax, %rax
jne 0x43f85
movq (%r15), %rbp
leaq 0x1518cc(%rip), %rax    # 0x1954b0
movl 0x1518c6(%rip), %ecx    # 0x1954b0
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x20(%rax,%rcx,8), %rdx
movq 0x18(%rax,%rcx,8), %rcx
andq %rbp, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %rbp, %rdx
je 0x43c3e
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbp, %rdx
je 0x43c3e
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbp, %rdx
je 0x43c3e
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbp, %rdx
jne 0x43c47
movq (%rax,%rcx), %r14
testq %r14, %r14
jne 0x43c6e
movabsq $-0x3dfc7e0a250a30dc, %rdi # imm = 0xC20381F5DAF5CF24
movq %rbp, %rsi
callq 0xe9bc5
movq %rax, %r14
leaq 0x15184d(%rip), %rdi    # 0x1954b0
movq %rbp, %rsi
movq %rax, %rdx
callq 0x115fac
movq %r15, %rdi
callq *0x10(%r14)
movq 0x8(%rsp), %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
xorl %ecx, %ecx
callq 0x3a94e
testq %rax, %rax
jne 0x43f85
movq (%r12), %rbp
leaq 0x15902b(%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 %rbp, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %rbp, %rdx
je 0x43cf3
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbp, %rdx
je 0x43cf3
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbp, %rdx
je 0x43cf3
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbp, %rdx
jne 0x43cfc
movq (%rax,%rcx), %r14
testq %r14, %r14
jne 0x43d23
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %rbp, %rsi
callq 0xe9bc5
movq %rax, %r14
leaq 0x158fb0(%rip), %rdi    # 0x19ccc8
movq %rbp, %rsi
movq %rax, %rdx
callq 0x115fac
leaq 0xeb630(%rip), %rdx     # 0x12f35a
movq %r14, %rdi
movq %r12, %rsi
callq 0xffe2b
cmpq $0x0, 0x8(%rbx)
je 0x43f6b
movabsq $-0x12e90733f18038df, %rcx # imm = 0xED16F8CC0E7FC721
cmpq %rcx, 0x10(%rbx)
jne 0x43f74
movb %al, 0x10(%rsp)
movq %rbx, %rdi
callq 0x10128
leaq 0x28(%rsp), %rdi
movabsq $-0x641110359430e9c5, %rdx # imm = 0x9BEEEFCA6BCF163B
xorl %esi, %esi
movq %rax, %rcx
callq 0xd68a8
movq %rax, %rbx
movabsq $-0x2c53c3baa9910217, %rax # imm = 0xD3AC3C45566EFDE9
movq %rax, 0x10(%rbx)
movq (%r15), %rbp
leaq 0x15171c(%rip), %rax    # 0x1954b0
movl 0x151716(%rip), %ecx    # 0x1954b0
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x20(%rax,%rcx,8), %rdx
movq 0x18(%rax,%rcx,8), %rcx
andq %rbp, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %rbp, %rdx
je 0x43dee
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbp, %rdx
je 0x43dee
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbp, %rdx
je 0x43dee
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbp, %rdx
jne 0x43df7
movq (%rax,%rcx), %r14
testq %r14, %r14
jne 0x43e1e
movabsq $-0x3dfc7e0a250a30dc, %rdi # imm = 0xC20381F5DAF5CF24
movq %rbp, %rsi
callq 0xe9bc5
movq %rax, %r14
leaq 0x15169d(%rip), %rdi    # 0x1954b0
movq %rbp, %rsi
movq %rax, %rdx
callq 0x115fac
leaq 0xed79c(%rip), %rsi     # 0x1315c1
movq %r15, %rdi
callq *0x20(%r14)
testq %rax, %rax
jne 0x43f85
cmpb $0x0, 0x10(%rsp)
je 0x43fd9
leaq 0xffba6(%rip), %rsi     # 0x1439ed
movq %r12, %rdi
xorl %eax, %eax
callq 0xda80
testq %rax, %rax
movq 0x8(%rsp), %r14
jne 0x43f85
movq %r14, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x329d8
movq %r14, %rcx
movq %rax, %r14
leaq 0x60(%rcx), %rbp
movq %rbp, %rdi
movq %rax, %rsi
callq 0xc8bf8
testb %al, %al
je 0x43fa4
movq %rbp, %rdi
movq %r14, %rsi
callq 0xc883f
testq %rax, %rax
je 0x440df
movq 0x8(%rsp), %r14
movq 0x48(%r14), %rcx
movq (%rax), %rax
movq (%rcx,%rax,8), %rax
addq $0x8, %rax
jmp 0x43fcf
leaq 0xed7fa(%rip), %rsi     # 0x1316ba
movq %r12, %rdi
xorl %eax, %eax
callq 0xda80
testq %rax, %rax
jne 0x43f85
callq 0x46f7e
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
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, %rbx
movq 0x8(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0x3a94e
testq %rax, %rax
jne 0x43f85
leaq 0xe942c(%rip), %rsi     # 0x12d35d
movq %r12, %rdi
xorl %eax, %eax
callq 0xda80
testq %rax, %rax
jne 0x43f85
movq %r14, %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
xorl %ecx, %ecx
callq 0x3a94e
testq %rax, %rax
jne 0x43f85
leaq 0xeb3fc(%rip), %rsi     # 0x12f35a
movq %r12, %rdi
callq 0x1130c
jmp 0x43d35
leaq 0xed751(%rip), %rsi     # 0x1316c3
jmp 0x43f7b
leaq 0xed769(%rip), %rsi     # 0x1316e4
movq %r12, %rdi
xorl %eax, %eax
callq 0xde10
movq %rax, %rbp
leaq 0x28(%rsp), %rdi
callq 0xd6d2c
movq %rbp, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movabsq $0x5e9151f1091c19ba, %rax # imm = 0x5E9151F1091C19BA
cmpq %rax, %r14
je 0x43fd9
movabsq $-0x38096408726e4e99, %rax # imm = 0xC7F69BF78D91B167
cmpq %rax, %r14
jne 0x440ed
movq 0x8(%rsp), %r14
leaq 0x28(%r14), %rax
movq (%rax), %rax
movq %rax, 0x10(%rsp)
jmp 0x43fe7
movq $0x0, 0x10(%rsp)
movq 0x8(%rsp), %r14
leaq 0x106f76(%rip), %rsi    # 0x14af64
movq %r12, %rdi
xorl %eax, %eax
callq 0xda80
testq %rax, %rax
jne 0x43f85
cmpq $0x1, 0x20(%rbx)
jne 0x44016
cmpb $0x1, 0x2d(%rbx)
jne 0x44022
leaq 0xed75a(%rip), %rsi     # 0x13176b
jmp 0x43f7b
leaq 0xed728(%rip), %rsi     # 0x131745
jmp 0x43f7b
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x32522
testq %rax, %rax
jne 0x43f85
leaq 0xed7f4(%rip), %rsi     # 0x131834
movq %r15, %rdi
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x38f32
testq %rax, %rax
jne 0x43f85
movq %r15, %rdi
movq 0x18(%rsp), %rsi
callq 0x37b5f
leaq 0xea0d8(%rip), %rsi     # 0x12e144
movq %r15, %rdi
xorl %eax, %eax
callq 0x38f32
testq %rax, %rax
jne 0x43f85
movq %r15, %rdi
movq %r13, %rsi
callq 0x37b5f
leaq 0xec34a(%rip), %rsi     # 0x1303db
movq %r15, %rdi
callq 0x328fe
testq %rax, %rax
jne 0x43f85
movq 0x8(%rsp), %rax
movq 0x98(%rax), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movb $0x1, 0x10(%rax)
cmpq $0x0, 0x20(%rsp)
je 0x440d8
movq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0xfef3
movb $0x1, 0x2d(%r14)
xorl %ebp, %ebp
jmp 0x43f88
movq $-0x1, 0x10(%rsp)
jmp 0x43fe2
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x31f9d
leaq 0xed609(%rip), %rsi     # 0x13170a
movq %r12, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde10
jmp 0x43f85