// File: /workspace/github_c_makefile_star2_O3/johsteffens[P]beth/xoico/src/xoico.xo.c
// Function: xoico_compiler_s_parse
er_t xoico_compiler_s_parse( xoico_compiler_s* o, sc_t target_name, sc_t target_ext, const st_s* target_output_folder, sc_t source_path, sc_t group_name, sc_t trait_name, tp_t embed_method, sz_t* p_target_index )
{
    // xoico_compiler.x:464:1
    BLM_INIT_LEVEL(0);
    const st_s* source_folder = ((st_s*)BLM_LEVEL_T_PUSH(0,st_s,bcore_file_folder_path(source_path )));
    const st_s* output_folder = target_output_folder ? target_output_folder : source_folder;
    st_s* target_output_path = ((st_s*)BLM_LEVEL_T_PUSH(0,st_s,st_s_create_fa("#<sc_t>/#<sc_t>.#<sc_t>", output_folder->sc, target_name, target_ext )));
    
    sz_t target_index = -1;
    for(sz_t i = 0; i < o->size; i++ )
    {
        if( sc_t_equal( target_name, o->data[ i ]->name.sc ) )
        {
            target_index = i;
            break;
        }
    }
    
    if( target_index == -1 )
    {
        xoico_target_s* target = xoico_target_s_create();
        target->compiler = o;
        st_s_copy_sc(&(target->name        ),target_name );
        st_s_copy_sc(&(target->ext         ),target_ext );
        st_s_copy_fa(&(target->include_path),"#<sc_t>.#<sc_t>", target_name, target_ext );
        st_s_copy(&(target->output_path),target_output_path );
        xoico_compiler_s_push_d(o,target );
        target_index = o->size - 1;
    }
    
    xoico_target_s* target = o->data[ target_index ];
    
    /// check paths and extensions
    if( !st_s_equal_sc(&(target->ext),target_ext ) )
    {
        ERR_fa( "Target '#<sc_t>': Assigned extension '#<sc_t>' differs from requested extension '#<sc_t>'.", target->name.sc, target->ext.sc, target_ext );
    }
    if( !st_s_equal_st(&(target->output_path),target_output_path ) )
    {
        ERR_fa( "Target '#<sc_t>': Assigned output path '#<sc_t>' differs from requested output path '#<sc_t>'.", target->name.sc, target->output_path.sc, target_output_path->sc );
    }
    
    BLM_TRY(xoico_target_s_parse_from_path(target,source_path, group_name, trait_name, embed_method ))
    if( p_target_index ) (*(p_target_index)) = target_index;
    
    BLM_RETURNV(er_t, 0)
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, 0x10(%rsp)
movq %r8, %r14
movq %rcx, %rbx
movq %rdx, %r15
movq %rsi, %rbp
movq %rdi, %r13
leaq 0x16ae77(%rip), %rax    # 0x19bdd0
movq (%rax), %rsi
leaq 0x18(%rsp), %r12
movq %r12, %rdi
callq 0xd6675
movq $0x0, 0x10(%r12)
movq %r14, 0x8(%rsp)
movq %r14, %rdi
callq 0xbf2b1
movabsq $-0x503db0e6e1c2e704, %r14 # imm = 0xAFC24F191E3D18FC
movq %r12, %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %rax, %rcx
callq 0xd68a8
testq %rbx, %rbx
cmovneq %rbx, %rax
movq 0x8(%rax), %rsi
leaq 0xff095(%rip), %rdi     # 0x130040
movq %rbp, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x109dca
movq %r12, %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %rax, %rcx
callq 0xd68a8
movq %rax, %r12
cmpq $0x0, 0x10(%r13)
je 0x30ff6
xorl %r14d, %r14d
movq 0x8(%r13), %rax
movq (%rax,%r14,8), %rax
movq 0x10(%rax), %rsi
movq %rbp, %rdi
callq 0xdfa34
testl %eax, %eax
je 0x31057
incq %r14
cmpq 0x10(%r13), %r14
jb 0x30fd5
callq 0x2d30b
movq %rax, %rbx
movq %r13, 0x138(%rax)
leaq 0x8(%rax), %rdi
movq %rbp, %rsi
callq 0x109612
leaq 0x28(%rbx), %rdi
movq %r15, %rsi
callq 0x109612
leaq 0x58(%rbx), %rdi
leaq 0xff020(%rip), %rsi     # 0x130048
movq %rbp, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x1097fd
leaq 0x78(%rbx), %rdi
movq %r12, %rsi
callq 0x1094fa
movq (%r13), %rsi
movq %r13, %rdi
movq %rbx, %rdx
callq 0x55b79
movq 0x10(%r13), %r14
decq %r14
movq 0x8(%r13), %rax
movq (%rax,%r14,8), %r13
movq 0x30(%r13), %rdi
movq %r15, %rsi
callq 0xbe959
testl %eax, %eax
je 0x3109c
movq 0x10(%r13), %r8
movq 0x30(%r13), %r9
movq %r15, (%rsp)
leaq 0xfefd6(%rip), %rdi     # 0x130058
leaq 0xfc207(%rip), %rsi     # 0x12d290
leaq 0xfefdf(%rip), %rcx     # 0x13006f
movl $0x17f2, %edx           # imm = 0x17F2
xorl %eax, %eax
callq 0xbe6f9
movq 0x80(%r13), %rdi
testq %r12, %r12
je 0x310af
movq 0x8(%r12), %rsi
jmp 0x310b1
xorl %esi, %esi
movq 0x88(%rsp), %r15
movq 0x80(%rsp), %rbp
callq 0xbe959
testl %eax, %eax
je 0x310ff
movq 0x10(%r13), %r8
movq 0x80(%r13), %r9
movq 0x8(%r12), %rax
movq %rax, (%rsp)
leaq 0xfef73(%rip), %rdi     # 0x130058
leaq 0xfc1a4(%rip), %rsi     # 0x12d290
leaq 0xfefd7(%rip), %rcx     # 0x1300ca
movl $0x17f6, %edx           # imm = 0x17F6
xorl %eax, %eax
callq 0xbe6f9
movq %r13, %rdi
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbp, %rcx
movq %r15, %r8
callq 0x2d653
movq %rax, %rbx
testq %rax, %rax
setne %al
movq 0x90(%rsp), %rdx
testq %rdx, %rdx
sete %cl
orb %al, %cl
jne 0x31135
movq %r14, (%rdx)
leaq 0x18(%rsp), %rdi
callq 0xd6d2c
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq