// File: /workspace/github_c_makefile_star2_O3/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 0x5d6b
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 0x5d7a
movsbl (%r15), %edi
callq 0x7f3a
testb %al, %al
jne 0x5d7a
cmpb $0x23, (%r15)
je 0x5be5
movq %r15, %rdi
leaq 0x8c9e(%rip), %rbx      # 0xe8be
movq %rbx, %rsi
callq 0x2170
testq %rax, %rax
je 0x5d6b
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 0x5c60
movb $0x0, -0x1(%r12,%rax)
xorl %edi, %edi
movq %rbx, %rsi
callq 0x2170
testq %rax, %rax
je 0x5d6b
movq %rbp, %r14
xorl %ebp, %ebp
cmpb $0x20, (%rax)
sete %bpl
addq %rax, %rbp
movq %rbp, %rdi
callq 0x20b0
testq %rax, %rax
je 0x5cd8
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 0x5cc4
movzbl %dil, %esi
addl %esi, %ebx
leal (%rbx,%rbx), %esi
cmpq %rdx, %rcx
leal (%rsi,%rsi,4), %esi
cmovel %ebx, %esi
movl $0x1, %r13d
movl %esi, %ebx
jmp 0x5cce
cmpb $0x6f, %sil
jne 0x5cce
testl %ebx, %ebx
je 0x5cdd
incq %rdx
cmpq %rdx, %rax
jne 0x5c9a
jmp 0x5cfa
xorl %r13d, %r13d
jmp 0x5cf8
movq %rbp, %rdi
leaq 0x8b3d(%rip), %rsi      # 0xe824
callq 0x21c0
testq %rax, %rax
movl $0x1, %eax
cmovnel %eax, %r13d
xorl %ebx, %ebx
movq %r14, %rbp
movq %r14, %rdi
movq %r12, %rsi
callq 0x5b57
testl %eax, %eax
js 0x5d22
movq (%rbp), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rax
movl %ebx, 0xc(%rax)
movl %r13d, 0x8(%rax)
jmp 0x5be5
cmpl $-0x1, %eax
jne 0x5be5
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 0x6c26
jmp 0x5be5
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