// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/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,REDIS_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 0x643c2(%rip), %rsi     # 0xbfa5d
callq 0x26ae0
movq %rax, %r14
movl $0x28, %edi
callq 0x382d1
movq %rax, %rbx
testq %r14, %r14
jne 0x5b6c3
callq 0x26880
cmpl $0x2, (%rax)
jne 0x5b87d
leaq 0xa5b6e(%rip), %rdi     # 0x101238
xorl %r15d, %r15d
xorl %esi, %esi
callq 0x2e68c
movq %rax, (%rbx)
leaq 0xa5b8a(%rip), %rdi     # 0x101268
xorl %esi, %esi
callq 0x2e68c
movq %rax, 0x8(%rbx)
movl %r15d, 0x10(%rbx)
movq $0x0, 0x18(%rbx)
movl %r15d, 0x20(%rbx)
testq %r14, %r14
je 0x5b87f
leaq 0x10(%rsp), %rdi
movl $0x401, %esi            # imm = 0x401
movq %r14, %rdx
callq 0x26440
testq %rax, %rax
je 0x5b873
xorl %ebp, %ebp
leaq 0x10(%rsp), %r15
leaq 0x6956f(%rip), %r12     # 0xc4c9a
movq %r14, 0x8(%rsp)
movq %r15, %rdi
callq 0x362b0
movq %rax, %rdi
movq %r12, %rsi
callq 0x376a4
movq %rax, %r13
movzbl (%rax), %eax
cmpl $0x23, %eax
je 0x5b752
testl %eax, %eax
jne 0x5b79e
cmpl $0x0, 0x20(%rbx)
jne 0x5b772
movq %r13, %rdi
leaq 0x6953d(%rip), %rsi     # 0xc4c9f
callq 0x268f0
testl %eax, %eax
jne 0x5b772
movl $0x1, 0x20(%rbx)
movq 0x18(%rbx), %rdi
movslq 0x10(%rbx), %rax
leaq 0x8(,%rax,8), %rsi
callq 0x3837d
movq %rax, 0x18(%rbx)
movslq 0x10(%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x10(%rbx)
movq %r13, (%rax,%rcx,8)
jmp 0x5b858
movq %r15, %r14
movq %r12, %r15
movq %r13, %rdi
leaq 0x4(%rsp), %rsi
callq 0x37e0a
testq %rax, %rax
je 0x5b804
movq %rax, %r12
movq (%rax), %rdi
callq 0x378aa
movq 0x18(%rbx), %rdi
movslq 0x10(%rbx), %rax
leaq 0x8(,%rax,8), %rsi
callq 0x3837d
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 0x5b5f0
movl 0x4(%rsp), %esi
movq %r12, %rdi
callq 0x37c04
jmp 0x5b84d
leaq 0x694b2(%rip), %rdi     # 0xc4cbd
callq 0x362b0
movq %rax, %rdi
movq %r13, %rsi
callq 0x36bc3
movq %rax, %r12
movq %r13, %rdi
callq 0x36330
movq 0x18(%rbx), %rdi
movslq 0x10(%rbx), %rax
leaq 0x8(,%rax,8), %rsi
callq 0x3837d
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 0x26440
incl %ebp
testq %rax, %rax
jne 0x5b730
movq %r14, %rdi
callq 0x26a10
jmp 0x5b87f
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq