// File: /workspace/github_c_makefile_star2_O2/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, %r15d
movq %rsi, %rbx
movq %rdi, %r14
leaq 0xb1ca1(%rip), %rax     # 0x117dd0
movq (%rax), %rsi
leaq 0x48(%rsp), %rdi
callq 0x717f5
movq %r14, %rdi
callq 0x660de
movq %rbx, %rdi
callq 0x65f2c
testb %al, %al
je 0x662d7
movq %rbx, %rdi
callq 0xd260
testq %rax, %rax
setne %bpl
je 0x66319
movq %rax, %r12
movl %ebp, 0x18(%rsp)
leaq 0x8(%r14), %rdi
movq %rbx, %rsi
callq 0x8e611
xorl %eax, %eax
callq 0x8eb65
leaq 0x48(%rsp), %rdi
movabsq $-0x503db0e6e1c2e704, %rsi # imm = 0xAFC24F191E3D18FC
movq %rax, %rdx
callq 0x71917
movq %rax, %r13
movq %r14, 0x20(%rsp)
leaq 0x40(%r14), %rax
movq %rax, 0x28(%rsp)
leaq 0x479e1(%rip), %rbp     # 0xadb93
leaq 0x440bc(%rip), %r14     # 0xaa275
xorb $0x1, %r15b
movl %r15d, 0x1c(%rsp)
movq %r12, %rdi
callq 0xd280
testq %rax, %rax
je 0x662e5
movq %rax, %r15
addq $0x13, %r15
movq %r15, %rdi
movq %rbp, %rsi
callq 0x66337
testb %al, %al
jne 0x661c2
movq %r15, %rdi
movq %r14, %rsi
callq 0x66337
testb %al, %al
jne 0x661c2
movq %r13, %rdi
leaq 0x43e76(%rip), %rsi     # 0xaa078
movq %rbx, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x8e7af
movq 0x8(%r13), %rdi
leaq 0x78(%rsp), %rsi
callq 0xd460
testl %eax, %eax
jne 0x661c2
movl 0x90(%rsp), %eax
movl $0xf000, %ecx           # imm = 0xF000
andl %ecx, %eax
cmpl $0x8000, %eax           # imm = 0x8000
jne 0x66249
movq 0x8(%r13), %rsi
movq 0x28(%rsp), %rdi
callq 0x5c59f
jmp 0x661c2
cmpl $0x4000, %eax           # imm = 0x4000
setne %al
orb 0x1c(%rsp), %al
jne 0x661c2
callq 0x6608e
movq %rax, %r15
movq 0x8(%r13), %rsi
movq %rax, %rdi
pushq $0x1
popq %rdx
callq 0x6610e
testb %al, %al
je 0x66285
testq %r15, %r15
je 0x66292
movq (%r15), %rdi
callq 0x8cd25
jmp 0x66294
movq %r15, %rdi
callq 0x6609e
jmp 0x661c2
xorl %eax, %eax
movq %r15, 0x30(%rsp)
movq %rax, 0x38(%rsp)
movq $0x2, 0x40(%rsp)
movq 0x20(%rsp), %r15
movq (%r15), %rdi
callq 0x664c8
movq 0x40(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %rax, %rdi
movq %r15, %rsi
callq 0x7c34a
jmp 0x661c2
leaq 0x48(%rsp), %rdi
callq 0x71b64
xorl %ebp, %ebp
jmp 0x66323
movq %r12, %rdi
callq 0xd3b0
testl %eax, %eax
movl 0x18(%rsp), %ebp
je 0x66319
leaq 0x5cecd(%rip), %rdi     # 0xc31c9
leaq 0x5ceb7(%rip), %rsi     # 0xc31ba
leaq 0x5ced4(%rip), %rcx     # 0xc31de
movl $0x96, %edx
movq %rbx, %r8
xorl %eax, %eax
callq 0x60186
leaq 0x48(%rsp), %rdi
callq 0x71b64
movl %ebp, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq