// File: /workspace/github_c_makefile_star2_O2/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
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
testq %rdi, %rdi
je 0x5b23
movq %rsi, %rbp
movl $0x418, %edi            # imm = 0x418
callq 0x2130
movq %rax, %r15
movl $0x418, %edi            # imm = 0x418
callq 0x2130
movq %rax, %r12
movq %r15, %rdi
movl $0x418, %esi            # imm = 0x418
movq 0x10(%rsp), %rdx
callq 0x2100
testq %rax, %rax
je 0x5b05
pushq $0x1
popq %r13
movq %rbp, 0x8(%rsp)
movsbl (%r15), %edi
callq 0x7ace
testb %al, %al
jne 0x5b05
cmpb $0x23, (%r15)
je 0x5aea
movq %r15, %rdi
leaq 0x8ef9(%rip), %rbx      # 0xe8be
movq %rbx, %rsi
callq 0x2160
testq %rax, %rax
je 0x5b23
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 0x5a05
movb $0x0, -0x1(%r12,%rax)
xorl %edi, %edi
movq %rbx, %rsi
callq 0x2160
testq %rax, %rax
je 0x5b23
xorl %ebp, %ebp
cmpb $0x20, (%rax)
sete %bpl
addq %rax, %rbp
movq %rbp, %rdi
callq 0x20b0
leaq -0x2(%rax), %rcx
xorl %ebx, %ebx
xorl %r14d, %r14d
xorl %edx, %edx
cmpq %rdx, %rax
je 0x5a86
movb (%rbp,%rdx), %sil
leal -0x30(%rsi), %edi
cmpb $0x9, %dil
ja 0x5a5f
movzbl %dil, %edi
addl %edi, %r14d
imull $0xa, %r14d, %edi
cmpq %rdx, %rcx
cmovnel %edi, %r14d
movl %r13d, %ebx
incq %rdx
cmpb $0x6f, %sil
jne 0x5a37
testl %r14d, %r14d
jne 0x5a37
movq %rbp, %rdi
leaq 0x8dad(%rip), %rsi      # 0xe824
callq 0x21b0
testq %rax, %rax
cmovnel %r13d, %ebx
xorl %r14d, %r14d
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x58f1
testl %eax, %eax
js 0x5aad
movq (%rbp), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rax
movl %r14d, 0xc(%rax)
movl %ebx, 0x8(%rax)
jmp 0x5aea
cmpl $-0x1, %eax
jne 0x5aea
pushq $0x10
popq %rdi
callq 0x2130
movq %rax, %rbp
movl $0xff, %edi
callq 0x2130
movq %rax, (%rbp)
movq %rax, %rdi
movq %r12, %rsi
callq 0x2080
movl %r14d, 0xc(%rbp)
movl %ebx, 0x8(%rbp)
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0x68b5
movq %r15, %rdi
movl $0x418, %esi            # imm = 0x418
movq 0x10(%rsp), %rdx
callq 0x2100
testq %rax, %rax
jne 0x59a0
movq %r15, %rdi
callq 0x2030
movq %r12, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2030
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq