// File: /workspace/github_c_makefile_star2_O2/johsteffens[P]beth/xoico/src/xoico.xo.c
// Function: xoico_wrap_s_finalize
er_t xoico_wrap_s_finalize( xoico_wrap_s* o, const xoico_host* host )
{
    // xoico_wrap.x:42:5
    BLM_INIT_LEVEL(0);
    xoico_compiler_s* compiler = xoico_host_a_compiler(host);
    const xoico_group_s* group = xoico_compiler_s_get_group(compiler,o->group_name );
    if( !group ) BLM_TRY(x_source_point_s_parse_error_fa(&(o->source_point),"Wrap: '#<sc_t>' is not a group.", xoico_compiler_s_nameof(compiler,o->group_name ) ))
    const xoico_func_s* func = xoico_group_s_get_func(group,o->func_name );
    if( !func ) BLM_TRY(x_source_point_s_parse_error_fa(&(o->source_point),"Wrap: '#<sc_t>' is not a function in group '#<sc_t>'.", xoico_compiler_s_nameof(compiler,o->func_name ), xoico_compiler_s_nameof(compiler,o->group_name ) ))
    
    xoico_signature_s_attach( &(o->signature ),  xoico_signature_s_clone(xoico_compiler_s_get_signature(compiler,func->signature->global_name )));
    BLM_TRY(xoico_signature_s_set_global_name(o->signature,host ))
    BLM_TRY(xoico_signature_s_convert_transient_types(o->signature,host, xoico_host_a_transient_map(host) ))
    BLM_TRY(xoico_compiler_s_register_item(compiler,((const xoico*)(o->signature ))))
    
    BCORE_PASS_CREATE(xoico_func_s,o->func);
    o->func->name = o->signature->name;
    o->func->signature_global_name = o->signature->global_name;
    
    st_s* st = ((st_s*)BLM_LEVEL_T_PUSH(0,st_s,st_s_create()));
    st_s_push_fa(st,"{" );
    if( xoico_signature_s_returns_a_value(o->signature) ) st_s_push_sc(st,"return " );
    
    st_s_push_fa(st,"#<sc_t>_#<sc_t>(", xoico_host_a_nameof(host,group->tp_name ), xoico_host_a_nameof(host,func->name ) );
    
    if( o->signature->arg_o )
    {
        BLM_TRY(xoico_arg_s_expand_name(o->signature->arg_o,host,((x_sink*)( st ))))
        BLM_TRY(xoico_args_s_expand_name(&(o->signature->args),host, false,((x_sink*)( st ))))
    }
    else
    {
        BLM_TRY(xoico_args_s_expand_name(&(o->signature->args),host, true,((x_sink*)( st ))))
    }
    
    st_s_push_fa(st,");};" );
    
    BCORE_PASS_CREATE(xoico_body_s,o->func->body);
    BLM_TRY(xoico_body_s_parse(o->func->body,host, ((x_source*)BLM_LEVEL_A_PUSH(0,x_source_create_from_sc(st->sc ))) ))
    
    BLM_RETURNV(er_t, 0)
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x100882(%rip), %rax    # 0x117dd0
movq (%rax), %rsi
leaq 0x18(%rsp), %r15
movq %r15, %rdi
callq 0x717f5
andq $0x0, 0x10(%r15)
movq %rbx, %rdi
callq 0xdab3
movq %rax, %rbp
movq 0x8(%r14), %rsi
movq %rax, %rdi
callq 0x1393c
movq %rax, %r15
testq %rax, %rax
je 0x17756
movq %rbx, 0x8(%rsp)
movq 0x10(%r14), %rsi
movq %r15, %rdi
callq 0x13a3a
movq %rax, %rbx
testq %rax, %rax
je 0x17784
movq %r15, 0x10(%rsp)
leaq 0x30(%r14), %r12
movq 0x40(%rbx), %rax
movq 0x18(%rax), %rsi
movq %rbp, %rdi
callq 0xffca
movq %rax, %rdi
callq 0xf979
movq %r12, %rdi
movq %rax, %rsi
callq 0x11556
movq 0x30(%r14), %rdi
movq 0x8(%rsp), %r15
movq %r15, %rsi
callq 0xfb44
movq 0x30(%r14), %r13
movq %r15, %rdi
callq 0x11588
movq %r13, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0xf993
movq 0x30(%r14), %rsi
movq %rbp, %rdi
callq 0x114d0
testq %rax, %rax
jne 0x177c3
movq %rbx, %r13
movq 0x38(%r14), %rax
testq %rax, %rax
jne 0x17624
callq 0x10ebb
movq %rax, 0x38(%r14)
movq (%r12), %rcx
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x18(%rcx), %rcx
movq %rcx, 0x20(%rax)
xorl %eax, %eax
callq 0x8eb65
leaq 0x18(%rsp), %rdi
movabsq $-0x503db0e6e1c2e704, %rdx # imm = 0xAFC24F191E3D18FC
xorl %esi, %esi
movq %rax, %rcx
callq 0x71967
movq %rax, %rbp
leaq 0xa9da6(%rip), %rsi     # 0xc1408
movq %rax, %rdi
xorl %eax, %eax
callq 0x8f4ef
movq (%r12), %rdi
callq 0x12db3
testb %al, %al
movq 0x8(%rsp), %rbx
movq 0x10(%rsp), %r15
je 0x17692
leaq 0x93385(%rip), %rsi     # 0xaaa0f
movq %rbp, %rdi
callq 0x8f392
movq 0xa8(%r15), %rsi
movq %rbx, %rdi
callq 0xdf58
movq %rax, %r15
movq 0x8(%r13), %rsi
movq %rbx, %rdi
callq 0xdf58
leaq 0x94269(%rip), %rsi     # 0xab920
movq %rbp, %rdi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x8f4ef
movq (%r12), %rdi
movq 0x50(%rdi), %r15
testq %r15, %r15
je 0x176e6
movq %r15, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0xf379
movq (%r12), %rdi
xorl %edx, %edx
testq %r15, %r15
sete %dl
addq $0x58, %rdi
movq %rbx, %rsi
movq %rbp, %rcx
callq 0xf831
leaq 0x9422d(%rip), %rsi     # 0xab931
movq %rbp, %rdi
xorl %eax, %eax
callq 0x8f4ef
movq 0x38(%r14), %r12
movq 0x38(%r12), %r15
testq %r15, %r15
jne 0x1772e
callq 0x10839
movq %rax, 0x38(%r12)
movq 0x38(%r14), %rax
movq 0x38(%rax), %r15
movq 0x8(%rbp), %rdi
callq 0x76c9e
leaq 0x18(%rsp), %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x71a90
movq %r15, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x10b30
jmp 0x177c3
leaq 0x18(%r14), %r12
movq 0x8(%r14), %rsi
movq %rbp, %rdi
callq 0xdad8
leaq 0x9415d(%rip), %rsi     # 0xab8ca
movq %r12, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xf256
testq %rax, %rax
jne 0x177c3
jmp 0x17586
leaq 0x18(%r14), %r12
movq 0x10(%r14), %rsi
movq %rbp, %rdi
callq 0xdad8
movq %rax, %r13
movq 0x8(%r14), %rsi
movq %rbp, %rdi
callq 0xdad8
leaq 0x94140(%rip), %rsi     # 0xab8ea
movq %r12, %rdi
movq %r13, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xf256
testq %rax, %rax
je 0x175a3
movq %rax, %r13
leaq 0x18(%rsp), %rdi
callq 0x71b64
movq %r13, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq