// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
leaq 0x1a9082(%rip), %rax    # 0x1b2330
movq (%rax), %rax
movq %rax, -0x28(%rbp)
leaq -0x58(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0xbfe80
movq -0x60(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x18(%rbp), %rdi
callq 0x5170
movq %rax, -0x68(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x1e0(%rbp)
movb $0x0, %al
callq 0xff2e0
movq -0x1e0(%rbp), %rdi
movq %rax, %rcx
xorl %eax, %eax
movl %eax, %esi
movabsq $-0x503db0e6e1c2e704, %rdx # imm = 0xAFC24F191E3D18FC
callq 0xc01a0
movq %rax, -0x70(%rbp)
movq -0x20(%rbp), %rdi
leaq 0x12a4de(%rip), %rsi    # 0x133807
callq 0x6700
testb $0x1, %al
jne 0x9337
jmp 0x9561
movq $0x0, -0x78(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq -0x78(%rbp), %rdx
callq 0x55b0
movq %rax, -0x80(%rbp)
cmpq $0x0, -0x80(%rbp)
je 0x937f
movq -0x80(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x60(%rbp), %rdi
callq 0xc0720
movq -0x88(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9af8
movq -0x68(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x9b10
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
jne 0x93ed
movq -0x20(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq -0x18(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x5a60
movq -0x1e8(%rbp), %rdi
movq %rax, %rdx
leaq 0x12a450(%rip), %rsi    # 0x133816
movb $0x0, %al
callq 0x4c80
movq %rax, -0x98(%rbp)
movq -0x60(%rbp), %rdi
callq 0xc0720
movq -0x98(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9af8
movq -0x10(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x8bd0
movq -0x10(%rbp), %rdi
addq $0x80, %rdi
movq -0x20(%rbp), %rsi
callq 0x5560
movq -0x20(%rbp), %rdi
movq -0x70(%rbp), %rdx
leaq 0x145123(%rip), %rsi    # 0x14e543
movb $0x0, %al
callq 0x4a20
movq %rax, -0xa0(%rbp)
cmpq $0x0, -0xa0(%rbp)
je 0x945f
movq -0xa0(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x60(%rbp), %rdi
callq 0xc0720
movq -0xa8(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9af8
movq -0x68(%rbp), %rdi
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x5140
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rdi
leaq 0x12a3bf(%rip), %rsi    # 0x133845
movb $0x0, %al
callq 0x4a20
movq %rax, -0xb0(%rbp)
cmpq $0x0, -0xb0(%rbp)
je 0x94c5
movq -0xb0(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x60(%rbp), %rdi
callq 0xc0720
movq -0xb8(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9af8
movq -0x10(%rbp), %rdi
addq $0x58, %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x83d0
movq %rax, -0xc0(%rbp)
cmpq $0x0, -0xc0(%rbp)
je 0x9512
movq -0xc0(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x60(%rbp), %rdi
callq 0xc0720
movq -0xc8(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9af8
movq -0x20(%rbp), %rdi
leaq 0x14be2d(%rip), %rsi    # 0x15534a
movb $0x0, %al
callq 0x4a20
movq %rax, -0xd0(%rbp)
cmpq $0x0, -0xd0(%rbp)
je 0x955c
movq -0xd0(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x60(%rbp), %rdi
callq 0xc0720
movq -0xd8(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9af8
jmp 0x9981
movq -0x10(%rbp), %rdi
addq $0x80, %rdi
movq -0x20(%rbp), %rsi
callq 0x5560
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x5f70
movq %rax, -0xe0(%rbp)
cmpq $0x0, -0xe0(%rbp)
je 0x95c2
movq -0xe0(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x60(%rbp), %rdi
callq 0xc0720
movq -0xe8(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9af8
movq -0x10(%rbp), %rax
movb $0x0, 0x4e(%rax)
movq -0x20(%rbp), %rdi
movq -0x70(%rbp), %rdx
leaq 0x144f6a(%rip), %rsi    # 0x14e543
movb $0x0, %al
callq 0x4a20
movq %rax, -0xf0(%rbp)
cmpq $0x0, -0xf0(%rbp)
je 0x9618
movq -0xf0(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x60(%rbp), %rdi
callq 0xc0720
movq -0xf8(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9af8
movq -0x68(%rbp), %rdi
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x5140
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rdi
leaq 0x12a206(%rip), %rsi    # 0x133845
movb $0x0, %al
callq 0x4a20
movq %rax, -0x100(%rbp)
cmpq $0x0, -0x100(%rbp)
je 0x967e
movq -0x100(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x60(%rbp), %rdi
callq 0xc0720
movq -0x108(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9af8
movq -0x20(%rbp), %rdi
leaq 0x12a1bf(%rip), %rsi    # 0x133848
callq 0x6700
testb $0x1, %al
jne 0x98e6
movq -0x60(%rbp), %rax
movq %rax, -0x110(%rbp)
leaq -0x140(%rbp), %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
movq -0x110(%rbp), %rsi
callq 0xbfe80
movq -0x148(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x110(%rbp), %rax
movq $0x2, 0x10(%rax)
movq -0x110(%rbp), %rax
movq %rax, -0x1f0(%rbp)
callq 0x7a10
movq -0x1f0(%rbp), %rdi
movq %rax, %rcx
movl $0x2, %esi
movabsq $-0x21883bf5398e4338, %rdx # imm = 0xDE77C40AC671BCC8
callq 0xc01a0
movq %rax, -0x150(%rbp)
movq -0x150(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x7aa0
movq %rax, -0x158(%rbp)
cmpq $0x0, -0x158(%rbp)
je 0x9766
movq -0x158(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x148(%rbp), %rdi
callq 0xc0720
movq -0x160(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9af8
movq -0x20(%rbp), %rdi
leaq 0x12a0d7(%rip), %rsi    # 0x133848
callq 0x6700
testb $0x1, %al
jne 0x97c9
movq -0x20(%rbp), %rdi
leaq 0x129f31(%rip), %rsi    # 0x1336b6
movb $0x0, %al
callq 0x4a20
movq %rax, -0x168(%rbp)
cmpq $0x0, -0x168(%rbp)
je 0x97c7
movq -0x168(%rbp), %rax
movq %rax, -0x170(%rbp)
movq -0x148(%rbp), %rdi
callq 0xc0720
movq -0x170(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9af8
jmp 0x97c9
movq -0x150(%rbp), %rax
movabsq $-0x509c1db379fe0942, %rcx # imm = 0xAF63E24C8601F6BE
cmpq %rcx, 0x50(%rax)
jne 0x985c
movq -0x10(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x1f8(%rbp)
movq -0x150(%rbp), %rdi
callq 0x9d3d0
movq -0x1f8(%rbp), %rdi
movq %rax, %rsi
callq 0x9ba0
movq -0x10(%rbp), %rdi
addq $0x58, %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x9bf0
movq %rax, -0x178(%rbp)
cmpq $0x0, -0x178(%rbp)
je 0x985a
movq -0x178(%rbp), %rax
movq %rax, -0x180(%rbp)
movq -0x148(%rbp), %rdi
callq 0xc0720
movq -0x180(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9af8
jmp 0x98d8
movq -0x10(%rbp), %rax
addq $0x58, %rax
movq %rax, -0x200(%rbp)
movq -0x150(%rbp), %rdi
callq 0x9d3d0
movq -0x200(%rbp), %rdi
movq %rax, %rsi
callq 0x85f0
movq -0x10(%rbp), %rdi
addq $0x58, %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x83d0
movq %rax, -0x188(%rbp)
cmpq $0x0, -0x188(%rbp)
je 0x98d6
movq -0x188(%rbp), %rax
movq %rax, -0x190(%rbp)
movq -0x148(%rbp), %rdi
callq 0xc0720
movq -0x190(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9af8
jmp 0x98d8
leaq -0x148(%rbp), %rdi
callq 0xc06e0
jmp 0x9935
movq -0x10(%rbp), %rdi
addq $0x58, %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x9bf0
movq %rax, -0x198(%rbp)
cmpq $0x0, -0x198(%rbp)
je 0x9933
movq -0x198(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movq -0x60(%rbp), %rdi
callq 0xc0720
movq -0x1a0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9af8
jmp 0x9935
movq -0x20(%rbp), %rdi
leaq 0x14ba0a(%rip), %rsi    # 0x15534a
movb $0x0, %al
callq 0x4a20
movq %rax, -0x1a8(%rbp)
cmpq $0x0, -0x1a8(%rbp)
je 0x997f
movq -0x1a8(%rbp), %rax
movq %rax, -0x1b0(%rbp)
movq -0x60(%rbp), %rdi
callq 0xc0720
movq -0x1b0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9af8
jmp 0x9981
movq -0x10(%rbp), %rax
cmpq $0x0, 0x40(%rax)
jne 0x99a6
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x9020
movq %rax, -0x208(%rbp)
jmp 0x99b1
xorl %eax, %eax
movq %rax, -0x208(%rbp)
jmp 0x99b1
movq -0x208(%rbp), %rax
movq %rax, -0x1b8(%rbp)
cmpq $0x0, -0x1b8(%rbp)
je 0x9a97
movq -0x10(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x99ee
movq -0x10(%rbp), %rax
cmpq $0x0, 0x38(%rax)
jne 0x99ee
movq -0x10(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x9a20
movq -0x20(%rbp), %rdi
leaq 0x129e57(%rip), %rsi    # 0x133850
movb $0x0, %al
callq 0x4c80
movq %rax, -0x1c0(%rbp)
movq -0x60(%rbp), %rdi
callq 0xc0720
movq -0x1c0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9af8
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
movq -0x1b8(%rbp), %rsi
addq $0x20, %rsi
callq 0x5ce0
movq -0x1b8(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x218(%rbp)
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
addq $0x18, %rdi
leaq -0x3ebd(%rip), %rsi     # 0x5ba0
callq 0x6750
movq -0x218(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
addq $0x78, %rax
movq %rax, -0x210(%rbp)
movq -0x1b8(%rbp), %rdi
callq 0x9d3d0
movq -0x210(%rbp), %rdi
movq %rax, %rsi
callq 0x9ba0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x9150
movq %rax, -0x1c8(%rbp)
cmpq $0x0, -0x1c8(%rbp)
je 0x9ad9
movq -0x1c8(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movq -0x60(%rbp), %rdi
callq 0xc0720
movq -0x1d0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9af8
movq $0x0, -0x1d8(%rbp)
movq -0x60(%rbp), %rdi
callq 0xc0720
movq -0x1d8(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
nopw %cs:(%rax,%rax)