// File: /workspace/github_c_makefile_star2_O1/System-Glitch[P]ESGILinter-C/src/conf.c
// Function: load_configuration
char load_configuration(char *filename, arraylist_t *conf) {
    if (strlen(filename) <= 0) return 1;

    FILE *src;
    char *line;
    char *tmp;
    char *get; //fgets return

    src = fopen(filename, "rb");
    if(src == NULL) return 1;

    line = malloc(sizeof(char) * 1048);
    tmp = malloc(sizeof(char) * 1048);

    exclude_conf_file(conf, filename);

    while(fgets(line, 1048, src) != NULL){
        if(strstr(line, "=extends") ==  line){
            get = fgets(line, 1048, src);
            if(get == NULL) { //Unexpected EOF reached
                fclose(src);
                free(tmp);
                free(line);
                return 2;
            }
            if(!is_whitespace(line[0])){
                strcpy(tmp, "conf_inc_");
                strformat(line, 1048);
                strcat(tmp, line);
                while(!is_whitespace(line[0]) && line[0] != '#' && find_rule_index(conf, tmp) == -1 ){
                    load_configuration(line, conf);
                    get = fgets(line, 1048, src);
                    if(get == NULL) { //Unexpected EOF reached
                        fclose(src);
                        free(tmp);
                        free(line);
                        return 2;
                    }
                }
            }
        }else if(strstr(line, "=rules") == line){
            load_rules(src, conf);
        }else if(strstr(line, "=excludedFiles") == line){
            exclude_file(src, conf);
        }else if(strstr(line, "=recursive") == line){
            recursive_activation(src, conf);
        }
    }

    fclose(src);
    free(line);
    free(tmp);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movb $0x1, %bpl
cmpb $0x0, (%rdi)
je 0x5a25
movq %rsi, %r15
movq %rdi, %r13
leaq 0x77a4(%rip), %rsi      # 0xd004
callq 0x2160
testq %rax, %rax
je 0x5a25
movq %rax, %rbx
movl $0x418, %edi            # imm = 0x418
callq 0x2140
movq %rax, %r12
movl $0x418, %edi            # imm = 0x418
callq 0x2140
movq %rax, %r14
movq %r15, %rdi
movq %r13, %rsi
callq 0x5a36
movq %r12, %rdi
movl $0x418, %esi            # imm = 0x418
movq %rbx, %rdx
callq 0x2110
testq %rax, %rax
je 0x5a00
leaq 0x8e87(%rip), %r13      # 0xe73d
movl $0x8, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x2070
testl %eax, %eax
je 0x592e
movl $0x6, %edx
movq %r12, %rdi
leaq 0x8e77(%rip), %rsi      # 0xe750
callq 0x2070
testl %eax, %eax
je 0x59cf
movl $0xe, %edx
movq %r12, %rdi
leaq 0x8e62(%rip), %rsi      # 0xe757
callq 0x2070
testl %eax, %eax
je 0x59dc
movl $0xa, %edx
movq %r12, %rdi
leaq 0x8e55(%rip), %rsi      # 0xe766
callq 0x2070
testl %eax, %eax
jne 0x59e7
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5e0c
jmp 0x59e7
movq %r12, %rdi
movl $0x418, %esi            # imm = 0x418
movq %rbx, %rdx
callq 0x2110
movb $0x2, %bpl
testq %rax, %rax
je 0x5a07
movsbl (%r12), %edi
callq 0x7ed1
testb %al, %al
jne 0x59e7
movabsq $0x636e695f666e6f63, %rax # imm = 0x636E695F666E6F63
movq %rax, (%r14)
movw $0x5f, 0x8(%r14)
movl $0x418, %esi            # imm = 0x418
movq %r12, %rdi
callq 0x8124
movq %r14, %rdi
movq %r12, %rsi
callq 0x2180
movsbl (%r12), %edi
callq 0x7ed1
testb %al, %al
jne 0x59e7
cmpb $0x23, (%r12)
je 0x59e7
movq %r15, %rdi
movq %r14, %rsi
callq 0x5a97
cmpl $-0x1, %eax
jne 0x59e7
movq %r12, %rdi
movq %r15, %rsi
callq 0x583c
movq %r12, %rdi
movl $0x418, %esi            # imm = 0x418
movq %rbx, %rdx
callq 0x2110
testq %rax, %rax
jne 0x5988
jmp 0x5a07
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5af0
jmp 0x59e7
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5cd6
movq %r12, %rdi
movl $0x418, %esi            # imm = 0x418
movq %rbx, %rdx
callq 0x2110
testq %rax, %rax
jne 0x58b6
xorl %ebp, %ebp
movq %r12, %r15
jmp 0x5a0d
movq %r14, %r15
movq %r12, %r14
movq %rbx, %rdi
callq 0x2090
movq %r15, %rdi
callq 0x2030
movq %r14, %rdi
callq 0x2030
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq