// File: /workspace/github_c_makefile_star2_O3/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 0x1740db(%rip), %rax    # 0x19bdd0
movq (%rax), %rsi
leaq 0x18(%rsp), %r15
movq %r15, %rdi
callq 0xd6675
movq $0x0, 0x10(%r15)
movq (%rbx), %r15
leaq 0x16a989(%rip), %rbp    # 0x1926a0
movl 0x16a983(%rip), %eax    # 0x1926a0
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%rbp,%rax,8), %rcx
movq 0x18(%rbp,%rax,8), %rdx
andq %r15, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %r15, %rdx
je 0x27d70
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r15, %rdx
je 0x27d70
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r15, %rdx
je 0x27d70
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r15, %rdx
jne 0x27d79
movq (%rax,%rcx), %r12
testq %r12, %r12
jne 0x27da0
movabsq $-0x1e682f89ce03d7c8, %rdi # imm = 0xE197D07631FC2838
movq %r15, %rsi
callq 0xe9bc5
movq %rax, %r12
leaq 0x16a90b(%rip), %rdi    # 0x1926a0
movq %r15, %rsi
movq %rax, %rdx
callq 0x115fac
movq %rbx, %rdi
callq *0x20(%r12)
movq %rax, %r15
movq 0x8(%r14), %rsi
leaq 0x50(%rax), %rdi
callq 0xca94f
testq %rax, %rax
je 0x27ddc
movq (%rax), %rax
testq %rax, %rax
je 0x27ddc
movq 0x10(%r14), %rsi
movq %rax, 0x8(%rsp)
leaq 0x178(%rax), %rdi
callq 0xca94f
jmp 0x27e20
leaq 0x18(%r14), %r12
movq 0x8(%r14), %rsi
movq %r15, %rdi
callq 0xe3d7
leaq 0x106ad7(%rip), %rsi    # 0x12e8ca
movq %r12, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x13254
testq %rax, %rax
jne 0x281e3
movq 0x10(%r14), %rsi
movl $0x178, %edi            # imm = 0x178
callq 0xca94f
movq $0x0, 0x8(%rsp)
testq %rax, %rax
je 0x27e2d
movq (%rax), %rax
testq %rax, %rax
jne 0x27e6e
leaq 0x18(%r14), %r12
movq 0x10(%r14), %rsi
movq %r15, %rdi
callq 0xe3d7
movq %rax, %r13
movq 0x8(%r14), %rsi
movq %r15, %rdi
callq 0xe3d7
leaq 0x106a97(%rip), %rsi    # 0x12e8ea
movq %r12, %rdi
movq %r13, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x13254
testq %rax, %rax
jne 0x281e3
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movq 0x40(%rax), %rax
movq 0x18(%rax), %rsi
movq %r15, %rdi
callq 0x15785
movq %rax, %rdi
callq 0x145cb
movq %rax, %r12
movq 0x30(%r14), %rdi
callq 0x1450e
movq %r12, 0x30(%r14)
movq %r12, %rdi
movq %rbx, %rsi
callq 0x14c31
movq 0x30(%r14), %r12
movq (%rbx), %r13
movl 0x16a7ed(%rip), %eax    # 0x1926a0
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%rbp,%rax,8), %rcx
movq 0x18(%rbp,%rax,8), %rdx
andq %r13, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %r13, %rdx
je 0x27f06
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r13, %rdx
je 0x27f06
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r13, %rdx
je 0x27f06
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r13, %rdx
jne 0x27f0f
movq (%rax,%rcx), %rbp
testq %rbp, %rbp
jne 0x27f36
movabsq $-0x1e682f89ce03d7c8, %rdi # imm = 0xE197D07631FC2838
movq %r13, %rsi
callq 0xe9bc5
movq %rax, %rbp
leaq 0x16a775(%rip), %rdi    # 0x1926a0
movq %r13, %rsi
movq %rax, %rdx
callq 0x115fac
movq %rbx, %rdi
callq *0x40(%rbp)
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x1468a
movq 0x30(%r14), %rsi
movq %r15, %rdi
callq 0x1abe3
testq %rax, %rax
jne 0x281e3
movq 0x38(%r14), %rax
testq %rax, %rax
jne 0x27f71
callq 0x196b9
movq %rax, 0x38(%r14)
movq 0x30(%r14), %rcx
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x18(%rcx), %rcx
movq %rcx, 0x20(%rax)
xorl %eax, %eax
callq 0x109c82
leaq 0x18(%rsp), %rdi
movabsq $-0x503db0e6e1c2e704, %rdx # imm = 0xAFC24F191E3D18FC
xorl %esi, %esi
movq %rax, %rcx
callq 0xd68a8
movq %rax, %r15
leaq 0x11b6c9(%rip), %rsi    # 0x143678
movq %rax, %rdi
xorl %eax, %eax
callq 0x10a8a5
movq 0x30(%r14), %rax
movq 0x28(%rax), %rcx
movabsq $0x3173c900e37ae1df, %rdx # imm = 0x3173C900E37AE1DF
cmpq %rdx, %rcx
leaq 0x16a6cb(%rip), %rbp    # 0x1926a0
je 0x27fdc
testq %rcx, %rcx
jne 0x27fe3
cmpq $0x0, 0x40(%rax)
je 0x27ff2
leaq 0x105a25(%rip), %rsi    # 0x12da0f
movq %r15, %rdi
callq 0x10a6fa
movq 0x8(%rsp), %rax
movq 0xa8(%rax), %r12
movq (%rbx), %r13
movl 0x16a699(%rip), %eax    # 0x1926a0
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%rbp,%rax,8), %rcx
movq 0x18(%rbp,%rax,8), %rdx
andq %r13, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %r13, %rdx
je 0x2805a
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r13, %rdx
je 0x2805a
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r13, %rdx
je 0x2805a
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r13, %rdx
jne 0x28063
movq (%rax,%rcx), %rbp
testq %rbp, %rbp
jne 0x2808a
movabsq $-0x1e682f89ce03d7c8, %rdi # imm = 0xE197D07631FC2838
movq %r13, %rsi
callq 0xe9bc5
movq %rax, %rbp
leaq 0x16a621(%rip), %rdi    # 0x1926a0
movq %r13, %rsi
movq %rax, %rdx
callq 0x115fac
movq %rbx, %rdi
movq %r12, %rsi
callq *0x48(%rbp)
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rax
movq 0x8(%rax), %r13
movq (%rbx), %rbp
movl 0x16a5f6(%rip), %eax    # 0x1926a0
cltq
leaq (%rax,%rax,2), %rax
leaq 0x16a5e9(%rip), %rdx    # 0x1926a0
movq 0x20(%rdx,%rax,8), %rcx
movq 0x18(%rdx,%rax,8), %rdx
andq %rbp, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %rbp, %rdx
je 0x28104
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbp, %rdx
je 0x28104
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbp, %rdx
je 0x28104
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbp, %rdx
jne 0x2810d
movq (%rax,%rcx), %r12
testq %r12, %r12
jne 0x28134
movabsq $-0x1e682f89ce03d7c8, %rdi # imm = 0xE197D07631FC2838
movq %rbp, %rsi
callq 0xe9bc5
movq %rax, %r12
leaq 0x16a577(%rip), %rdi    # 0x1926a0
movq %rbp, %rsi
movq %rax, %rdx
callq 0x115fac
movq %rbx, %rdi
movq %r13, %rsi
callq *0x48(%r12)
leaq 0x1067da(%rip), %rsi    # 0x12e920
movq %r15, %rdi
movq 0x8(%rsp), %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x10a8a5
movq 0x30(%r14), %rdi
movq 0x50(%rdi), %r12
testq %r12, %r12
je 0x28177
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x134d3
movq 0x30(%r14), %rdi
xorl %edx, %edx
testq %r12, %r12
sete %dl
addq $0x58, %rdi
movq %rbx, %rsi
movq %r15, %rcx
callq 0x1403e
leaq 0x10679c(%rip), %rsi    # 0x12e931
movq %r15, %rdi
xorl %eax, %eax
callq 0x10a8a5
movq 0x38(%r14), %r13
movq 0x38(%r13), %r12
testq %r12, %r12
jne 0x281bd
callq 0x17f81
movq %rax, 0x38(%r13)
movq 0x38(%r14), %rax
movq 0x38(%rax), %r12
movq 0x8(%r15), %rdi
callq 0xe4688
leaq 0x18(%rsp), %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0xd6b17
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x189ff
movq %rax, %r12
leaq 0x18(%rsp), %rdi
callq 0xd6d2c
movq %r12, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq