// File: /workspace/github_c_makefile_star2_O3/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 0x14db64(%rip), %rax    # 0x19bdd0
movq (%rax), %rsi
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0xd6675
movq $0x0, 0x10(%r14)
movq %rsp, %r15
movq %r15, %rdi
callq 0x4dc10
movabsq $0x10b2ebc3a7c03bbd, %rsi # imm = 0x10B2EBC3A7C03BBD
movq %r14, %rdi
movq %r15, %rdx
callq 0xd68d9
cmpq $0x2, 0x10(%rbx)
jb 0x4e2c5
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x4e351
movq 0x8(%rax), %rdi
jmp 0x4e353
leaq 0x58(%rsp), %rbx
movq %rbx, 0x20(%rsp)
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0xd6675
movq $0x1, 0x10(%rbx)
leaq 0x88(%rsp), %r14
movq %r14, %rdi
callq 0x109030
movabsq $-0x503db0e6e1c2e704, %rsi # imm = 0xAFC24F191E3D18FC
movq %rbx, %rdi
movq %r14, %rdx
callq 0xd68d9
movq %r14, %rdi
callq 0x4e1a2
movq 0x8(%r14), %rsi
movl $0x1, %edi
callq 0xbeb67
testq %rax, %rax
je 0x4e338
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0xd6d2c
movl %ebx, %edi
callq 0x54258
leaq 0x20(%rsp), %rdi
callq 0xd6d0d
callq 0xbf031
movl $0x1, %ebx
jmp 0x4e674
xorl %edi, %edi
leaq 0xe3e42(%rip), %rsi     # 0x13219c
callq 0xbe959
testl %eax, %eax
je 0x4e4d6
movl $0x1, %ebp
cmpq $0x2, 0x10(%rbx)
jb 0x4e4ed
movl $0x1, %r13d
leaq 0xe3e1f(%rip), %r14     # 0x1321a3
leaq 0xe3e1b(%rip), %r15     # 0x1321a6
leaq 0xe3e17(%rip), %r12     # 0x1321a9
movq 0x8(%rbx), %rax
movq (%rax,%r13,8), %rax
movq 0x8(%rax), %rdi
cmpb $0x2d, (%rdi)
jne 0x4e4ea
movq %r14, %rsi
callq 0xbe959
testl %eax, %eax
je 0x4e3c6
movq 0x8(%rbx), %rax
movq (%rax,%r13,8), %rax
testq %rax, %rax
je 0x4e3d7
movq 0x8(%rax), %rdi
jmp 0x4e3d9
movq 0x10(%rsp), %rax
movb $0x1, 0x184(%rax)
jmp 0x4e474
xorl %edi, %edi
movq %r15, %rsi
callq 0xbe959
testl %eax, %eax
je 0x4e3f8
movq 0x8(%rbx), %rax
movq (%rax,%r13,8), %rax
testq %rax, %rax
je 0x4e406
movq 0x8(%rax), %rdi
jmp 0x4e408
movq 0x10(%rsp), %rax
movb $0x1, 0x183(%rax)
jmp 0x4e474
xorl %edi, %edi
movq %r12, %rsi
callq 0xbe959
testl %eax, %eax
je 0x4e427
movq 0x8(%rbx), %rax
movq (%rax,%r13,8), %rax
testq %rax, %rax
je 0x4e435
movq 0x8(%rax), %rdi
jmp 0x4e437
movq 0x10(%rsp), %rax
movb $0x1, 0x182(%rax)
jmp 0x4e474
xorl %edi, %edi
leaq 0xe3d6e(%rip), %rsi     # 0x1321ac
callq 0xbe959
testl %eax, %eax
je 0x4e489
movq 0x8(%rbx), %rax
movq (%rax,%r13,8), %rax
movq 0x8(%rax), %r8
leaq 0xe3d55(%rip), %rdi     # 0x1321af
leaq 0xdee2f(%rip), %rsi     # 0x12d290
movl $0x2b40, %edx           # imm = 0x2B40
leaq 0xe3d6b(%rip), %rcx     # 0x1321d8
xorl %eax, %eax
callq 0xbe6f9
movq %r13, %rbp
incq %rbp
movq %rbp, %r13
cmpq 0x10(%rbx), %rbp
jb 0x4e392
jmp 0x4e4ed
leaq 0x1(%r13), %rbp
cmpq %rbp, 0x10(%rbx)
jne 0x4e4b4
leaq 0xe3d15(%rip), %rdi     # 0x1321af
leaq 0xdedef(%rip), %rsi     # 0x12d290
movl $0x2b3b, %edx           # imm = 0x2B3B
leaq 0xe3d12(%rip), %rcx     # 0x1321bf
xorl %eax, %eax
callq 0xbe6f9
movq 0x8(%rbx), %rax
movq 0x8(%rax,%r13,8), %rdi
callq 0x10a2da
movq %rax, %r13
movq 0x8(%rsp), %rdi
callq 0x10a028
movq %r13, 0x8(%rsp)
jmp 0x4e477
leaq 0x14d90b(%rip), %rax    # 0x19bde8
movq (%rax), %rdi
callq 0x4e1a2
jmp 0x4e672
movq %r13, %rbp
movq 0x10(%rsp), %rax
cmpb $0x1, 0x184(%rax)
jne 0x4e518
leaq 0x14d8e6(%rip), %rax    # 0x19bde8
movq (%rax), %rdi
leaq 0xe3ce5(%rip), %rsi     # 0x1321f1
xorl %eax, %eax
callq 0xed3f
movq 0x10(%rsp), %rax
cmpb $0x1, 0x183(%rax)
jne 0x4e539
leaq 0x14d8c0(%rip), %rax    # 0x19bde8
movq (%rax), %rdi
leaq 0xe3ccc(%rip), %rsi     # 0x1321fe
xorl %eax, %eax
callq 0xed3f
cmpq 0x10(%rbx), %rbp
jb 0x4e54e
leaq 0x14d8a2(%rip), %rax    # 0x19bde8
movq (%rax), %rdi
callq 0x4e1a2
callq 0xd340
movq %rax, %r14
cmpq 0x10(%rbx), %rbp
jae 0x4e585
movq %rsp, %r15
movq 0x8(%rbx), %rax
movq (%rax,%rbp,8), %rax
movq 0x8(%rax), %rsi
movq %r15, %rdi
callq 0x4e0b5
testq %rax, %rax
jne 0x4e342
incq %rbp
cmpq 0x10(%rbx), %rbp
jb 0x4e55f
movq 0x10(%rsp), %rdi
callq 0x3120e
testb %al, %al
je 0x4e5a4
movq %rsp, %rdi
callq 0x4e153
testq %rax, %rax
jne 0x4e342
callq 0xd340
subq %r14, %rax
cvtsi2sd %rax, %xmm0
divsd 0xdeab7(%rip), %xmm0    # 0x12d070
leaq 0x14d828(%rip), %rax    # 0x19bde8
movq (%rax), %rbx
leaq 0xe3c47(%rip), %rdi     # 0x132211
movb $0x1, %al
callq 0x109ce5
movq %rax, %r14
movq (%rbx), %r15
leaq 0x14e4d2(%rip), %rax    # 0x19cab0
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 0x4e634
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r15, %rdx
je 0x4e634
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r15, %rdx
je 0x4e634
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r15, %rdx
jne 0x4e63d
movq (%rax,%rcx), %r12
testq %r12, %r12
jne 0x4e664
movabsq $0x5ea8cabb93ff3b7e, %rdi # imm = 0x5EA8CABB93FF3B7E
movq %r15, %rsi
callq 0xe9bc5
movq %rax, %r12
leaq 0x14e457(%rip), %rdi    # 0x19cab0
movq %r15, %rsi
movq %rax, %rdx
callq 0x115fac
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0xfe558
xorl %ebx, %ebx
leaq 0x28(%rsp), %rdi
callq 0xd6d2c
movl %ebx, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq