// File: /workspace/github_c_makefile_star2_O1/johsteffens[P]beth/xoico/src/xoico.xo.c
// Function: xoico_main_main
s2_t xoico_main_main( const bcore_arr_st_s* args )
{
    // xoico_main.x:40:1
    BLM_INIT_LEVEL(0);
    xoico_builder_main_s builder_main;BLM_T_INIT_SPUSH(xoico_builder_main_s, &builder_main);;
    er_t er = 0;
    
    sz_t arg_idx = 1;
    
    if( args->size > 1 )
    {
        if( st_s_equal_sc(args->data[ arg_idx ],"--help" ) )
        {
            xoico_main_help(x_sink_stdout() );
        }
        else
        {
            while( arg_idx < args->size && args->data[ arg_idx ]->sc[ 0 ] == '-' )
            {
                if( st_s_equal_sc(args->data[ arg_idx ],"-d" ) )
                {
                    BLM_TRY_EXIT(xoico_builder_main_s_set_dry_run(&(builder_main),true ))
                }
                else if( st_s_equal_sc(args->data[ arg_idx ],"-e" ) )
                {
                    BLM_TRY_EXIT(xoico_builder_main_s_set_always_expand(&(builder_main),true ))
                }
                else if( st_s_equal_sc(args->data[ arg_idx ],"-f" ) )
                {
                    BLM_TRY_EXIT(xoico_builder_main_s_set_overwrite_unsigned_target_files(&(builder_main),true ))
                }
                else if( st_s_equal_sc(args->data[ arg_idx ],"-O" ) )
                {
                    arg_idx++;
                    if( args->size == arg_idx ) ERR_fa( "Output folder expected.\n" );
                    st_s_attach( &(builder_main.output_folder ),  st_s_clone(args->data[ arg_idx ]));
                }
                else
                {
                    ERR_fa( "Invalid option: #<sc_t>\n", args->data[ arg_idx ]->sc );
                }
                arg_idx++;
            }
    
            if( xoico_builder_main_s_get_dry_run(&(builder_main)) )
            {
                x_sink_push_fa(x_sink_stdout(),"Dry run ...\n" );
            }
    
            if( xoico_builder_main_s_get_always_expand(&(builder_main)) )
            {
                x_sink_push_fa(x_sink_stdout(),"Expanding all ...\n" );
            }
    
            if( arg_idx >= args->size ) xoico_main_help(x_sink_stdout() );
            clock_t time = clock();
    
            for(sz_t i = arg_idx; i < args->size; i++ )
            {
                if( ( er = xoico_builder_main_s_build_from_file(&(builder_main),args->data[ i ]->sc ) ) ) break;
            }
    
            if( !er && xoico_builder_main_s_update_required(&(builder_main)) )
            {
                er = xoico_builder_main_s_update(&(builder_main));
            }
    
            if( !er )
            {
                f3_t time_var = clock() - time;
                time_var /= CLOCKS_PER_SEC;
                x_sink_push_st_d(x_sink_stdout(),st_s_createf("Finished after %.3f seconds.\n", time_var ) );
            }
        }
    }
    else
    {BLM_INIT_LEVEL(1);
        er = 1;
        st_s st;BLM_T_INIT_SPUSH(st_s, &st);;
        xoico_main_help(((x_sink*)(&(st ))));
        BLM_TRY_EXIT(bcore_error_push_sc(er, st.sc ))
    BLM_DOWN();}
    
    if( er ) bcore_error_pop_all_to_stderr();
    
    BLM_RETURNV(s2_t, ( er > 0 ) ? 1 : 0)
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %rbx
leaq 0x15547b(%rip), %rax    # 0x1a8dd0
movq (%rax), %rsi
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0xe0431
movq $0x0, 0x10(%r14)
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x532b9
movabsq $0x10b2ebc3a7c03bbd, %rsi # imm = 0x10B2EBC3A7C03BBD
movq %r14, %rdi
movq %r15, %rdx
callq 0xe06ab
cmpq $0x2, 0x10(%rbx)
jb 0x539b0
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x53a2e
movq 0x8(%rax), %rdi
jmp 0x53a30
leaq 0x78(%rsp), %rdi
movq %rdi, (%rsp)
leaq 0x28(%rsp), %rsi
callq 0xe0431
movq (%rsp), %rbx
movq $0x1, 0x10(%rbx)
leaq 0x58(%rsp), %r14
movq %r14, %rdi
callq 0x113f7c
movabsq $-0x503db0e6e1c2e704, %rsi # imm = 0xAFC24F191E3D18FC
movq %rbx, %rdi
movq %r14, %rdx
callq 0xe06ab
movq %r14, %rdi
callq 0x53886
movq 0x8(%r14), %rsi
movl $0x1, %edi
callq 0xc86db
testq %rax, %rax
je 0x53a1f
movq %rax, %rbx
movq (%rsp), %rdi
callq 0xe0b30
movl %ebx, %edi
callq 0x59990
movq %rsp, %rdi
callq 0xe0b11
xorl %ebp, %ebp
jmp 0x53d67
xorl %edi, %edi
leaq 0xe9765(%rip), %rsi     # 0x13d19c
callq 0xc84cd
testl %eax, %eax
je 0x53bba
movl $0x1, %ebp
cmpq $0x2, 0x10(%rbx)
jb 0x53bd4
movl $0x1, %r13d
leaq 0xe9742(%rip), %r14     # 0x13d1a3
leaq 0xe973e(%rip), %r15     # 0x13d1a6
leaq 0xe973a(%rip), %r12     # 0x13d1a9
movq 0x8(%rbx), %rax
movq (%rax,%r13,8), %rax
movq 0x8(%rax), %rdi
cmpb $0x2d, (%rdi)
jne 0x53bd1
testq %rax, %rax
cmoveq %rax, %rdi
movq %r14, %rsi
callq 0xc84cd
testl %eax, %eax
je 0x53aaa
movq 0x8(%rbx), %rax
movq (%rax,%r13,8), %rax
testq %rax, %rax
je 0x53abb
movq 0x8(%rax), %rdi
jmp 0x53abd
movq 0x18(%rsp), %rax
movb $0x1, 0x184(%rax)
jmp 0x53b58
xorl %edi, %edi
movq %r15, %rsi
callq 0xc84cd
testl %eax, %eax
je 0x53adc
movq 0x8(%rbx), %rax
movq (%rax,%r13,8), %rax
testq %rax, %rax
je 0x53aea
movq 0x8(%rax), %rdi
jmp 0x53aec
movq 0x18(%rsp), %rax
movb $0x1, 0x183(%rax)
jmp 0x53b58
xorl %edi, %edi
movq %r12, %rsi
callq 0xc84cd
testl %eax, %eax
je 0x53b0b
movq 0x8(%rbx), %rax
movq (%rax,%r13,8), %rax
testq %rax, %rax
je 0x53b19
movq 0x8(%rax), %rdi
jmp 0x53b1b
movq 0x18(%rsp), %rax
movb $0x1, 0x182(%rax)
jmp 0x53b58
xorl %edi, %edi
leaq 0xe968a(%rip), %rsi     # 0x13d1ac
callq 0xc84cd
testl %eax, %eax
je 0x53b6d
movq 0x8(%rbx), %rax
movq (%rax,%r13,8), %rax
movq 0x8(%rax), %r8
leaq 0xe9671(%rip), %rdi     # 0x13d1af
leaq 0xe474b(%rip), %rsi     # 0x138290
movl $0x2b40, %edx           # imm = 0x2B40
leaq 0xe9687(%rip), %rcx     # 0x13d1d8
xorl %eax, %eax
callq 0xc825d
movq %r13, %rbp
incq %rbp
movq %rbp, %r13
cmpq 0x10(%rbx), %rbp
jb 0x53a6f
jmp 0x53bd4
leaq 0x1(%r13), %rbp
cmpq %rbp, 0x10(%rbx)
jne 0x53b98
leaq 0xe9631(%rip), %rdi     # 0x13d1af
leaq 0xe470b(%rip), %rsi     # 0x138290
movl $0x2b3b, %edx           # imm = 0x2B3B
leaq 0xe962e(%rip), %rcx     # 0x13d1bf
xorl %eax, %eax
callq 0xc825d
movq 0x8(%rbx), %rax
movq 0x8(%rax,%r13,8), %rdi
callq 0x115213
movq %rax, %r13
movq 0x10(%rsp), %rdi
callq 0x114f61
movq %r13, 0x10(%rsp)
jmp 0x53b5b
leaq 0x155227(%rip), %rax    # 0x1a8de8
movq (%rax), %rdi
callq 0x53886
movb $0x1, %bpl
jmp 0x53d67
movq %r13, %rbp
movq 0x18(%rsp), %rax
cmpb $0x1, 0x184(%rax)
jne 0x53bfa
leaq 0x1551ff(%rip), %rax    # 0x1a8de8
movq (%rax), %rdi
leaq 0xe95fe(%rip), %rsi     # 0x13d1f1
xorl %eax, %eax
callq 0xee2a
movq 0x18(%rsp), %rax
cmpb $0x1, 0x183(%rax)
jne 0x53c20
leaq 0x1551d9(%rip), %rax    # 0x1a8de8
movq (%rax), %rdi
leaq 0xe95e5(%rip), %rsi     # 0x13d1fe
xorl %eax, %eax
callq 0xee2a
cmpq 0x10(%rbx), %rbp
jb 0x53c35
leaq 0x1551bb(%rip), %rax    # 0x1a8de8
movq (%rax), %rdi
callq 0x53886
callq 0xd340
movq %rax, %r14
cmpq 0x10(%rbx), %rbp
jae 0x53c6a
leaq 0x8(%rsp), %r15
movq 0x8(%rbx), %rax
movq (%rax,%rbp,8), %rax
movq 0x8(%rax), %rsi
movq %r15, %rdi
callq 0x5377b
testq %rax, %rax
jne 0x53c8e
incq %rbp
cmpq 0x10(%rbx), %rbp
jb 0x53c48
movq 0x18(%rsp), %rdi
callq 0x3335c
movb $0x1, %bpl
testb %al, %al
je 0x53c90
leaq 0x8(%rsp), %rdi
callq 0x53845
testq %rax, %rax
sete %bpl
jmp 0x53c90
xorl %ebp, %ebp
testb %bpl, %bpl
je 0x53d67
callq 0xd340
subq %r14, %rax
cvtsi2sd %rax, %xmm0
divsd 0xe43c2(%rip), %xmm0    # 0x138070
leaq 0x155133(%rip), %rax    # 0x1a8de8
movq (%rax), %rbx
leaq 0xe9552(%rip), %rdi     # 0x13d211
movb $0x1, %al
callq 0x114c1e
movq %rax, %r14
movq (%rbx), %r15
leaq 0x155ddd(%rip), %rax    # 0x1a9ab0
movl (%rax), %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x20(%rax,%rcx,8), %rdx
movq 0x18(%rax,%rcx,8), %rcx
andq %r15, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %r15, %rdx
je 0x53d29
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r15, %rdx
je 0x53d29
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r15, %rdx
je 0x53d29
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r15, %rdx
jne 0x53d97
movq (%rax,%rcx), %r12
testq %r12, %r12
jne 0x53d59
movabsq $0x5ea8cabb93ff3b7e, %rdi # imm = 0x5EA8CABB93FF3B7E
movq %r15, %rsi
callq 0xf3f85
movq %rax, %r12
leaq 0x155d62(%rip), %rdi    # 0x1a9ab0
movq %r15, %rsi
movq %rax, %rdx
callq 0x12128c
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x1090f0
testb %bpl, %bpl
jne 0x53d71
callq 0xc8ba5
xorb $0x1, %bpl
movzbl %bpl, %ebx
leaq 0x28(%rsp), %rdi
callq 0xe0b30
movl %ebx, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r12d, %r12d
jmp 0x53d2d