// File: /workspace/github_c_makefile_star2_O1/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, 0x10(%rsp)
movq %rcx, %r13
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, 0x8(%rsp)
movabsq $-0x7850996cdf80346a, %r14 # imm = 0x87AF6693207FCB96
leaq 0x160885(%rip), %rax    # 0x1a8dd0
movq (%rax), %rsi
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0xe0431
movq $0x0, 0x10(%r15)
callq 0x4c277
movq %r15, %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %rax, %rcx
callq 0xe0676
movq %rax, %r15
testq %r12, %r12
je 0x4872b
leaq 0xf4134(%rip), %rsi     # 0x13c6bf
movq %rbx, %rdi
xorl %eax, %eax
callq 0xda10
movq %rax, %rbp
testq %rax, %rax
jne 0x48a08
movq %r15, (%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %r14
leaq 0x159efc(%rip), %rax    # 0x1a24b0
movl 0x159ef6(%rip), %ecx    # 0x1a24b0
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 0x48612
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r14, %rdx
je 0x48612
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r14, %rdx
je 0x48612
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r14, %rdx
jne 0x48a24
movq (%rax,%rcx), %r15
testq %r15, %r15
jne 0x48642
movabsq $-0x3dfc7e0a250a30dc, %rdi # imm = 0xC20381F5DAF5CF24
movq %r14, %rsi
callq 0xf3f85
movq %rax, %r15
leaq 0x159e79(%rip), %rdi    # 0x1a24b0
movq %r14, %rsi
movq %rax, %rdx
callq 0x12128c
movq 0x10(%rsp), %rdi
callq *0x10(%r15)
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq (%rsp), %rdx
xorl %ecx, %ecx
callq 0x3dbae
movq %rax, %r14
testq %rax, %rax
je 0x48673
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %r14, %rbp
testq %r14, %r14
jne 0x48a12
movq (%rbx), %r14
leaq 0x161642(%rip), %rax    # 0x1a9cc8
movl (%rax), %ecx
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 0x486e0
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r14, %rdx
je 0x486e0
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r14, %rdx
je 0x486e0
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r14, %rdx
jne 0x48a8b
movq (%rax,%rcx), %r15
testq %r15, %r15
jne 0x48710
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %r14, %rsi
callq 0xf3f85
movq %rax, %r15
leaq 0x1615c3(%rip), %rdi    # 0x1a9cc8
movq %r14, %rsi
movq %rax, %rdx
callq 0x12128c
leaq 0xf1c43(%rip), %rdx     # 0x13a35a
movq %r15, %rdi
movq %rbx, %rsi
callq 0x10aa16
movq (%rsp), %r15
jmp 0x4882d
leaq 0xf3f88(%rip), %rsi     # 0x13c6ba
movq %rbx, %rdi
xorl %eax, %eax
callq 0xda10
movq %rax, %rbp
testq %rax, %rax
jne 0x48a08
movq %r15, (%rsp)
callq 0x4c277
leaq 0x28(%rsp), %r15
movq %r15, %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %rax, %rcx
callq 0xe0676
movq %rax, %r12
callq 0x10060
movabsq $-0x641110359430e9c5, %rdx # imm = 0x9BEEEFCA6BCF163B
movq %r15, %rdi
xorl %esi, %esi
movq %rax, %rcx
callq 0xe0676
movq %rax, %r14
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
movq %rax, %rcx
callq 0x3dbae
movq %rax, %r15
testq %rax, %rax
je 0x487b0
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %r15, %rbp
testq %r15, %r15
je 0x487be
xorl %ecx, %ecx
xorl %eax, %eax
xorl %r12d, %r12d
jmp 0x48821
leaq 0xefb98(%rip), %rsi     # 0x13835d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xda10
movq %rax, %r15
testq %rax, %rax
je 0x487e4
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %r15, %rbp
testq %r15, %r15
jne 0x4881a
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq (%rsp), %rdx
xorl %ecx, %ecx
callq 0x3dbae
movq %rax, %r15
testq %rax, %rax
je 0x48811
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %r15, %rbp
testq %r15, %r15
je 0x48a75
xorl %ecx, %ecx
xorl %eax, %eax
movq %r14, %r13
movq (%rsp), %r15
testb %cl, %cl
je 0x48a12
cmpq $0x0, 0x8(%r13)
je 0x489eb
movabsq $-0x12e90733f18038df, %rcx # imm = 0xED16F8CC0E7FC721
cmpq %rcx, 0x10(%r13)
jne 0x489f4
movq %rax, (%rsp)
movq %r13, %rdi
callq 0x101d1
leaq 0x28(%rsp), %rdi
movabsq $-0x641110359430e9c5, %rdx # imm = 0x9BEEEFCA6BCF163B
xorl %esi, %esi
movq %rax, %rcx
callq 0xe0676
movabsq $-0x2c53c3baa9910217, %rcx # imm = 0xD3AC3C45566EFDE9
movq %rax, 0x18(%rsp)
movq %rcx, 0x10(%rax)
movq 0x10(%rsp), %rax
movq (%rax), %r14
leaq 0x159c1d(%rip), %rax    # 0x1a24b0
movl 0x159c17(%rip), %ecx    # 0x1a24b0
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 0x488f1
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r14, %rdx
je 0x488f1
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r14, %rdx
je 0x488f1
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r14, %rdx
jne 0x48a93
movq (%rax,%rcx), %r13
testq %r13, %r13
jne 0x48921
movabsq $-0x3dfc7e0a250a30dc, %rdi # imm = 0xC20381F5DAF5CF24
movq %r14, %rsi
callq 0xf3f85
movq %rax, %r13
leaq 0x159b9a(%rip), %rdi    # 0x1a24b0
movq %r14, %rsi
movq %rax, %rdx
callq 0x12128c
leaq 0xf3c99(%rip), %rsi     # 0x13c5c1
movq 0x10(%rsp), %rdi
callq *0x20(%r13)
movq %rax, %r14
testq %rax, %rax
je 0x48946
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %r14, %rbp
testq %r14, %r14
jne 0x48a12
cmpb $0x0, (%rsp)
je 0x48a2c
leaq 0x10604d(%rip), %rsi    # 0x14e9ad
movq %rbx, %rdi
xorl %eax, %eax
callq 0xda10
movq %rax, %r14
testq %rax, %rax
je 0x4897f
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %r14, %rbp
testq %r14, %r14
jne 0x48a12
movq %r15, (%rsp)
movq 0x8(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x34cab
movq %rax, %r14
addq $0x60, %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0xd2d4f
testb %al, %al
je 0x48aa7
movq %r15, %rdi
movq %r14, %rsi
callq 0xd2a60
movb $0x1, %r15b
testq %rax, %rax
je 0x48bf4
movq 0x8(%rsp), %rcx
movq 0x48(%rcx), %rcx
movq (%rax), %rax
movq (%rcx,%rax,8), %rax
movq 0x8(%rax), %r13
jmp 0x48c31
leaq 0xf3cd1(%rip), %rsi     # 0x13c6c3
jmp 0x489fb
leaq 0xf3ce9(%rip), %rsi     # 0x13c6e4
movq %rbx, %rdi
xorl %eax, %eax
callq 0xddb2
movq %rax, %rbp
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %rbp, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r15d, %r15d
jmp 0x48616
xorl %r13d, %r13d
leaq 0x10d506(%rip), %rsi    # 0x155f3c
movq %rbx, %rdi
xorl %eax, %eax
callq 0xda10
movq %rax, %r14
testq %rax, %rax
je 0x48a55
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %r14, %rbp
testq %r14, %r14
jne 0x48a12
movq 0x18(%rsp), %rsi
cmpq $0x1, 0x20(%rsi)
jne 0x48a9b
cmpb $0x1, 0x2d(%rsi)
jne 0x48ade
leaq 0xf3cf8(%rip), %rsi     # 0x13c76b
jmp 0x489fb
leaq 0xf18de(%rip), %rsi     # 0x13a35a
movq %rbx, %rdi
callq 0x115a3
movb $0x1, %cl
jmp 0x4881e
xorl %r15d, %r15d
jmp 0x486e4
xorl %r13d, %r13d
jmp 0x488f5
leaq 0xf3ca3(%rip), %rsi     # 0x13c745
jmp 0x489fb
movb $0x1, %r15b
movabsq $0x5e9151f1091c19ba, %rax # imm = 0x5E9151F1091C19BA
cmpq %rax, %r14
je 0x48c2e
movabsq $-0x38096408726e4e99, %rax # imm = 0xC7F69BF78D91B167
cmpq %rax, %r14
jne 0x48bfd
movq 0x8(%rsp), %rax
movq 0x28(%rax), %r13
jmp 0x48c31
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rdx
callq 0x34734
movq %rax, %rbx
testq %rax, %rax
je 0x48b02
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %rbx, %rbp
testq %rbx, %rbx
jne 0x48a12
leaq 0xf3d22(%rip), %rsi     # 0x13c834
movq 0x10(%rsp), %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0x3bd77
movq %rax, %rbx
testq %rax, %rax
je 0x48b36
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %rbx, %rbp
testq %rbx, %rbx
jne 0x48a12
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3a736
leaq 0xf05ee(%rip), %rsi     # 0x139144
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3bd77
movq %rax, %rbx
testq %rax, %rax
je 0x48b75
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %rbx, %rbp
testq %rbx, %rbx
jne 0x48a12
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3a736
leaq 0xf2846(%rip), %rsi     # 0x13b3db
movq %rbx, %rdi
callq 0x34bcc
movq %rax, %rbx
testq %rax, %rax
je 0x48bb2
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %rbx, %rbp
testq %rbx, %rbx
jne 0x48a12
movq 0x8(%rsp), %rax
movq 0x98(%rax), %rax
movq (%rax,%r13,8), %rax
movb $0x1, 0x10(%rax)
cmpq $0x0, 0x20(%rsp)
je 0x48bed
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0xff8e
movb $0x1, 0x2d(%rbx)
xorl %ebp, %ebp
jmp 0x48a08
movq $-0x1, %r13
jmp 0x48c31
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x3417e
leaq 0xf3af9(%rip), %rsi     # 0x13c70a
xorl %r15d, %r15d
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xddb2
movq %rax, %rbp
leaq 0x28(%rsp), %rdi
callq 0xe0b30
xorl %r13d, %r13d
testb %r15b, %r15b
movq (%rsp), %r15
je 0x48a12
jmp 0x48a2f