// File: /workspace/github_c_makefile_star2_O1/System-Glitch[P]ESGILinter-C/src/conf.c
// Function: load_rules
void load_rules(FILE *src, arraylist_t *conf){
    if(src == NULL) return;
    char *line;
    char *name;
    char *tmp;
    char *get; //fgets return
    int sum;
    int enable;
    int found;
    size_t length;
    rule_t *e;
    const char equal[2] = "=";

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

    get = fgets(line, 1048, src);
    if(get == NULL) { //Unexpected EOF reached
        free(line);
        free(name);
        return;
    }
    while(!is_whitespace(line[0])){
        if(line[0] != '#'){
            tmp = strtok(line, equal);
            if(tmp == NULL) return;

            if(line[1] == ' '){
                strcpy(name, tmp+2);
            }else{
                strcpy(name, tmp+1);
            }

            if(name[strlen(name) -1 ] == ' '){
                name[strlen(name) -1 ] = '\0';
            }

            tmp = strtok(NULL, equal);
            if(tmp == NULL) return;

            if(tmp[0] == ' ') tmp = tmp+1;
            sum = 0;
            enable = 0;
            length = strlen(tmp);
            for(size_t i = 0; i  < length ; i++){
                if(tmp[i] >= 48 && tmp[i] <= 57){
                    sum += (tmp[i]-48);
                    if(i != strlen(tmp) -2){
                        sum *= 10;
                    }
                    enable = 1;
                }
                if(sum == 0 && tmp[i] == 'o'){
                    if(strstr(tmp, "on")) {
                        enable = 1;
                        break;
                    }else{
                        break;
                    }
                }
            }
            found = find_rule_index(conf, name);
            if(found >= 0){
                ((rule_t*)(conf->array[found]))->value = sum;
                ((rule_t*)(conf->array[found]))->enable= enable;
            }else if(found == -1){
                e = malloc(sizeof(rule_t));
                e->name = malloc(sizeof(char) * 255);
                strcpy(e->name, name);
                e->value = sum;
                e->enable = enable;
                arraylist_add(conf, e);
            }
        }
        get = fgets(line, 1048, src);
        if(get == NULL) break;
    }
    free(line);
    free(name);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, (%rsp)
testq %rdi, %rdi
je 0x5ca9
movq %rsi, %rbp
movl $0x418, %edi            # imm = 0x418
callq 0x2140
movq %rax, %r15
movl $0x418, %edi            # imm = 0x418
callq 0x2140
movq %rax, %r12
movq %r15, %rdi
movl $0x418, %esi            # imm = 0x418
movq (%rsp), %rdx
callq 0x2110
testq %rax, %rax
je 0x5cb8
movsbl (%r15), %edi
callq 0x7ed1
testb %al, %al
jne 0x5cb8
cmpb $0x23, (%r15)
je 0x5b25
movq %r15, %rdi
leaq 0x8d6e(%rip), %rbx      # 0xe8ce
movq %rbx, %rsi
callq 0x2170
testq %rax, %rax
je 0x5ca9
xorl %ecx, %ecx
cmpb $0x20, 0x1(%r15)
sete %cl
leaq (%rcx,%rax), %rsi
incq %rsi
movq %r12, %rdi
callq 0x2080
movq %r12, %rdi
callq 0x20b0
cmpb $0x20, -0x1(%r12,%rax)
jne 0x5ba0
movb $0x0, -0x1(%r12,%rax)
xorl %edi, %edi
movq %rbx, %rsi
callq 0x2170
testq %rax, %rax
je 0x5ca9
movq %rbp, %r14
xorl %ebp, %ebp
cmpb $0x20, (%rax)
sete %bpl
addq %rax, %rbp
movq %rbp, %rdi
callq 0x20b0
testq %rax, %rax
je 0x5c16
leaq -0x2(%rax), %rcx
xorl %edx, %edx
xorl %ebx, %ebx
xorl %r13d, %r13d
movb (%rbp,%rdx), %sil
leal -0x30(%rsi), %edi
cmpb $0x9, %dil
ja 0x5c02
movzbl %dil, %edi
addl %edi, %ebx
leal (%rbx,%rbx), %edi
cmpq %rdx, %rcx
leal (%rdi,%rdi,4), %edi
cmovel %ebx, %edi
movl $0x1, %r13d
movl %edi, %ebx
cmpb $0x6f, %sil
jne 0x5c0c
testl %ebx, %ebx
je 0x5c1b
incq %rdx
cmpq %rdx, %rax
jne 0x5bda
jmp 0x5c38
xorl %r13d, %r13d
jmp 0x5c36
movq %rbp, %rdi
leaq 0x8c02(%rip), %rsi      # 0xe827
callq 0x21c0
testq %rax, %rax
movl $0x1, %eax
cmovnel %eax, %r13d
xorl %ebx, %ebx
movq %r14, %rbp
movq %r14, %rdi
movq %r12, %rsi
callq 0x5a97
testl %eax, %eax
js 0x5c60
movq (%rbp), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rax
movl %ebx, 0xc(%rax)
movl %r13d, 0x8(%rax)
jmp 0x5b25
cmpl $-0x1, %eax
jne 0x5b25
movl $0x10, %edi
callq 0x2140
movq %rax, %rbp
movl $0xff, %edi
callq 0x2140
movq %rax, (%rbp)
movq %rax, %rdi
movq %r12, %rsi
callq 0x2080
movl %ebx, 0xc(%rbp)
movl %r13d, 0x8(%rbp)
movq %r14, %rdi
movq %rbp, %rsi
movq %r14, %rbp
callq 0x6b96
jmp 0x5b25
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x2030
movq %r12, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2030