// File: /workspace/github_c_makefile_star2_O3/johsteffens[P]beth/xoico/src/xoico.xo.c
// Function: xoico_signature_s_parse
er_t xoico_signature_s_parse( xoico_signature_s* o, const xoico_host* host, x_source* source )
{
    // xoico_signature.x:141:1
    BLM_INIT_LEVEL(0);
    xoico_compiler_s* compiler = xoico_host_a_compiler(host);
    st_s* name_buf = ((st_s*)BLM_LEVEL_T_PUSH(0,st_s,st_s_create()));
    
    if( x_source_parse_bl(source," #?'extending'" ) )
    {
        tp_t tp_name = 0;
        BLM_TRY(xoico_host_a_parse_name_tp(host,source, (&(tp_name)) ))
        const xoico_signature_s* signature = xoico_compiler_s_get_signature(compiler,tp_name );
        if( !signature ) BLM_RETURNV(er_t, x_source_parse_error_fa(source,"Could not find predefined signature '#<sc_t>'.", xoico_host_a_nameof(host,tp_name ) ))
        xoico_signature_s_copy(o,signature );
        x_source_point_s_setup_from_source(&(o->source_point),source );
        BLM_TRY(x_source_parse_fa(source," #name", name_buf ))  // empty name is allowed
        o->name = xoico_compiler_s_entypeof(compiler,name_buf->sc );
        BLM_TRY(x_source_parse_fa(source," (" ))
        BLM_TRY(xoico_args_s_append(&(o->args),host, source ))
        BLM_TRY(x_source_parse_fa(source," )" ))
    }
    else
    {
        x_source_point_s_setup_from_source(&(o->source_point),source );
        BLM_TRY(xoico_typespec_s_parse(&(o->typespec_ret),host, source ))
        o->typespec_ret.flag_addressable = false;
    
        // get name
        BLM_TRY(x_source_parse_fa(source," #name", name_buf ))
        o->name = xoico_compiler_s_entypeof(compiler,name_buf->sc );
    
        BLM_TRY(x_source_parse_fa(source," (" ))
    
        if( !x_source_parse_bl(source," #=?')'" ) )
        {BLM_INIT_LEVEL(2);
            xoico_arg_s* arg = ((xoico_arg_s*)BLM_LEVEL_T_PUSH(2,xoico_arg_s,xoico_arg_s_create()));
            BLM_TRY(xoico_arg_s_parse(arg,host, source ))
            if( !x_source_parse_bl(source," #=?')'" ) ) BLM_TRY(x_source_parse_fa(source,", " ))
            if( arg->name == TYPEOF_o )
            {
                xoico_arg_s_attach( &(o->arg_o ),  ((xoico_arg_s*)bcore_fork(arg)));
                BLM_TRY(xoico_args_s_parse(&(o->args),host, source ))
            }
            else
            {
                x_array_push_d(((x_array*)(&(o->args))),((x_inst*)(((xoico_arg_s*)bcore_fork(arg)) )));
                BLM_TRY(xoico_args_s_append(&(o->args),host, source ))
            }
        BLM_DOWN();}
        else
        {
            BLM_TRY(xoico_args_s_parse(&(o->args),host, source ))
        }
    
        BLM_TRY(x_source_parse_fa(source," )" ))
    }
    
    /// if return type is a name in the argument list, copy argument typespec to return typespec
    const xoico_arg_s* ret_arg = ( o->typespec_ret.indirection == 0 ) ? xoico_signature_s_get_arg_by_name(o,o->typespec_ret.type ) : NULL;
    
    if( ret_arg )
    {
        if( o->typespec_ret.access_class != 0  || o->typespec_ret.transient || o->typespec_ret.indirection != 0 )
        {
            BLM_RETURNV(er_t, x_source_parse_error_fa(source,"Return typespec: Argument name used as type." ))
        }
        xoico_typespec_s_copy(&(o->typespec_ret),&(ret_arg->typespec ));
        BCORE_PASS_CREATE(xoico_typespec_transient_s,o->typespec_ret.transient)->cast_to_var = ret_arg->name;
        xoico_arg_s_attach( &(o->direct_return_arg ),  ((xoico_arg_s*)bcore_fork(((xoico_arg_s*)(ret_arg)))));
    }
    
    BLM_TRY(xoico_signature_s_set_global_name(o,host ))
    
    BLM_RETURNV(er_t, 0)
}

er_t xoico_signature_s_expand_declaration( const xoico_signature_s* o, const xoico_host* host, sc_t sc_func_global_name, sz_t indent, x_sink* sink )
{
    // xoico_signature.x:217:1
    
    BLM_TRY(xoico_signature_s_expand_ret(o,host, sink ))
    x_sink_push_fa(sink," #<sc_t>( ", sc_func_global_name );
    
    if( o->arg_o )
    {
        BLM_TRY(xoico_arg_s_expand(o->arg_o,host, sink ))
        BLM_TRY(xoico_args_s_expand(&(o->args),host, false, sink ))
        x_sink_push_fa(sink," )" );
    }
    else
    {
        if( o->args.size > 0 )
        {
            BLM_TRY(xoico_args_s_expand(&(o->args),host, true, sink ))
        }
        else
        {
            x_sink_push_fa(sink,"void" );
        }
        x_sink_push_fa(sink," )" );
    }
    return  0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, 0x8(%rsp)
leaq 0x186e83(%rip), %rax    # 0x19bdd0
movq (%rax), %rsi
leaq 0x28(%rsp), %r12
movq %r12, %rdi
callq 0xd6675
movq $0x0, 0x10(%r12)
movq (%rbx), %r12
leaq 0x17d730(%rip), %r15    # 0x1926a0
movl 0x17d72a(%rip), %eax    # 0x1926a0
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%r15,%rax,8), %rcx
movq 0x18(%r15,%rax,8), %rdx
andq %r12, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %r12, %rdx
je 0x14fc9
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r12, %rdx
je 0x14fc9
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r12, %rdx
je 0x14fc9
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r12, %rdx
jne 0x14fd2
movq (%rax,%rcx), %r13
testq %r13, %r13
jne 0x14ff9
movabsq $-0x1e682f89ce03d7c8, %rdi # imm = 0xE197D07631FC2838
movq %r12, %rsi
callq 0xe9bc5
movq %rax, %r13
leaq 0x17d6b2(%rip), %rdi    # 0x1926a0
movq %r12, %rsi
movq %rax, %rdx
callq 0x115fac
movq %rbx, %rdi
callq *0x20(%r13)
movq %rax, 0x10(%rsp)
xorl %eax, %eax
callq 0x109c82
leaq 0x28(%rsp), %rdi
movabsq $-0x503db0e6e1c2e704, %rdx # imm = 0xAFC24F191E3D18FC
xorl %esi, %esi
movq %rax, %rcx
callq 0xd68a8
movq %rax, 0x18(%rsp)
movq (%r14), %rbp
leaq 0x187c94(%rip), %r12    # 0x19ccc8
movl (%r12), %eax
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%r12,%rax,8), %rcx
movq 0x18(%r12,%rax,8), %rdx
andq %rbp, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %rbp, %rdx
je 0x1508b
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbp, %rdx
je 0x1508b
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbp, %rdx
je 0x1508b
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbp, %rdx
jne 0x15094
movq (%rax,%rcx), %r13
testq %r13, %r13
jne 0x150bb
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %rbp, %rsi
callq 0xe9bc5
movq %rax, %r13
leaq 0x187c18(%rip), %rdi    # 0x19ccc8
movq %rbp, %rsi
movq %rax, %rdx
callq 0x115fac
leaq 0x1183ed(%rip), %rdx    # 0x12d4af
movq %r13, %rdi
movq %r14, %rsi
callq 0xffe2b
testb %al, %al
je 0x152ca
movq $0x0, 0x58(%rsp)
movq (%rbx), %rbp
movl 0x17d5b9(%rip), %eax    # 0x1926a0
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%r15,%rax,8), %rcx
movq 0x18(%r15,%rax,8), %rdx
andq %rbp, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %rbp, %rdx
je 0x1513a
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbp, %rdx
je 0x1513a
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbp, %rdx
je 0x1513a
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbp, %rdx
jne 0x15143
movq (%rax,%rcx), %r13
testq %r13, %r13
jne 0x1516a
movabsq $-0x1e682f89ce03d7c8, %rdi # imm = 0xE197D07631FC2838
movq %rbp, %rsi
callq 0xe9bc5
movq %rax, %r13
leaq 0x17d541(%rip), %rdi    # 0x1926a0
movq %rbp, %rsi
movq %rax, %rdx
callq 0x115fac
leaq 0x58(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq *0x18(%r13)
testq %rax, %rax
jne 0x155a3
movq 0x58(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0x15785
testq %rax, %rax
je 0x154f4
movq 0x8(%rsp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x14396
leaq 0x88(%r15), %r13
movq %r14, %rdi
callq 0xbe7e4
movq %r13, %rdi
movq %rax, %rsi
callq 0x242ed
movq (%r14), %rbp
movl (%r12), %eax
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%r12,%rax,8), %rcx
movq 0x18(%r12,%rax,8), %rdx
andq %rbp, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %rbp, %rdx
je 0x1521e
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbp, %rdx
je 0x1521e
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbp, %rdx
je 0x1521e
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbp, %rdx
jne 0x15227
movq (%rax,%rcx), %r13
testq %r13, %r13
jne 0x1524e
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %rbp, %rsi
callq 0xe9bc5
movq %rax, %r13
leaq 0x187a85(%rip), %rdi    # 0x19ccc8
movq %rbp, %rsi
movq %rax, %rdx
callq 0x115fac
movq %r13, %rdi
movq %r14, %rsi
callq 0xffe72
movq %rax, 0x90(%r15)
leaq 0x12f02c(%rip), %rsi    # 0x144293
movq %r14, %rdi
movq 0x18(%rsp), %r12
movq %r12, %rdx
xorl %eax, %eax
callq 0xda80
testq %rax, %rax
jne 0x155a3
movq 0x8(%r12), %rsi
movq 0x10(%rsp), %rdi
addq $0x140, %rdi            # imm = 0x140
callq 0xd3d8e
movq %rax, 0x8(%r15)
leaq 0x11824a(%rip), %rsi    # 0x12d4ed
movq %r14, %rdi
xorl %eax, %eax
callq 0xda80
testq %rax, %rax
jne 0x155a3
leaq 0x58(%r15), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x13cf1
jmp 0x154aa
movq 0x8(%rsp), %r15
leaq 0x88(%r15), %r13
movq %r14, %rdi
callq 0xbe7e4
movq %r13, %rdi
movq %rax, %rsi
callq 0x242ed
movq (%r14), %rbp
movl (%r12), %eax
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%r12,%rax,8), %rcx
movq 0x18(%r12,%rax,8), %rdx
andq %rbp, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %rbp, %rdx
je 0x15343
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbp, %rdx
je 0x15343
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbp, %rdx
je 0x15343
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbp, %rdx
jne 0x1534c
movq (%rax,%rcx), %r13
testq %r13, %r13
jne 0x15373
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %rbp, %rsi
callq 0xe9bc5
movq %rax, %r13
leaq 0x187960(%rip), %rdi    # 0x19ccc8
movq %rbp, %rsi
movq %rax, %rdx
callq 0x115fac
movq %r13, %rdi
movq %r14, %rsi
callq 0xffe72
movq %rax, 0x90(%r15)
leaq 0x20(%r15), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x10262
testq %rax, %rax
jne 0x155a3
movb $0x0, 0x4e(%r15)
leaq 0x12eeea(%rip), %rsi    # 0x144293
movq %r14, %rdi
movq 0x18(%rsp), %r13
movq %r13, %rdx
xorl %eax, %eax
callq 0xda80
testq %rax, %rax
jne 0x155a3
movq 0x8(%r13), %rsi
movq 0x10(%rsp), %rdi
addq $0x140, %rdi            # imm = 0x140
callq 0xd3d8e
movq %rax, 0x8(%r15)
leaq 0x118109(%rip), %rsi    # 0x12d4ed
movq %r14, %rdi
xorl %eax, %eax
callq 0xda80
testq %rax, %rax
jne 0x155a3
movq (%r14), %rbp
movl (%r12), %eax
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%r12,%rax,8), %rcx
movq 0x18(%r12,%rax,8), %rdx
andq %rbp, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %rbp, %rdx
je 0x15451
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbp, %rdx
je 0x15451
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbp, %rdx
je 0x15451
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbp, %rdx
jne 0x1545a
movq (%rax,%rcx), %r13
testq %r13, %r13
jne 0x15481
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %rbp, %rsi
callq 0xe9bc5
movq %rax, %r13
leaq 0x187852(%rip), %rdi    # 0x19ccc8
movq %rbp, %rsi
movq %rax, %rdx
callq 0x115fac
leaq 0x118068(%rip), %rdx    # 0x12d4f0
movq %r13, %rdi
movq %r14, %rsi
callq 0xffe2b
testb %al, %al
je 0x155c5
leaq 0x58(%r15), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x157c7
testq %rax, %rax
jne 0x155a3
leaq 0x135aaa(%rip), %rsi    # 0x14af64
movq %r14, %rdi
xorl %eax, %eax
callq 0xda80
testq %rax, %rax
jne 0x155a3
cmpq $0x0, 0x40(%r15)
je 0x1568d
movq %r15, %rdi
movq %rbx, %rsi
callq 0x14c31
leaq 0x28(%rsp), %rdi
callq 0xd6d2c
xorl %ebp, %ebp
jmp 0x155b0
movq 0x58(%rsp), %rbp
movq (%rbx), %r12
movl 0x17d19e(%rip), %eax    # 0x1926a0
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%r15,%rax,8), %rcx
movq 0x18(%r15,%rax,8), %rdx
andq %r12, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %r12, %rdx
je 0x15555
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r12, %rdx
je 0x15555
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r12, %rdx
je 0x15555
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r12, %rdx
jne 0x1555e
movq (%rax,%rcx), %r13
testq %r13, %r13
jne 0x15585
movabsq $-0x1e682f89ce03d7c8, %rdi # imm = 0xE197D07631FC2838
movq %r12, %rsi
callq 0xe9bc5
movq %rax, %r13
leaq 0x17d126(%rip), %rdi    # 0x1926a0
movq %r12, %rsi
movq %rax, %rdx
callq 0x115fac
movq %rbx, %rdi
movq %rbp, %rsi
callq *0x48(%r13)
leaq 0x117f28(%rip), %rsi    # 0x12d4be
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde10
movq %rax, %rbp
leaq 0x28(%rsp), %rdi
callq 0xd6d2c
movq %rbp, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x58(%rsp), %r12
movq %r12, 0x20(%rsp)
leaq 0x28(%rsp), %rsi
movq %r12, %rdi
callq 0xd6675
movq $0x2, 0x10(%r12)
callq 0x12dab
movabsq $-0x21883bf5398e4338, %rdx # imm = 0xDE77C40AC671BCC8
movl $0x2, %esi
movq %r12, %rdi
movq %rax, %rcx
callq 0xd68a8
movq %rax, %r12
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x12fd2
testq %rax, %rax
jne 0x156f4
leaq 0x117ecb(%rip), %rsi    # 0x12d4f0
movq %r14, %rdi
callq 0x1130c
testb %al, %al
jne 0x1564b
leaq 0x117d26(%rip), %rsi    # 0x12d35e
movq %r14, %rdi
xorl %eax, %eax
callq 0xda80
testq %rax, %rax
jne 0x156f4
movq 0x50(%r12), %r15
movq %r12, %rdi
callq 0xbe7e4
movq %rax, %r12
movabsq $-0x509c1db379fe0942, %rax # imm = 0xAF63E24C8601F6BE
cmpq %rax, %r15
jne 0x156c9
movq 0x8(%rsp), %r15
movq 0x50(%r15), %rdi
callq 0x12e56
movq %r12, 0x50(%r15)
leaq 0x58(%r15), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x157c7
jmp 0x156ef
movq 0x28(%r15), %rax
movq 0x50(%r15), %r12
testq %r12, %r12
je 0x15710
cmpq %rax, 0x50(%r12)
jne 0x15710
cmpq $0x0, 0x30(%r15)
jne 0x156b3
cmpq $0x0, 0x38(%r15)
je 0x1573f
leaq 0x117e3e(%rip), %rsi    # 0x12d4f8
movq %r14, %rdi
xorl %eax, %eax
callq 0xde10
jmp 0x155a3
movq 0x8(%rsp), %r15
leaq 0x58(%r15), %r13
movq 0x58(%r15), %rsi
movq %r13, %rdi
movq %r12, %rdx
callq 0x55b79
movq %r13, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x13cf1
testq %rax, %rax
je 0x15701
movq %rax, %rbp
leaq 0x58(%rsp), %rdi
jmp 0x155ab
leaq 0x20(%rsp), %rdi
callq 0xd6d0d
jmp 0x154b3
movq 0x68(%r15), %rcx
testq %rcx, %rcx
je 0x154d8
movq 0x60(%r15), %rdx
xorl %esi, %esi
movq (%rdx,%rsi,8), %r12
cmpq %rax, 0x50(%r12)
je 0x156a1
incq %rsi
cmpq %rsi, %rcx
jne 0x15723
jmp 0x154d8
leaq 0x20(%r15), %rdi
leaq 0x20(%r12), %rsi
callq 0xfef3
movq 0x50(%r12), %r14
movq 0x38(%r15), %rax
testq %rax, %rax
jne 0x15764
callq 0xfa51
movq %rax, 0x38(%r15)
movq %r14, 0x10(%rax)
movq %r12, %rdi
callq 0xbe7e4
movq %rax, %r14
movq 0x78(%r15), %rdi
callq 0x12e56
movq %r14, 0x78(%r15)
jmp 0x154d8