// File: /workspace/github_c_makefile_star2_O1/erikdubbelboer[P]discnt/src/config.c
// Function: rewriteConfigReadOldFile
struct rewriteConfigState *rewriteConfigReadOldFile(char *path) {
    FILE *fp = fopen(path,"r");
    struct rewriteConfigState *state = zmalloc(sizeof(*state));
    char buf[CONFIG_MAX_LINE+1];
    int linenum = -1;

    if (fp == NULL && errno != ENOENT) return NULL;

    state->option_to_line = dictCreate(&optionToLineDictType,NULL);
    state->rewritten = dictCreate(&optionSetDictType,NULL);
    state->numlines = 0;
    state->lines = NULL;
    state->has_tail = 0;
    if (fp == NULL) return state;

    /* Read the old file line by line, populate the state. */
    while(fgets(buf,CONFIG_MAX_LINE+1,fp) != NULL) {
        int argc;
        sds *argv;
        sds line = sdstrim(sdsnew(buf),"\r\n\t ");

        linenum++; /* Zero based, so we init at -1 */

        /* Handle comments and empty lines. */
        if (line[0] == '#' || line[0] == '\0') {
            if (!state->has_tail && !strcmp(line,DISCNT_CONFIG_REWRITE_SIGNATURE))
                state->has_tail = 1;
            rewriteConfigAppendLine(state,line);
            continue;
        }

        /* Not a comment, split into arguments. */
        argv = sdssplitargs(line,&argc);
        if (argv == NULL) {
            /* Apparently the line is unparsable for some reason, for
             * instance it may have unbalanced quotes. Load it as a
             * comment. */
            sds aux = sdsnew("# ??? ");
            aux = sdscatsds(aux,line);
            sdsfree(line);
            rewriteConfigAppendLine(state,aux);
            continue;
        }

        sdstolower(argv[0]); /* We only want lowercase config directives. */

        /* Now we populate the state according to the content of this line.
         * Append the line and populate the option -> line numbers map. */
        rewriteConfigAppendLine(state,line);
        rewriteConfigAddLineNumberToOption(state,argv[0],linenum);

        sdsfreesplitres(argv,argc);
    }
    fclose(fp);
    return state;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x418, %rsp            # imm = 0x418
leaq 0x2ba2c(%rip), %rsi     # 0x547f5
callq 0x12500
movq %rax, %r14
movl $0x28, %edi
callq 0x1fea5
movq %rax, %rbx
testq %r14, %r14
jne 0x28df1
callq 0x120d0
cmpl $0x2, (%rax)
jne 0x28fab
leaq 0x46158(%rip), %rdi     # 0x6ef50
xorl %r15d, %r15d
xorl %esi, %esi
callq 0x18875
movq %rax, (%rbx)
leaq 0x46174(%rip), %rdi     # 0x6ef80
xorl %esi, %esi
callq 0x18875
movq %rax, 0x8(%rbx)
movl %r15d, 0x10(%rbx)
movq $0x0, 0x18(%rbx)
movl %r15d, 0x20(%rbx)
testq %r14, %r14
je 0x28fad
leaq 0x10(%rsp), %rdi
movl $0x401, %esi            # imm = 0x401
movq %r14, %rdx
callq 0x12470
testq %rax, %rax
je 0x28fa1
xorl %ebp, %ebp
leaq 0x10(%rsp), %r15
leaq 0x2cf7e(%rip), %r12     # 0x55dd7
movq %r14, 0x8(%rsp)
movq %r15, %rdi
callq 0x1de62
movq %rax, %rdi
movq %r12, %rsi
callq 0x1f248
movq %rax, %r13
movzbl (%rax), %eax
cmpl $0x23, %eax
je 0x28e80
testl %eax, %eax
jne 0x28ecc
cmpl $0x0, 0x20(%rbx)
jne 0x28ea0
movq %r13, %rdi
leaq 0x2cf4c(%rip), %rsi     # 0x55ddc
callq 0x124a0
testl %eax, %eax
jne 0x28ea0
movl $0x1, 0x20(%rbx)
movq 0x18(%rbx), %rdi
movslq 0x10(%rbx), %rax
leaq 0x8(,%rax,8), %rsi
callq 0x1ff61
movq %rax, 0x18(%rbx)
movslq 0x10(%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x10(%rbx)
movq %r13, (%rax,%rcx,8)
jmp 0x28f86
movq %r15, %r14
movq %r12, %r15
movq %r13, %rdi
leaq 0x4(%rsp), %rsi
callq 0x1f99c
testq %rax, %rax
je 0x28f32
movq %rax, %r12
movq (%rax), %rdi
callq 0x1f453
movq 0x18(%rbx), %rdi
movslq 0x10(%rbx), %rax
leaq 0x8(,%rax,8), %rsi
callq 0x1ff61
movq %rax, 0x18(%rbx)
movslq 0x10(%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x10(%rbx)
movq %r13, (%rax,%rcx,8)
movq (%r12), %rsi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x28d1e
movl 0x4(%rsp), %esi
movq %r12, %rdi
callq 0x1f796
jmp 0x28f7b
leaq 0x2cec1(%rip), %rdi     # 0x55dfa
callq 0x1de62
movq %rax, %rdi
movq %r13, %rsi
callq 0x1e764
movq %rax, %r12
movq %r13, %rdi
callq 0x1ded3
movq 0x18(%rbx), %rdi
movslq 0x10(%rbx), %rax
leaq 0x8(,%rax,8), %rsi
callq 0x1ff61
movq %rax, 0x18(%rbx)
movslq 0x10(%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x10(%rbx)
movq %r12, (%rax,%rcx,8)
movq %r15, %r12
movq %r14, %r15
movq 0x8(%rsp), %r14
movq %r15, %rdi
movl $0x401, %esi            # imm = 0x401
movq %r14, %rdx
callq 0x12470
incl %ebp
testq %rax, %rax
jne 0x28e5e
movq %r14, %rdi
callq 0x12220
jmp 0x28fad
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq