// File: /workspace/github_c_makefile_star2_O1/johsteffens[P]beth/lib/bcore/bcore_folder.c
// Function: bcore_folder_s_parse
bl_t bcore_folder_s_parse( bcore_folder_s* o, sc_t path, bl_t recurse )
{
    BLM_INIT();
    bcore_folder_s_clear( o );

    if( !bcore_folder_exists( path ) ) BLM_RETURNV( bl_t, false );

    struct dirent* entry;
    struct stat file_stat;

    DIR* dirp = opendir( path );
    if( !dirp ) BLM_RETURNV( bl_t, false );

    st_s_copy_sc( &o->name, path );

    st_s* full_path = BLM_CREATE( st_s );

    while( ( entry = readdir( dirp ) ) )
    {
        if( !sc_t_equ( entry->d_name, "." ) && !sc_t_equ( entry->d_name, ".." ) )
        {
            st_s_copy_fa( full_path, "#<sc_t>/#<sc_t>", path, entry->d_name );
            if( stat( full_path->sc, &file_stat ) == 0 )
            {
                if( S_ISREG( file_stat.st_mode ) ) // regular file
                {
                    bcore_arr_st_s_push_sc( &o->arr_file, full_path->sc );
                }
                else if( recurse && S_ISDIR( file_stat.st_mode ) ) // folder
                {
                    bcore_folder_s* sub_folder = bcore_folder_s_create();
                    if( bcore_folder_s_parse( sub_folder, full_path->sc, recurse ) )
                    {
                        bcore_array_a_push( ( bcore_array* )o, sr_asm( sub_folder ) );
                    }
                    else
                    {
                        bcore_folder_s_discard( sub_folder );
                    }
                }
            }
        }
    }

    if( closedir( dirp ) ) ERR_fa( "Error closing path '#<sc_t>'.", path );

    BLM_RETURNV( bl_t, true );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xd8197(%rip), %rax     # 0x1a8dd0
movq (%rax), %rsi
leaq 0x48(%rsp), %rdi
callq 0xe0431
movq %r14, %rdi
callq 0xd0b54
leaq 0x78(%rsp), %rsi
movq %rbx, %rdi
callq 0xd450
testl %eax, %eax
jne 0xd0ea5
movl $0xf000, %eax           # imm = 0xF000
andl 0x90(%rsp), %eax
cmpl $0x4000, %eax           # imm = 0x4000
jne 0xd0ea5
movq %rbx, %rdi
callq 0xd260
testq %rax, %rax
setne %r15b
je 0xd0ee9
movq %rax, %r12
movl %r15d, 0x1c(%rsp)
movl %ebp, 0x18(%rsp)
leaq 0x8(%r14), %rdi
movq %rbx, %rsi
callq 0x11454b
xorl %eax, %eax
callq 0x114bbb
leaq 0x48(%rsp), %rdi
movabsq $-0x503db0e6e1c2e704, %rsi # imm = 0xAFC24F191E3D18FC
movq %rax, %rdx
callq 0xe0582
movq %rax, %r13
movq %r12, %rdi
callq 0xd280
testq %rax, %rax
je 0xd0eb4
movq %rax, %r15
leaq 0x40(%r14), %rax
movq %rax, 0x28(%rsp)
leaq 0x6aea7(%rip), %rbp     # 0x13bb93
movl 0x18(%rsp), %eax
xorb $0x1, %al
movl %eax, 0x18(%rsp)
addq $0x13, %r15
movq %r15, %rdi
movq %rbp, %rsi
callq 0xe99c9
testl %eax, %eax
je 0xd0e8a
movq %r15, %rdi
leaq 0x6755e(%rip), %rsi     # 0x138275
callq 0xe99c9
testl %eax, %eax
je 0xd0e8a
movq %r13, %rdi
leaq 0x6734a(%rip), %rsi     # 0x138078
movq %rbx, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x114736
movq 0x8(%r13), %rdi
leaq 0x78(%rsp), %rsi
callq 0xd450
testl %eax, %eax
jne 0xd0e8a
movl 0x90(%rsp), %eax
movl $0xf000, %ecx           # imm = 0xF000
andl %ecx, %eax
cmpl $0x8000, %eax           # imm = 0x8000
jne 0xd0d79
movq 0x8(%r13), %rsi
movq 0x28(%rsp), %rdi
callq 0xc3965
jmp 0xd0e8a
cmpl $0x4000, %eax           # imm = 0x4000
setne %al
orb 0x18(%rsp), %al
jne 0xd0e8a
callq 0xd091f
movq %rax, %r15
movq 0x8(%r13), %rsi
movq %rax, %rdi
movl $0x1, %edx
callq 0xd0c19
testb %al, %al
je 0xd0db7
testq %r15, %r15
je 0xd0dc4
movq (%r15), %rdi
callq 0x1123e1
jmp 0xd0dc6
movq %r15, %rdi
callq 0xd09ce
jmp 0xd0e8a
xorl %eax, %eax
movq %r15, 0x30(%rsp)
movq %rax, 0x38(%rsp)
movq $0x2, 0x40(%rsp)
movq (%r14), %rsi
leaq 0xd803d(%rip), %rdx     # 0x1a8e20
movl (%rdx), %eax
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%rdx,%rax,8), %rcx
movq 0x18(%rdx,%rax,8), %rdx
andq %rsi, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %rsi, %rdx
je 0xd0e38
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rsi, %rdx
je 0xd0e38
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rsi, %rdx
je 0xd0e38
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rsi, %rdx
jne 0xd0ea0
movq (%rax,%rcx), %r15
testq %r15, %r15
jne 0xd0e6c
movabsq $-0x5073d588c3beb52e, %rdi # imm = 0xAF8C2A773C414AD2
movq %rsi, 0x20(%rsp)
callq 0xf3f85
movq %rax, %r15
leaq 0xd7fc1(%rip), %rdi     # 0x1a8e20
movq 0x20(%rsp), %rsi
movq %rax, %rdx
callq 0x12128c
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r15, %rdi
movq %r14, %rsi
callq 0xf7857
movq %r12, %rdi
callq 0xd280
movq %rax, %r15
testq %rax, %rax
jne 0xd0cf6
jmp 0xd0eb4
xorl %r15d, %r15d
jmp 0xd0e3c
leaq 0x48(%rsp), %rdi
callq 0xe0b30
xorl %r15d, %r15d
jmp 0xd0ef3
movq %r12, %rdi
callq 0xd3a0
testl %eax, %eax
movl 0x1c(%rsp), %r15d
je 0xd0ee9
leaq 0x7f458(%rip), %rdi     # 0x150324
leaq 0x7f442(%rip), %rsi     # 0x150315
leaq 0x7f45f(%rip), %rcx     # 0x150339
movl $0x96, %edx
movq %rbx, %r8
xorl %eax, %eax
callq 0xc825d
leaq 0x48(%rsp), %rdi
callq 0xe0b30
movl %r15d, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq