// File: /workspace/github_c_makefile_star2_O3/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, %bl
cmpb $0x0, (%rdi)
je 0x5ae5
movq %rsi, %r14
movq %rdi, %r13
leaq 0x76f1(%rip), %rsi      # 0xd004
callq 0x2160
testq %rax, %rax
je 0x5ae5
movq %rax, %r15
movl $0x418, %edi            # imm = 0x418
callq 0x2140
movq %rax, %rbx
movl $0x418, %edi            # imm = 0x418
callq 0x2140
movq %rax, %r12
movq %r14, %rdi
movq %r13, %rsi
callq 0x5af6
movq %rbx, %rdi
movl $0x418, %esi            # imm = 0x418
movq %r15, %rdx
callq 0x2110
testq %rax, %rax
je 0x5aaf
leaq 0x8dd1(%rip), %r13      # 0xe73a
leaq 0x8ddd(%rip), %rbp      # 0xe74d
movl $0x8, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2070
testl %eax, %eax
je 0x59e4
movl $0x6, %edx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2070
testl %eax, %eax
je 0x5a7e
movl $0xe, %edx
movq %rbx, %rdi
leaq 0x8da9(%rip), %rsi      # 0xe754
callq 0x2070
testl %eax, %eax
je 0x5a8b
movl $0xa, %edx
movq %rbx, %rdi
leaq 0x8d9c(%rip), %rsi      # 0xe763
callq 0x2070
testl %eax, %eax
jne 0x5a96
movq %r15, %rdi
movq %r14, %rsi
callq 0x5ed0
jmp 0x5a96
movq %rbx, %rdi
movl $0x418, %esi            # imm = 0x418
movq %r15, %rdx
callq 0x2110
testq %rax, %rax
je 0x5acb
movsbl (%rbx), %edi
callq 0x7f3a
testb %al, %al
jne 0x5a96
movabsq $0x636e695f666e6f63, %rax # imm = 0x636E695F666E6F63
movq %rax, (%r12)
movw $0x5f, 0x8(%r12)
movl $0x418, %esi            # imm = 0x418
movq %rbx, %rdi
callq 0x818e
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2180
movsbl (%rbx), %edi
callq 0x7f3a
testb %al, %al
jne 0x5a96
cmpb $0x23, (%rbx)
je 0x5a96
movq %r14, %rdi
movq %r12, %rsi
callq 0x5b57
cmpl $-0x1, %eax
jne 0x5a96
movq %rbx, %rdi
movq %r14, %rsi
callq 0x58f0
movq %rbx, %rdi
movl $0x418, %esi            # imm = 0x418
movq %r15, %rdx
callq 0x2110
testq %rax, %rax
jne 0x5a3b
jmp 0x5acb
movq %r15, %rdi
movq %r14, %rsi
callq 0x5bb0
jmp 0x5a96
movq %r15, %rdi
movq %r14, %rsi
callq 0x5d98
movq %rbx, %rdi
movl $0x418, %esi            # imm = 0x418
movq %r15, %rdx
callq 0x2110
testq %rax, %rax
jne 0x5970
movq %r15, %rdi
callq 0x2090
movq %rbx, %rdi
callq 0x2030
movq %r12, %rdi
callq 0x2030
xorl %ebx, %ebx
jmp 0x5ae5
movq %r15, %rdi
callq 0x2090
movq %r12, %rdi
callq 0x2030
movq %rbx, %rdi
callq 0x2030
movb $0x2, %bl
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq