// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movb %dl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
leaq 0x10873f(%rip), %rax    # 0x1b2330
movq (%rax), %rax
movq %rax, -0x28(%rbp)
leaq -0x58(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0xbfe80
movq -0x60(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
callq 0xa9b50
movq -0x18(%rbp), %rdi
callq 0xa96f0
testb $0x1, %al
jne 0xa9c45
movb $0x0, -0x61(%rbp)
movq -0x60(%rbp), %rdi
callq 0xc0720
movb -0x61(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0xa9e8b
movq -0x18(%rbp), %rdi
callq 0x4240
movq %rax, -0x108(%rbp)
cmpq $0x0, -0x108(%rbp)
jne 0xa9c7f
movb $0x0, -0x109(%rbp)
movq -0x60(%rbp), %rdi
callq 0xc0720
movb -0x109(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0xa9e8b
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
movq -0x18(%rbp), %rsi
callq 0xfea50
movq -0x28(%rbp), %rax
movq %rax, -0x148(%rbp)
movb $0x0, %al
callq 0xff2e0
movq -0x148(%rbp), %rdi
movq %rax, %rdx
movabsq $-0x503db0e6e1c2e704, %rsi # imm = 0xAFC24F191E3D18FC
callq 0xc00e0
movq %rax, -0x118(%rbp)
movq -0x108(%rbp), %rdi
callq 0x4260
movq %rax, -0x70(%rbp)
cmpq $0x0, %rax
je 0xa9e3a
movq -0x70(%rbp), %rdi
addq $0x13, %rdi
leaq 0x8d1b3(%rip), %rsi     # 0x136e9e
callq 0xa9ea0
testb $0x1, %al
jne 0xa9e35
movq -0x70(%rbp), %rdi
addq $0x13, %rdi
leaq 0x898c6(%rip), %rsi     # 0x1335cd
callq 0xa9ea0
testb $0x1, %al
jne 0xa9e35
movq -0x118(%rbp), %rdi
movq -0x18(%rbp), %rdx
movq -0x70(%rbp), %rcx
addq $0x13, %rcx
leaq 0x896a2(%rip), %rsi     # 0x1333d0
movb $0x0, %al
callq 0xfec20
movq -0x118(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x100(%rbp), %rsi
callq 0x4410
cmpl $0x0, %eax
jne 0xa9e33
movl -0xe8(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x8000, %eax           # imm = 0x8000
jne 0xa9d84
movq -0x10(%rbp), %rdi
addq $0x40, %rdi
movq -0x118(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x960d0
jmp 0xa9e31
testb $0x1, -0x19(%rbp)
je 0xa9e2f
movl -0xe8(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x4000, %eax           # imm = 0x4000
jne 0xa9e2f
callq 0xa9a00
movq %rax, -0x120(%rbp)
movq -0x120(%rbp), %rdi
movq -0x118(%rbp), %rax
movq 0x8(%rax), %rsi
movb -0x19(%rbp), %al
andb $0x1, %al
movzbl %al, %edx
callq 0xa9bd0
testb $0x1, %al
jne 0xa9dd5
jmp 0xa9e21
movq -0x10(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x120(%rbp), %rsi
leaq -0x138(%rbp), %rdi
callq 0xa9f20
movq -0x150(%rbp), %rdi
leaq -0x138(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xa9ed0
jmp 0xa9e2d
movq -0x120(%rbp), %rdi
callq 0xa9a60
jmp 0xa9e2f
jmp 0xa9e31
jmp 0xa9e33
jmp 0xa9e35
jmp 0xa9cc2
movq -0x108(%rbp), %rdi
callq 0x4360
cmpl $0x0, %eax
je 0xa9e70
movq -0x18(%rbp), %r8
leaq 0xa578f(%rip), %rdi     # 0x14f5e5
leaq 0xa5779(%rip), %rsi     # 0x14f5d6
movl $0x96, %edx
leaq 0xa5791(%rip), %rcx     # 0x14f5fa
movb $0x0, %al
callq 0x9d0f0
movb $0x1, -0x139(%rbp)
movq -0x60(%rbp), %rdi
callq 0xc0720
movb -0x139(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
nopl (%rax)