// File: /workspace/github_c_makefile_star2_O2/System-Glitch[P]ESGILinter-C/src/fileloader.c
// Function: search_files
void search_files(arraylist_t *conf, arraylist_t *files, char *path){
    if(!conf) return;

    struct dirent *read;
    DIR *rep;
    char *ext = NULL;
    char *name;

    rep = opendir(path);
    while ((read = readdir(rep))) {
        if(read->d_type == 8){
            ext = strsubstr(read->d_name, strlen(read->d_name)-2,2);
            if((strcmp(ext,".c") == 0 || strcmp(ext,".h") == 0) && is_excluded(conf, read->d_name) == 0){
                name = malloc(sizeof(char) * 1048);
                if(strcmp(path, ".") == 0){
                    strcpy(name,read->d_name);
                }else{
                    strcpy(name, path);
                    strcat(name,"/");
                    strcat(name, read->d_name);
                }
                arraylist_add(files, name);
            }
            free(ext);
            ext = NULL;
        }else if(read->d_type == 4 && strcmp(read->d_name,".") != 0 && strcmp(read->d_name,"..") != 0 && is_recursive(conf) != 0){

            if(strcmp(path, ".") == 0){
                strcpy(path, read->d_name);
            }else{
                strcat(path, "/");
                strcat(path, read->d_name);
            }
            search_files(conf, files, path);
        }
    }
    if(strindexof(path, '/') != -1){
        ext = strsubstr(path, 0, strlastindexof(path, '/'));
        strcpy(path, ext);
        free(ext);

    }else{
        strcpy(path,".");
    }
    closedir(rep);
}

// Assembly:
testq %rdi, %rdi
je 0x2a02
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r12
movq %rdx, %rdi
callq 0x20a0
movq %rax, %r14
movq %r14, %rdi
callq 0x2120
testq %rax, %rax
je 0x29c3
movq %rax, %r13
movzbl 0x12(%rax), %eax
cmpl $0x4, %eax
je 0x2937
cmpl $0x8, %eax
jne 0x2867
addq $0x13, %r13
movq %r13, %rdi
callq 0x20b0
leal -0x2(%rax), %esi
movq %r13, %rdi
pushq $0x2
popq %rdx
callq 0x79a6
movq %rax, %rbp
cmpb $0x2e, (%rax)
jne 0x292a
cmpb $0x63, 0x1(%rbp)
jne 0x28bb
cmpb $0x0, 0x2(%rbp)
je 0x28c7
cmpb $0x68, 0x1(%rbp)
jne 0x292a
cmpb $0x0, 0x2(%rbp)
jne 0x292a
movq %r12, %rdi
movq %r13, %rsi
callq 0x5e2c
testl %eax, %eax
jne 0x292a
movq %r15, (%rsp)
movl $0x418, %edi            # imm = 0x418
callq 0x2130
movq %rax, %r15
cmpb $0x2e, (%rbx)
jne 0x28f6
cmpb $0x0, 0x1(%rbx)
je 0x29b3
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2080
movq %r15, %rdi
callq 0x20b0
movw $0x2f, (%r15,%rax)
movq %r15, %rdi
movq %r13, %rsi
callq 0x2170
movq (%rsp), %rdi
movq %r15, %rsi
movq %rdi, %r15
callq 0x68b5
movq %rbp, %rdi
callq 0x2030
jmp 0x2867
cmpb $0x2e, 0x13(%r13)
jne 0x295b
cmpb $0x0, 0x14(%r13)
je 0x2867
cmpb $0x2e, 0x14(%r13)
jne 0x295b
cmpb $0x0, 0x15(%r13)
je 0x2867
movq %r12, %rdi
callq 0x5d6f
testl %eax, %eax
je 0x2867
addq $0x13, %r13
cmpb $0x2e, (%rbx)
jne 0x297a
cmpb $0x0, 0x1(%rbx)
je 0x29a6
movq %rbx, %rdi
callq 0x20b0
movw $0x2f, (%rbx,%rax)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2170
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x283f
jmp 0x2867
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2080
jmp 0x2993
movq %r15, %rdi
movq %r13, %rsi
callq 0x2080
jmp 0x291b
pushq $0x2f
popq %rsi
movq %rbx, %rdi
callq 0x7b48
cmpl $-0x1, %eax
je 0x2a03
pushq $0x2f
popq %rsi
movq %rbx, %rdi
callq 0x7b78
movq %rbx, %rdi
xorl %esi, %esi
movl %eax, %edx
callq 0x79a6
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2080
movq %r15, %rdi
callq 0x2030
jmp 0x2a08
retq
movw $0x2e, (%rbx)
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20f0