// File: /workspace/github_c_makefile_star2_O1/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, %r15
movq %rsi, %r13
movq %rdi, 0x8(%rsp)
leaq 0x193a16(%rip), %rax    # 0x1a8dd0
movq (%rax), %rsi
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0xe0431
movq $0x0, 0x10(%r14)
movq (%r13), %r12
leaq 0x18a2c3(%rip), %rbx    # 0x19f6a0
movl 0x18a2bd(%rip), %eax    # 0x19f6a0
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%rbx,%rax,8), %rcx
movq 0x18(%rbx,%rax,8), %rdx
andq %r12, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %r12, %rdx
je 0x1543a
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r12, %rdx
je 0x1543a
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r12, %rdx
je 0x1543a
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r12, %rdx
jne 0x159b0
movq (%rax,%rcx), %r14
testq %r14, %r14
jne 0x1546a
movabsq $-0x1e682f89ce03d7c8, %rdi # imm = 0xE197D07631FC2838
movq %r12, %rsi
callq 0xf3f85
movq %rax, %r14
leaq 0x18a241(%rip), %rdi    # 0x19f6a0
movq %r12, %rsi
movq %rax, %rdx
callq 0x12128c
movq %r13, 0x10(%rsp)
movq %r13, %rdi
callq *0x20(%r14)
movq %rax, 0x20(%rsp)
xorl %eax, %eax
callq 0x114bbb
leaq 0x28(%rsp), %rdi
movabsq $-0x503db0e6e1c2e704, %rdx # imm = 0xAFC24F191E3D18FC
xorl %esi, %esi
movq %rax, %rcx
callq 0xe0676
movq %rax, %rbp
movq (%r15), %r12
leaq 0x194820(%rip), %r13    # 0x1a9cc8
movl (%r13), %eax
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%r13,%rax,8), %rcx
movq 0x18(%r13,%rax,8), %rdx
andq %r12, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %r12, %rdx
je 0x15503
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r12, %rdx
je 0x15503
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r12, %rdx
je 0x15503
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r12, %rdx
jne 0x159b8
movq (%rax,%rcx), %r14
testq %r14, %r14
jne 0x15533
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %r12, %rsi
callq 0xf3f85
movq %rax, %r14
leaq 0x1947a0(%rip), %rdi    # 0x1a9cc8
movq %r12, %rsi
movq %rax, %rdx
callq 0x12128c
leaq 0x122f75(%rip), %rdx    # 0x1384af
movq %r14, %rdi
movq %r15, %rsi
callq 0x10aa16
testb %al, %al
je 0x1561e
movq $0x0, 0x58(%rsp)
movq 0x10(%rsp), %r13
movq (%r13), %r12
movl 0x18a13b(%rip), %eax    # 0x19f6a0
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%rbx,%rax,8), %rcx
movq 0x18(%rbx,%rax,8), %rdx
andq %r12, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %r12, %rdx
je 0x155bc
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r12, %rdx
je 0x155bc
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r12, %rdx
je 0x155bc
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r12, %rdx
jne 0x15a51
movq (%rax,%rcx), %r14
testq %r14, %r14
jne 0x155ec
movabsq $-0x1e682f89ce03d7c8, %rdi # imm = 0xE197D07631FC2838
movq %r12, %rsi
callq 0xf3f85
movq %rax, %r14
leaq 0x18a0bf(%rip), %rdi    # 0x19f6a0
movq %r12, %rsi
movq %rax, %rdx
callq 0x12128c
leaq 0x58(%rsp), %rdx
movq %r13, %rdi
movq %r15, %rsi
callq *0x18(%r14)
movq %rax, %r12
testq %rax, %rax
je 0x157b6
movq %r12, %r14
leaq 0x28(%rsp), %rdi
callq 0xe0b30
xorl %eax, %eax
movq %r14, %r12
jmp 0x15898
movq 0x8(%rsp), %rbx
leaq 0x80(%rbx), %rdi
movq %r15, %rsi
callq 0xe9fb
leaq 0x20(%rbx), %rdi
movq 0x10(%rsp), %rsi
movq %r15, %rdx
callq 0x10314
movq %rax, %r12
testq %rax, %rax
jne 0x15a32
movb $0x0, 0x4e(%rbx)
leaq 0x139c28(%rip), %rsi    # 0x14f282
movq %r15, %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xda10
movq %rax, %r14
testq %rax, %rax
je 0x1567c
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %r14, %r12
testq %r14, %r14
jne 0x15a3c
movq 0x8(%rbp), %rsi
movq 0x20(%rsp), %rdi
addq $0x140, %rdi            # imm = 0x140
callq 0xddb52
movq 0x8(%rsp), %rcx
movq %rax, 0x8(%rcx)
leaq 0x122e43(%rip), %rsi    # 0x1384ed
movq %r15, %rdi
xorl %eax, %eax
callq 0xda10
movq %rax, %r14
testq %rax, %rax
je 0x156c9
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %r14, %r12
testq %r14, %r14
jne 0x15a3c
movq (%r15), %rbx
movl (%r13), %eax
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%r13,%rax,8), %rcx
movq 0x18(%r13,%rax,8), %rdx
andq %rbx, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %rbx, %rdx
je 0x15730
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbx, %rdx
je 0x15730
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbx, %rdx
je 0x15730
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbx, %rdx
jne 0x15c0a
movq (%rax,%rcx), %r14
testq %r14, %r14
jne 0x15760
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %rbx, %rsi
callq 0xf3f85
movq %rax, %r14
leaq 0x194573(%rip), %rdi    # 0x1a9cc8
movq %rbx, %rsi
movq %rax, %rdx
callq 0x12128c
leaq 0x122d89(%rip), %rdx    # 0x1384f0
movq %r14, %rdi
movq %r15, %rsi
callq 0x10aa16
testb %al, %al
je 0x15a59
movq 0x8(%rsp), %rax
leaq 0x58(%rax), %rdi
movq 0x10(%rsp), %r13
movq %r13, %rsi
movq %r15, %rdx
callq 0x15c69
movq %rax, %r14
testq %rax, %rax
je 0x157a8
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %r14, %r12
testq %r14, %r14
jne 0x15a3c
jmp 0x15ad5
movq 0x58(%rsp), %rsi
movq 0x20(%rsp), %rdi
callq 0x15c23
testq %rax, %rax
je 0x158ef
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x14796
leaq 0x80(%rbx), %rdi
movq %r15, %rsi
callq 0xe9fb
leaq 0x139a8e(%rip), %rsi    # 0x14f282
movq %r15, %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xda10
movq %rax, %r14
testq %rax, %rax
je 0x15816
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %r14, %r12
testq %r14, %r14
jne 0x15896
movq 0x8(%rbp), %rsi
movq 0x20(%rsp), %rdi
addq $0x140, %rdi            # imm = 0x140
callq 0xddb52
movq 0x8(%rsp), %rcx
movq %rax, 0x8(%rcx)
leaq 0x122cad(%rip), %rsi    # 0x1384ed
movq %r15, %rdi
xorl %eax, %eax
callq 0xda10
movq %rax, %r14
testq %rax, %rax
je 0x1585f
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %r14, %r12
testq %r14, %r14
jne 0x15896
movq 0x8(%rsp), %rax
leaq 0x58(%rax), %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x14067
movq %rax, %r14
testq %rax, %rax
je 0x1588d
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %r14, %r12
testq %r14, %r14
je 0x15b09
xorl %eax, %eax
testb %al, %al
je 0x15a3c
movq 0x8(%rsp), %r14
movq 0x40(%r14), %rbx
testq %rbx, %rbx
je 0x158b3
xorl %r12d, %r12d
jmp 0x158c2
movq 0x28(%r14), %rsi
movq %r14, %rdi
callq 0x14d5f
movq %rax, %r12
testq %r12, %r12
je 0x15a24
cmpq $0x0, 0x30(%r14)
je 0x159c0
leaq 0x122c1b(%rip), %rsi    # 0x1384f8
movq %r15, %rdi
xorl %eax, %eax
callq 0xddb2
movq %rax, %r12
jmp 0x15a32
movq 0x58(%rsp), %r12
movq (%r13), %r13
movl 0x189da2(%rip), %eax    # 0x19f6a0
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%rbx,%rax,8), %rcx
movq 0x18(%rbx,%rax,8), %rdx
andq %r13, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %r13, %rdx
je 0x15955
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r13, %rdx
je 0x15955
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r13, %rdx
je 0x15955
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r13, %rdx
jne 0x15bb6
movq (%rax,%rcx), %r14
testq %r14, %r14
jne 0x15985
movabsq $-0x1e682f89ce03d7c8, %rdi # imm = 0xE197D07631FC2838
movq %r13, %rsi
callq 0xf3f85
movq %rax, %r14
leaq 0x189d26(%rip), %rdi    # 0x19f6a0
movq %r13, %rsi
movq %rax, %rdx
callq 0x12128c
movq 0x10(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq *0x48(%r14)
leaq 0x122b23(%rip), %rsi    # 0x1384be
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xddb2
movq %rax, %r14
jmp 0x1560a
xorl %r14d, %r14d
jmp 0x1543e
xorl %r14d, %r14d
jmp 0x15507
testq %rbx, %rbx
jne 0x158d6
cmpq $0x0, 0x38(%r14)
jne 0x158d6
leaq 0x20(%r14), %rdi
leaq 0x20(%r12), %rsi
callq 0xff8e
movq 0x50(%r12), %rbx
movq 0x38(%r14), %rax
testq %rax, %rax
jne 0x159f9
callq 0xfad4
movq %rax, 0x38(%r14)
movq %rbx, 0x10(%rax)
movq %r12, %rdi
callq 0xc8348
movq %rax, %r14
movq 0x8(%rsp), %rax
movq 0x78(%rax), %rdi
callq 0x1320a
movq 0x8(%rsp), %rax
movq %r14, 0x78(%rax)
movq 0x8(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x15076
xorl %r12d, %r12d
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %r12, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r14d, %r14d
jmp 0x155c0
leaq 0x58(%rsp), %rdi
movq %rdi, 0x18(%rsp)
leaq 0x28(%rsp), %rsi
callq 0xe0431
movq 0x18(%rsp), %r14
movq $0x2, 0x10(%r14)
callq 0x1315b
movabsq $-0x21883bf5398e4338, %rdx # imm = 0xDE77C40AC671BCC8
movl $0x2, %esi
movq %r14, %rdi
movq %rax, %rcx
callq 0xe0676
movq %rax, %r13
movq %rax, %rdi
movq 0x10(%rsp), %rsi
movq %r15, %rdx
callq 0x13390
movq %rax, %r14
testq %rax, %rax
je 0x15ac1
movq 0x18(%rsp), %rdi
callq 0xe0b30
movq %r14, %r12
testq %r14, %r14
je 0x15b2e
xorl %eax, %eax
movq 0x10(%rsp), %r13
testb %al, %al
je 0x15a3c
leaq 0x140460(%rip), %rsi    # 0x155f3c
movq %r15, %rdi
xorl %eax, %eax
callq 0xda10
movq %rax, %r14
testq %rax, %rax
je 0x15afb
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movq %r14, %r12
testq %r14, %r14
jne 0x15a3c
jmp 0x158a0
leaq 0x14042c(%rip), %rsi    # 0x155f3c
movq %r15, %rdi
xorl %eax, %eax
callq 0xda10
movq %rax, %r14
testq %rax, %rax
sete %al
jne 0x1560a
jmp 0x15898
leaq 0x1229bb(%rip), %rsi    # 0x1384f0
movq %r15, %rdi
callq 0x115a3
testb %al, %al
jne 0x15b70
leaq 0x122816(%rip), %rsi    # 0x13835e
movq %r15, %rdi
xorl %eax, %eax
callq 0xda10
movq %rax, %r14
testq %rax, %rax
je 0x15b67
movq 0x18(%rsp), %rdi
callq 0xe0b30
movq %r14, %r12
testq %r14, %r14
jne 0x15ac6
movq 0x50(%r13), %rbx
movq %r13, %rdi
callq 0xc8348
movq %rax, %r14
movabsq $-0x509c1db379fe0942, %rax # imm = 0xAF63E24C8601F6BE
cmpq %rax, %rbx
jne 0x15bbe
movq 0x8(%rsp), %rbx
movq 0x50(%rbx), %rdi
callq 0x1320a
movq %r14, 0x50(%rbx)
leaq 0x58(%rbx), %rdi
movq 0x10(%rsp), %r13
movq %r13, %rsi
movq %r15, %rdx
callq 0x15c69
jmp 0x15be9
xorl %r14d, %r14d
jmp 0x15959
movq 0x8(%rsp), %rax
leaq 0x58(%rax), %r13
movq 0x58(%rax), %rsi
movq %r13, %rdi
movq %r14, %rdx
callq 0x5b3a7
movq %r13, %rdi
movq 0x10(%rsp), %r13
movq %r13, %rsi
movq %r15, %rdx
callq 0x14067
movq %rax, %r14
testq %rax, %rax
je 0x15bfe
movq 0x18(%rsp), %rdi
callq 0xe0b30
movq %r14, %r12
testq %r14, %r14
je 0x15c12
xorl %eax, %eax
jmp 0x15acd
xorl %r14d, %r14d
jmp 0x15734
leaq 0x18(%rsp), %rdi
callq 0xe0b11
movb $0x1, %al
jmp 0x15acd