// File: /workspace/github_c_makefile_star2_O1/johsteffens[P]beth/xoico/src/xoico.xo.c
// Function: xoico_stamp_s_parse_func
er_t xoico_stamp_s_parse_func( xoico_stamp_s* o, x_source* source )
{
    // xoico_stamp.x:386:1
    BLM_INIT_LEVEL(0);
    xoico_compiler_s* compiler = o->group->compiler;
    xoico_func_s* func = ((xoico_func_s*)BLM_LEVEL_T_PUSH(0,xoico_func_s,xoico_func_s_create()));
    BLM_TRY(xoico_func_s_parse(func,((const xoico_host*)(o)), source ))
    
    sz_t idx = xoico_funcs_s_get_index_from_name(&(o->funcs),func->name );
    
    if( idx >= 0 )
    {
        xoico_func_s* prex_func = o->funcs.data[ idx ];
        if( ( prex_func->signature_global_name == func->signature_global_name ) )
        {
            if( !func->body )
            {
                BLM_RETURNV(er_t, x_source_parse_error_fa(source,"Function '#<sc_t>' has already been declared.", xoico_compiler_s_nameof(compiler,func->name ) ))
            }
            else if( prex_func->body )
            {
                BLM_RETURNV(er_t, x_source_point_s_parse_error_fa(&(func->source_point),"Function '#<sc_t>' has already a body.", xoico_compiler_s_nameof(compiler,func->name ) ))
            }
            else
            {
                BLM_TRY(xoico_funcs_s_replace_d(&(o->funcs),idx, ((xoico_func_s*)bcore_fork(func)) ))
            }
        }
        else if( prex_func->overloadable )
        {
            BLM_TRY(xoico_funcs_s_replace_d(&(o->funcs),idx, ((xoico_func_s*)bcore_fork(func)) ))
        }
        else
        {
            BLM_RETURNV(er_t, x_source_point_s_parse_error_fa(&(func->source_point),"Function '#<sc_t>' has already been declared and is not overloadable.", xoico_compiler_s_nameof(compiler,func->name ) ))
        }
    }
    else
    {
        x_array_push_d(((x_array*)(&(o->funcs))),((x_inst*)(((xoico_func_s*)bcore_fork(func)) )));
    }
    
    if( func->signature_global_name == ((tp_t)(TYPEOF_x_inst_main)) ) BLM_TRY(xoico_target_s_set_main_function(o->group->xoico_source->target,func ))
    
    BLM_RETURNV(er_t, 0)
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x18292e(%rip), %rax    # 0x1a8dd0
movq (%rax), %rsi
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0xe0431
movq $0x0, 0x10(%r14)
movq 0xc8(%rbx), %rax
movq 0x140(%rax), %r13
callq 0x19c7d
movabsq $-0x58b74b3ddbc4f8b6, %rdx # imm = 0xA748B4C2243B074A
movq %r14, %rdi
xorl %esi, %esi
movq %rax, %rcx
callq 0xe0676
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x1a60a
movq %rax, %r15
testq %rax, %rax
jne 0x266a1
movq 0x8(%r14), %rsi
movq 0x68(%rbx), %rax
testq %rax, %rax
je 0x26522
movq 0x60(%rbx), %rdx
movq (%rdx), %rcx
cmpq %rsi, 0x8(%rcx)
jne 0x2652e
movq %r13, %rdi
xorl %ebp, %ebp
jmp 0x26561
movq %r13, %rdi
movq $-0x1, %rbp
jmp 0x26561
movl $0x1, %r8d
xorl %ecx, %ecx
movq %r8, %r10
cmpq %r8, %rax
je 0x26550
movq (%rdx,%r10,8), %r9
leaq 0x1(%r10), %r8
cmpq %rsi, 0x8(%r9)
cmoveq %r10, %rcx
jne 0x26536
movq %r13, %rdi
cmpq %rax, %r10
movq $-0x1, %rbp
cmovbq %rcx, %rbp
leaq 0x58(%rbx), %r13
testq %rbp, %rbp
js 0x2659c
movq 0x60(%rbx), %rax
movq (%rax,%rbp,8), %rax
movq 0x20(%rax), %rcx
cmpq 0x20(%r14), %rcx
jne 0x265b5
cmpq $0x0, 0x38(%r14)
je 0x265f7
cmpq $0x0, 0x38(%rax)
je 0x265bb
leaq 0x48(%r14), %r15
callq 0xe39f
leaq 0x112a18(%rip), %rsi    # 0x138fb2
jmp 0x265e6
movq %r14, %rdi
callq 0xc8348
movq (%r13), %rsi
movq %r13, %rdi
movq %rax, %rdx
callq 0x5b3a7
jmp 0x26628
cmpb $0x1, 0x29(%rax)
jne 0x265d6
movq %r14, %rdi
callq 0xc8348
movq %r13, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x1c879
movb $0x1, %bpl
jmp 0x2661f
leaq 0x48(%r14), %r15
callq 0xe39f
leaq 0x113374(%rip), %rsi    # 0x13995a
xorl %ebp, %ebp
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x13591
jmp 0x26612
callq 0xe39f
leaq 0x112981(%rip), %rsi    # 0x138f84
xorl %ebp, %ebp
movq %r12, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xddb2
movq %rax, %r15
leaq 0x8(%rsp), %rdi
callq 0xe0b30
testb %bpl, %bpl
je 0x266ab
movabsq $0x242b13df94fa288, %rax # imm = 0x242B13DF94FA288
cmpq %rax, 0x20(%r14)
jne 0x2669e
movq 0xc8(%rbx), %rax
movq 0x138(%rax), %rax
movq 0x90(%rax), %rax
movq 0x138(%rax), %rcx
cmpb $0x1, 0x170(%rcx)
jne 0x26677
addq $0x48, %r14
leaq 0x113cf8(%rip), %rsi    # 0x13a360
movq %r14, %rdi
xorl %eax, %eax
callq 0x13591
movq %rax, %rbx
jmp 0x26687
movb $0x1, 0x170(%rcx)
movq %r14, 0x140(%rax)
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x26699
leaq 0x8(%rsp), %rdi
callq 0xe0b30
movq %rbx, %r15
testq %rbx, %rbx
jne 0x266ab
xorl %r15d, %r15d
leaq 0x8(%rsp), %rdi
callq 0xe0b30
movq %r15, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq