// File: /workspace/github_c_makefile_star2_O2/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 0xefcb6(%rip), %rax     # 0x117dd0
movq (%rax), %rsi
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x717f5
andq $0x0, 0x10(%r14)
movq %rsp, %r15
movq %r15, %rdi
callq 0x27f42
movabsq $0x10b2ebc3a7c03bbd, %rsi # imm = 0x10B2EBC3A7C03BBD
movq %r14, %rdi
movq %r15, %rdx
callq 0x71998
cmpq $0x2, 0x10(%rbx)
jb 0x28186
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
leaq 0x87037(%rip), %rsi     # 0xaf19c
callq 0x19c6c
testb %al, %al
je 0x2820e
leaq 0xefc6f(%rip), %rax     # 0x117de8
movq (%rax), %rdi
callq 0x280f3
jmp 0x28444
leaq 0x58(%rsp), %rbx
movq %rbx, 0x20(%rsp)
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0x717f5
movq $0x1, 0x10(%rbx)
leaq 0x88(%rsp), %r14
movq %r14, %rdi
callq 0x8e048
movabsq $-0x503db0e6e1c2e704, %rsi # imm = 0xAFC24F191E3D18FC
movq %rbx, %rdi
movq %r14, %rdx
callq 0x71998
movq %r14, %rdi
callq 0x280f3
movq 0x8(%r14), %rsi
pushq $0x1
popq %rdi
callq 0x60533
testq %rax, %rax
je 0x281f7
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x71b64
movl %ebx, %edi
callq 0x2dc20
leaq 0x20(%rsp), %rdi
callq 0x71b48
callq 0x609b0
pushq $0x1
popq %rbx
jmp 0x28446
pushq $0x1
popq %rbp
leaq 0x86f8b(%rip), %r14     # 0xaf1a3
leaq 0x86f87(%rip), %r15     # 0xaf1a6
leaq 0x86f83(%rip), %r12     # 0xaf1a9
cmpq 0x10(%rbx), %rbp
jae 0x2834c
movq 0x8(%rbx), %rax
movq (%rax,%rbp,8), %rdi
movq 0x8(%rdi), %rax
cmpb $0x2d, (%rax)
jne 0x2834c
movq %r14, %rsi
callq 0x19c6c
testb %al, %al
je 0x28262
movq 0x10(%rsp), %rax
movb $0x1, 0x184(%rax)
jmp 0x2833e
movq 0x8(%rbx), %rax
movq (%rax,%rbp,8), %rdi
movq %r15, %rsi
callq 0x19c6c
testb %al, %al
je 0x28287
movq 0x10(%rsp), %rax
movb $0x1, 0x183(%rax)
jmp 0x2833e
movq 0x8(%rbx), %rax
movq (%rax,%rbp,8), %rdi
movq %r12, %rsi
callq 0x19c6c
testb %al, %al
je 0x282ac
movq 0x10(%rsp), %rax
movb $0x1, 0x182(%rax)
jmp 0x2833e
movq 0x8(%rbx), %rax
movq (%rax,%rbp,8), %rdi
leaq 0x86ef1(%rip), %rsi     # 0xaf1ac
callq 0x19c6c
testb %al, %al
je 0x28311
leaq 0x1(%rbp), %r13
cmpq %r13, 0x10(%rbx)
jne 0x282ef
leaq 0x86eda(%rip), %rdi     # 0xaf1af
leaq 0x81fb4(%rip), %rsi     # 0xaa290
movl $0x2b3b, %edx           # imm = 0x2B3B
leaq 0x86ed7(%rip), %rcx     # 0xaf1bf
xorl %eax, %eax
callq 0x60186
movq 0x8(%rbx), %rax
movq 0x8(%rax,%rbp,8), %rdi
callq 0x8efe4
movq %rax, %rbp
movq 0x8(%rsp), %rdi
callq 0x8edd4
movq %rbp, 0x8(%rsp)
jmp 0x28341
movq 0x8(%rbx), %rax
movq (%rax,%rbp,8), %rax
movq 0x8(%rax), %r8
leaq 0x86e8b(%rip), %rdi     # 0xaf1af
leaq 0x81f65(%rip), %rsi     # 0xaa290
movl $0x2b40, %edx           # imm = 0x2B40
leaq 0x86ea1(%rip), %rcx     # 0xaf1d8
xorl %eax, %eax
callq 0x60186
movq %rbp, %r13
incq %r13
movq %r13, %rbp
jmp 0x28226
movq 0x10(%rsp), %rax
cmpb $0x1, 0x184(%rax)
jne 0x28377
leaq 0xefa87(%rip), %rax     # 0x117de8
movq (%rax), %rdi
leaq 0x86e86(%rip), %rsi     # 0xaf1f1
xorl %eax, %eax
callq 0xdd43
movq 0x10(%rsp), %rax
cmpb $0x1, 0x183(%rax)
jne 0x28398
leaq 0xefa61(%rip), %rax     # 0x117de8
movq (%rax), %rdi
leaq 0x86e6d(%rip), %rsi     # 0xaf1fe
xorl %eax, %eax
callq 0xdd43
cmpq 0x10(%rbx), %rbp
jb 0x283ad
leaq 0xefa43(%rip), %rax     # 0x117de8
movq (%rax), %rdi
callq 0x280f3
callq 0xd340
movq %rax, %r14
movq %rsp, %r15
cmpq 0x10(%rbx), %rbp
jae 0x283df
movq 0x8(%rbx), %rax
movq (%rax,%rbp,8), %rax
movq 0x8(%rax), %rsi
movq %r15, %rdi
callq 0x28007
incq %rbp
testq %rax, %rax
je 0x283b8
jmp 0x28201
movq 0x10(%rsp), %rdi
callq 0x1c727
testb %al, %al
je 0x283fe
movq %rsp, %rdi
callq 0x280a4
testq %rax, %rax
jne 0x28201
callq 0xd340
subq %r14, %rax
cvtsi2sd %rax, %xmm0
divsd 0x81c5d(%rip), %xmm0    # 0xaa070
leaq 0xef9ce(%rip), %rax     # 0x117de8
movq (%rax), %rbx
leaq 0x86ded(%rip), %rdi     # 0xaf211
movb $0x1, %al
callq 0x8ebc4
movq %rax, %r14
movq (%rbx), %rdi
callq 0x2d6cb
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x87c18
xorl %ebx, %ebx
leaq 0x28(%rsp), %rdi
callq 0x71b64
movl %ebx, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq