// File: /workspace/github_c_makefile_star2_O1/justy989[P]ce/ce_commands.c
// Function: find_files_in_directory_recursively
CeStrNode_t* find_files_in_directory_recursively(const char* directory, CeStrNode_t* node, char** ignore_dirs,
                                                 int* ignore_dir_lens, uint64_t ignore_dir_count){
     char* path = ce_strndup((char*)directory, MAX_PATH_LEN);
     CeListDirResult_t list_dir_result = ce_list_dir(path);

     int64_t path_len = strnlen(path, MAX_PATH_LEN);

    // Strip the search characters at the end of the path if they exist.
#if defined(PLATFORM_WINDOWS)
     if(path_len > 0 && path_len < MAX_PATH_LEN){
         if(path[path_len - 1] == CE_CURRENT_DIR_SEARCH){
             path[path_len - 1] = 0;
             path_len--;
         }
         if(path_len > 0 && path[path_len - 1] == CE_PATH_SEPARATOR){
             path[path_len - 1] = 0;
             path_len--;
         }
     }
#else
     if(path_len > 2){
         if(path[path_len - 1] == CE_CURRENT_DIR_SEARCH){
             path[path_len - 1] = 0;
             path_len--;
         }
         if(path_len > 0 && path[path_len - 1] == CE_PATH_SEPARATOR){
             path[path_len - 1] = 0;
             path_len--;
         }
     }

#endif

     bool path_is_current_dir = false;
#if defined(PLATFORM_WINDOWS)
     path_is_current_dir = path_len == 2 &&
                           path[0] == '.' &&
                           path[1] == '\\';
#else
     path_is_current_dir = path_len == 1 &&
                           path[0] == '.';
#endif


     char full_path[MAX_PATH_LEN];
     for(int64_t i = 0; i < list_dir_result.count; i++){
          if(strcmp(list_dir_result.filenames[i], ".") == 0 ||
             strcmp(list_dir_result.filenames[i], "..") == 0){
              continue;
          }
          int full_path_len = 0;
          if (path_is_current_dir){
              full_path_len = snprintf(full_path, MAX_PATH_LEN, "%s", list_dir_result.filenames[i]);
          }else{
              full_path_len = snprintf(full_path, MAX_PATH_LEN, "%s%c%s", path,
                                       CE_PATH_SEPARATOR, list_dir_result.filenames[i]);
          }
          if(list_dir_result.is_directories[i] && full_path_len < (MAX_PATH_LEN - 3)){
               bool ignore_dir = false;
               for(uint64_t j = 0; j < ignore_dir_count; j++){
                    if(full_path_len >= ignore_dir_lens[j] &&
                       strcmp(full_path + full_path_len - ignore_dir_lens[j], ignore_dirs[j]) == 0){
                        ignore_dir = true;
                        break;
                    }
               }
               if(ignore_dir) continue;
               full_path[full_path_len] = CE_PATH_SEPARATOR;
               full_path[full_path_len + 1] = CE_CURRENT_DIR_SEARCH;
               full_path[full_path_len + 2] = 0;
               node = find_files_in_directory_recursively(full_path, node, ignore_dirs,
                                                          ignore_dir_lens, ignore_dir_count);
          }else{
               CeStrNode_t* new_node = malloc(sizeof(*new_node));
               new_node->string = strdup(full_path);
               new_node->next = NULL;
               node->next = new_node;
               node = new_node;
          }
     }
     ce_free_list_dir_result(&list_dir_result);
     free(path);

     return node;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x448, %rsp            # imm = 0x448
movq %r8, %r14
movq %rcx, %r12
movq %rdx, 0x20(%rsp)
movq %rsi, %rbx
movl $0x400, %esi            # imm = 0x400
callq 0xf9db
movq %rax, %r13
leaq 0x28(%rsp), %rdi
movq %rax, %rsi
callq 0x1090a
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdi
callq 0xd2c0
cmpq $0x3, %rax
jl 0x17605
cmpb $0x2e, -0x1(%r13,%rax)
jne 0x175f4
movb $0x0, -0x1(%r13,%rax)
decq %rax
cmpb $0x2f, -0x1(%r13,%rax)
jne 0x17605
movb $0x0, -0x1(%r13,%rax)
decq %rax
cmpq $0x1, %rax
jne 0x17619
cmpb $0x2e, (%r13)
sete %al
movl %eax, 0x4(%rsp)
jmp 0x17621
movl $0x0, 0x4(%rsp)
cmpq $0x0, 0x28(%rsp)
jle 0x17789
xorl %ebp, %ebp
movq %r13, 0x8(%rsp)
movq 0x30(%rsp), %rax
movq (%rax,%rbp,8), %r15
movq %r15, %rdi
leaq 0x18d3d(%rip), %rsi     # 0x30384
callq 0xd390
testl %eax, %eax
je 0x1777b
movq %r15, %rdi
leaq 0x18d25(%rip), %rsi     # 0x30383
callq 0xd390
testl %eax, %eax
je 0x1777b
cmpb $0x0, 0x4(%rsp)
je 0x1768f
movl $0x400, %esi            # imm = 0x400
leaq 0x40(%rsp), %rdi
leaq 0x1a239(%rip), %rdx     # 0x318bc
movq %r15, %rcx
xorl %eax, %eax
callq 0xd260
jmp 0x176b3
movl $0x400, %esi            # imm = 0x400
leaq 0x40(%rsp), %rdi
leaq 0x1720d(%rip), %rdx     # 0x2e8ad
movq %r13, %rcx
movl $0x2f, %r8d
movq %r15, %r9
xorl %eax, %eax
callq 0xd260
movl %eax, %r15d
cmpl $0x3fc, %eax            # imm = 0x3FC
jg 0x17746
movq 0x38(%rsp), %rax
cmpb $0x0, (%rax,%rbp)
je 0x17746
movq %rbx, 0x10(%rsp)
movslq %r15d, %rax
movq %rax, 0x18(%rsp)
testq %r14, %r14
je 0x17716
movq 0x18(%rsp), %rax
leaq (%rsp,%rax), %r13
addq $0x40, %r13
xorl %ebx, %ebx
movslq (%r12,%rbx,4), %rax
cmpl %eax, %r15d
jl 0x1770e
movq %r13, %rdi
subq %rax, %rdi
movq 0x20(%rsp), %rax
movq (%rax,%rbx,8), %rsi
callq 0xd390
testl %eax, %eax
je 0x17771
incq %rbx
cmpq %rbx, %r14
jne 0x176ed
movq 0x18(%rsp), %rax
movw $0x2e2f, 0x40(%rsp,%rax) # imm = 0x2E2F
movb $0x0, 0x42(%rsp,%rax)
leaq 0x40(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %r12, %rcx
movq %r14, %r8
callq 0x17597
movq %rax, %rbx
jmp 0x17776
movl $0x10, %edi
callq 0xd4c0
movq %rax, %r15
leaq 0x40(%rsp), %rdi
callq 0xd640
movq %rax, (%r15)
movq $0x0, 0x8(%r15)
movq %r15, 0x8(%rbx)
movq %r15, %rbx
jmp 0x1777b
movq 0x10(%rsp), %rbx
movq 0x8(%rsp), %r13
incq %rbp
cmpq 0x28(%rsp), %rbp
jl 0x17634
leaq 0x28(%rsp), %rdi
callq 0x109f7
movq %r13, %rdi
callq 0xd090
movq %rbx, %rax
addq $0x448, %rsp            # imm = 0x448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq