// File: /workspace/github_c_makefile_star2_O0/erikdubbelboer[P]discnt/src/config.c
// Function: rewriteConfig
int rewriteConfig(char *path) {
    struct rewriteConfigState *state;
    sds newcontent;
    int retval;

    /* Step 1: read the old config into our rewrite state. */
    if ((state = rewriteConfigReadOldFile(path)) == NULL) return -1;

    /* Step 2: rewrite every single option, replacing or appending it inside
     * the rewrite state. */

    rewriteConfigYesNoOption(state,"daemonize",server.daemonize,0);
    rewriteConfigStringOption(state,"pidfile",server.pidfile,CONFIG_DEFAULT_PID_FILE);
    rewriteConfigNumericalOption(state,"port",server.port,CONFIG_DEFAULT_SERVER_PORT);
    rewriteConfigNumericalOption(state,"tcp-backlog",server.tcp_backlog,CONFIG_DEFAULT_TCP_BACKLOG);
    rewriteConfigBindOption(state);
    rewriteConfigStringOption(state,"unixsocket",server.unixsocket,NULL);
    rewriteConfigOctalOption(state,"unixsocketperm",server.unixsocketperm,CONFIG_DEFAULT_UNIX_SOCKET_PERM);
    rewriteConfigNumericalOption(state,"timeout",server.maxidletime,CONFIG_DEFAULT_CLIENT_TIMEOUT);
    rewriteConfigNumericalOption(state,"tcp-keepalive",server.tcpkeepalive,CONFIG_DEFAULT_TCP_KEEPALIVE);
    rewriteConfigEnumOption(state,"loglevel",server.verbosity,loglevel_enum,CONFIG_DEFAULT_VERBOSITY);
    rewriteConfigStringOption(state,"logfile",server.logfile,CONFIG_DEFAULT_LOGFILE);
    rewriteConfigYesNoOption(state,"syslog-enabled",server.syslog_enabled,CONFIG_DEFAULT_SYSLOG_ENABLED);
    rewriteConfigStringOption(state,"syslog-ident",server.syslog_ident,CONFIG_DEFAULT_SYSLOG_IDENT);
    rewriteConfigSyslogfacilityOption(state);
    rewriteConfigSaveOption(state);
    rewriteConfigYesNoOption(state,"stop-writes-on-bgsave-error",server.stop_writes_on_bgsave_err,CONFIG_DEFAULT_STOP_WRITES_ON_BGSAVE_ERROR);
    rewriteConfigYesNoOption(state,"ddbchecksum",server.ddb_checksum,CONFIG_DEFAULT_DDB_CHECKSUM);
    rewriteConfigStringOption(state,"dbfilename",server.ddb_filename,CONFIG_DEFAULT_DDB_FILENAME);
    rewriteConfigDirOption(state);
    rewriteConfigStringOption(state,"requirepass",server.requirepass,NULL);
    rewriteConfigNumericalOption(state,"maxclients",server.maxclients,CONFIG_DEFAULT_MAX_CLIENTS);
    rewriteConfigBytesOption(state,"maxmemory",server.maxmemory,CONFIG_DEFAULT_MAXMEMORY);
    rewriteConfigDoubleOption(state,"default-precision",server.default_precision,CONFIG_DEFAULT_PRECISION);
    rewriteConfigNumericalOption(state,"history-size",server.history_size,CONFIG_HISTORY);
    rewriteConfigStringOption(state,"cluster-config-file",server.cluster_configfile,CONFIG_DEFAULT_CLUSTER_CONFIG_FILE);
    rewriteConfigNumericalOption(state,"cluster-node-timeout",server.cluster_node_timeout,CLUSTER_DEFAULT_NODE_TIMEOUT);
    rewriteConfigNumericalOption(state,"latency-monitor-threshold",server.latency_monitor_threshold,CONFIG_DEFAULT_LATENCY_MONITOR_THRESHOLD);
    rewriteConfigYesNoOption(state,"activerehashing",server.activerehashing,CONFIG_DEFAULT_ACTIVE_REHASHING);
    rewriteConfigClientoutputbufferlimitOption(state);
    rewriteConfigNumericalOption(state,"hz",server.hz,CONFIG_DEFAULT_HZ);
    rewriteConfigEnumOption(state,"supervised",server.supervised_mode,supervised_mode_enum,SUPERVISED_NONE);

    /* Step 3: remove all the orphaned lines in the old file, that is, lines
     * that were used by a config option and are no longer used, like in case
     * of multiple "save" options or duplicated options. */
    rewriteConfigRemoveOrphaned(state);

    /* Step 4: generate a new configuration file from the modified state
     * and write it into the original file. */
    newcontent = rewriteConfigGetContentFromState(state);
    retval = rewriteConfigOverwriteFile(server.configfile,newcontent);

    sdsfree(newcontent);
    rewriteConfigReleaseState(state);
    return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2d9c0
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x2ea3b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2ee36
movq -0x18(%rbp), %rdi
leaq 0x906a2(%rip), %rax     # 0xbf0e8
movl 0x5b8(%rax), %edx
leaq 0x777c9(%rip), %rsi     # 0xa621c
xorl %ecx, %ecx
callq 0x2df00
movq -0x18(%rbp), %rdi
leaq 0x90683(%rip), %rax     # 0xbf0e8
movq 0x50(%rax), %rdx
leaq 0x777f5(%rip), %rsi     # 0xa6265
leaq 0x750e5(%rip), %rcx     # 0xa3b5c
callq 0x2df80
movq -0x18(%rbp), %rdi
leaq 0x90661(%rip), %rax     # 0xbf0e8
movslq 0xb4(%rax), %rdx
leaq 0x7753d(%rip), %rsi     # 0xa5fd2
movl $0x148e, %ecx           # imm = 0x148E
callq 0x2e050
movq -0x18(%rbp), %rdi
leaq 0x9063e(%rip), %rax     # 0xbf0e8
movslq 0xb8(%rax), %rdx
leaq 0x7751f(%rip), %rsi     # 0xa5fd7
movl $0x1ff, %ecx            # imm = 0x1FF
callq 0x2e050
movq -0x18(%rbp), %rdi
callq 0x2e5c0
movq -0x18(%rbp), %rdi
leaq 0x90612(%rip), %rax     # 0xbf0e8
movq 0x148(%rax), %rdx
leaq 0x7460b(%rip), %rsi     # 0xa30ef
xorl %eax, %eax
movl %eax, %ecx
callq 0x2df80
movq -0x18(%rbp), %rdi
leaq 0x905f0(%rip), %rax     # 0xbf0e8
movl 0x150(%rax), %edx
leaq 0x7751b(%rip), %rsi     # 0xa6020
xorl %ecx, %ecx
callq 0x2e140
movq -0x18(%rbp), %rdi
leaq 0x905d1(%rip), %rax     # 0xbf0e8
movslq 0x59c(%rax), %rdx
leaq 0x77800(%rip), %rsi     # 0xa6325
xorl %eax, %eax
movl %eax, %ecx
callq 0x2e050
movq -0x18(%rbp), %rdi
leaq 0x905af(%rip), %rax     # 0xbf0e8
movslq 0x5a0(%rax), %rdx
leaq 0x77459(%rip), %rsi     # 0xa5fa0
xorl %eax, %eax
movl %eax, %ecx
callq 0x2e050
movq -0x18(%rbp), %rdi
leaq 0x9058d(%rip), %rax     # 0xbf0e8
movl 0x598(%rax), %edx
leaq 0x7751b(%rip), %rsi     # 0xa6083
leaq 0x90341(%rip), %rcx     # 0xbeeb0
movl $0x2, %r8d
callq 0x2e1b0
movq -0x18(%rbp), %rdi
leaq 0x90563(%rip), %rax     # 0xbf0e8
movq 0x5f0(%rax), %rdx
leaq 0x7753b(%rip), %rsi     # 0xa60ce
leaq 0x771d8(%rip), %rcx     # 0xa5d72
callq 0x2df80
movq -0x18(%rbp), %rdi
leaq 0x9053e(%rip), %rax     # 0xbf0e8
movl 0x5f8(%rax), %edx
leaq 0x7753b(%rip), %rsi     # 0xa60f2
xorl %ecx, %ecx
callq 0x2df00
movq -0x18(%rbp), %rdi
leaq 0x9051f(%rip), %rax     # 0xbf0e8
movq 0x600(%rax), %rdx
leaq 0x77549(%rip), %rsi     # 0xa6120
leaq 0x74f77(%rip), %rcx     # 0xa3b55
callq 0x2df80
movq -0x18(%rbp), %rdi
callq 0x2e230
movq -0x18(%rbp), %rdi
callq 0x2e2c0
movq -0x18(%rbp), %rdi
leaq 0x904e8(%rip), %rax     # 0xbf0e8
movl 0x700(%rax), %edx
leaq 0x777fb(%rip), %rsi     # 0xa6408
movl $0x1, %ecx
callq 0x2df00
movq -0x18(%rbp), %rdi
leaq 0x904c6(%rip), %rax     # 0xbf0e8
movl 0x6d4(%rax), %edx
leaq 0x775d1(%rip), %rsi     # 0xa6200
movl $0x1, %ecx
callq 0x2df00
movq -0x18(%rbp), %rdi
leaq 0x904a4(%rip), %rax     # 0xbf0e8
movq 0x6c8(%rax), %rdx
leaq 0x7761b(%rip), %rsi     # 0xa626d
leaq 0x74f17(%rip), %rcx     # 0xa3b70
callq 0x2df80
movq -0x18(%rbp), %rdi
callq 0x2e380
movq -0x18(%rbp), %rdi
leaq 0x90476(%rip), %rax     # 0xbf0e8
movq 0x48(%rax), %rdx
leaq 0x775ac(%rip), %rsi     # 0xa6229
xorl %eax, %eax
movl %eax, %ecx
callq 0x2df80
movq -0x18(%rbp), %rdi
leaq 0x90457(%rip), %rax     # 0xbf0e8
movl 0x60c(%rax), %eax
movl %eax, %edx
leaq 0x774e8(%rip), %rsi     # 0xa6188
movl $0x2710, %ecx           # imm = 0x2710
callq 0x2e050
movq -0x18(%rbp), %rdi
leaq 0x90433(%rip), %rax     # 0xbf0e8
movq 0x610(%rax), %rdx
leaq 0x774ea(%rip), %rsi     # 0xa61ad
movl $0x40000000, %ecx       # imm = 0x40000000
callq 0x2de80
movq -0x18(%rbp), %rdi
leaq 0x90410(%rip), %rax     # 0xbf0e8
movsd 0x620(%rax), %xmm0
leaq 0x774d0(%rip), %rsi     # 0xa61b7
movsd 0x74739(%rip), %xmm1    # 0xa3428
callq 0x2e0c0
movq -0x18(%rbp), %rdi
leaq 0x903e9(%rip), %rax     # 0xbf0e8
movl 0x628(%rax), %eax
movl %eax, %edx
leaq 0x774d5(%rip), %rsi     # 0xa61e3
movl $0xa, %ecx
callq 0x2e050
movq -0x18(%rbp), %rdi
leaq 0x903c5(%rip), %rax     # 0xbf0e8
movq 0x660(%rax), %rdx
leaq 0x775d3(%rip), %rsi     # 0xa6304
leaq 0x74e41(%rip), %rcx     # 0xa3b79
callq 0x2df80
movq -0x18(%rbp), %rdi
leaq 0x903a0(%rip), %rax     # 0xbf0e8
movq 0x658(%rax), %rdx
leaq 0x775c2(%rip), %rsi     # 0xa6318
movl $0x3a98, %ecx           # imm = 0x3A98
callq 0x2e050
movq -0x18(%rbp), %rdi
leaq 0x9037d(%rip), %rax     # 0xbf0e8
movq 0x670(%rax), %rdx
leaq 0x775de(%rip), %rsi     # 0xa6357
xorl %eax, %eax
movl %eax, %ecx
callq 0x2e050
movq -0x18(%rbp), %rdi
leaq 0x9035b(%rip), %rax     # 0xbf0e8
movl 0x44(%rax), %edx
leaq 0x77475(%rip), %rsi     # 0xa620c
movl $0x1, %ecx
callq 0x2df00
movq -0x18(%rbp), %rdi
callq 0x2e3e0
movq -0x18(%rbp), %rdi
leaq 0x90333(%rip), %rax     # 0xbf0e8
movslq 0x20(%rax), %rdx
leaq 0x77466(%rip), %rsi     # 0xa6226
movl $0xa, %ecx
callq 0x2e050
movq -0x18(%rbp), %rdi
leaq 0x90313(%rip), %rax     # 0xbf0e8
movl 0x5b4(%rax), %edx
leaq 0x77642(%rip), %rsi     # 0xa6424
leaq 0x90117(%rip), %rcx     # 0xbef00
xorl %r8d, %r8d
callq 0x2e1b0
movq -0x18(%rbp), %rdi
callq 0x2e790
movq -0x18(%rbp), %rdi
callq 0x2e690
movq %rax, -0x20(%rbp)
leaq 0x902da(%rip), %rax     # 0xbf0e8
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x2e880
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
callq 0x1e3c0
movq -0x18(%rbp), %rdi
callq 0x2e740
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nop