// File: /workspace/github_c_makefile_star2_O2/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 0x5881
movq %rsi, %r14
movq %rdi, %r13
leaq 0x7941(%rip), %rsi      # 0xd004
callq 0x2150
testq %rax, %rax
je 0x5881
movq %rax, %r15
movl $0x418, %edi            # imm = 0x418
callq 0x2130
movq %rax, %rbx
movl $0x418, %edi            # imm = 0x418
callq 0x2130
movq %rax, %r12
movq %r14, %rdi
movq %r13, %rsi
callq 0x5892
leaq 0x903a(%rip), %r13      # 0xe73a
pushq $0x8
popq %rbp
movq %rbx, %rdi
movl $0x418, %esi            # imm = 0x418
movq %r15, %rdx
callq 0x2100
testq %rax, %rax
je 0x5867
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x2070
movq %rbx, %rdi
testl %eax, %eax
je 0x5788
leaq 0x9015(%rip), %rsi      # 0xe74d
pushq $0x6
popq %rdx
callq 0x2070
testl %eax, %eax
je 0x582b
movq %rbx, %rdi
leaq 0x9002(%rip), %rsi      # 0xe754
pushq $0xe
popq %rdx
callq 0x2070
testl %eax, %eax
je 0x583b
movq %rbx, %rdi
leaq 0x8ff7(%rip), %rsi      # 0xe763
pushq $0xa
popq %rdx
callq 0x2070
testl %eax, %eax
jne 0x5703
movq %r15, %rdi
movq %r14, %rsi
callq 0x5c66
jmp 0x5703
movl $0x418, %esi            # imm = 0x418
movq %r15, %rdx
callq 0x2100
testq %rax, %rax
je 0x584b
movsbl (%rbx), %edi
callq 0x7ace
testb %al, %al
jne 0x5703
movabsq $0x636e695f666e6f63, %rax # imm = 0x636E695F666E6F63
movq %rax, (%r12)
movw $0x5f, 0x8(%r12)
movl $0x418, %esi            # imm = 0x418
movq %rbx, %rdi
callq 0x7cfb
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2170
movsbl (%rbx), %edi
callq 0x7ace
testb %al, %al
jne 0x5703
cmpb $0x23, (%rbx)
je 0x5703
movq %r14, %rdi
movq %r12, %rsi
callq 0x58f1
cmpl $-0x1, %eax
jne 0x5703
movq %rbx, %rdi
movq %r14, %rsi
callq 0x56a0
movq %rbx, %rdi
movl $0x418, %esi            # imm = 0x418
movq %r15, %rdx
callq 0x2100
testq %rax, %rax
jne 0x57dc
jmp 0x584b
movq %r15, %rdi
movq %r14, %rsi
callq 0x5943
jmp 0x5703
movq %r15, %rdi
movq %r14, %rsi
callq 0x5b32
jmp 0x5703
movq %r15, %rdi
callq 0x2090
movq %r12, %rdi
callq 0x2030
movq %rbx, %rdi
callq 0x2030
movb $0x2, %bl
jmp 0x5881
movq %r15, %rdi
callq 0x2090
movq %rbx, %rdi
callq 0x2030
movq %r12, %rdi
callq 0x2030
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq