// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
callq 0x2880e
testq %rax, %rax
je 0x297aa
movq %rax, %rbx
leaq 0x45bf1(%rip), %r15     # 0x6f088
movl 0x5b8(%r15), %edx
leaq 0x2c3bf(%rip), %rsi     # 0x55864
movq %rax, %rdi
xorl %ecx, %ecx
callq 0x28c12
movq 0x50(%r15), %rdx
leaq 0x2c3f3(%rip), %rsi     # 0x558ad
leaq 0x296cb(%rip), %rcx     # 0x52b8c
movq %rbx, %rdi
callq 0x28c70
movslq 0xb4(%r15), %rdx
leaq 0x2c143(%rip), %rsi     # 0x5561a
movl $0x148e, %ecx           # imm = 0x148E
movq %rbx, %rdi
callq 0x28d05
movslq 0xb8(%r15), %rdx
leaq 0x2c12d(%rip), %rsi     # 0x5561f
movl $0x1ff, %ecx            # imm = 0x1FF
movq %rbx, %rdi
callq 0x28d05
movq %rbx, %rdi
callq 0x2910e
movq 0x148(%r15), %rdx
leaq 0x28c26(%rip), %rsi     # 0x5213b
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x28c70
movl 0x150(%r15), %edx
leaq 0x2c13b(%rip), %rsi     # 0x55668
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x28db0
movslq 0x59c(%r15), %rdx
leaq 0x2c428(%rip), %rsi     # 0x5596d
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x28d05
movslq 0x5a0(%r15), %rdx
leaq 0x2c08b(%rip), %rsi     # 0x555e8
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x28d05
movl 0x598(%r15), %edx
leaq 0x2c156(%rip), %rsi     # 0x556cb
leaq 0x45934(%rip), %rcx     # 0x6eeb0
movq %rbx, %rdi
movl $0x2, %r8d
callq 0x28dfc
movq 0x5f0(%r15), %rdx
leaq 0x2c17e(%rip), %rsi     # 0x55716
leaq 0x2bc7e(%rip), %rcx     # 0x5521d
movq %rbx, %rdi
callq 0x28c70
movl 0x5f8(%r15), %edx
leaq 0x2c185(%rip), %rsi     # 0x5573a
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x28c12
movq 0x600(%r15), %rdx
leaq 0x2c19b(%rip), %rsi     # 0x55768
leaq 0x295b1(%rip), %rcx     # 0x52b85
movq %rbx, %rdi
callq 0x28c70
movq %rbx, %rdi
callq 0x28e7f
movq %rbx, %rdi
callq 0x28f1f
movl 0x700(%r15), %edx
leaq 0x2c456(%rip), %rsi     # 0x55a50
movq %rbx, %rdi
movl $0x1, %ecx
callq 0x28c12
movl 0x6d4(%r15), %edx
leaq 0x2c233(%rip), %rsi     # 0x55848
movq %rbx, %rdi
movl $0x1, %ecx
callq 0x28c12
movq 0x6c8(%r15), %rdx
leaq 0x2c285(%rip), %rsi     # 0x558b5
leaq 0x29569(%rip), %rcx     # 0x52ba0
movq %rbx, %rdi
callq 0x28c70
movq %rbx, %rdi
callq 0x28fbc
movq 0x48(%r15), %rdx
leaq 0x2c21f(%rip), %rsi     # 0x55871
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x28c70
movl 0x60c(%r15), %edx
leaq 0x2c166(%rip), %rsi     # 0x557d0
movl $0x2710, %ecx           # imm = 0x2710
movq %rbx, %rdi
callq 0x28d05
movq 0x610(%r15), %rdx
leaq 0x2c170(%rip), %rsi     # 0x557f5
movl $0x40000000, %ecx       # imm = 0x40000000
movq %rbx, %rdi
callq 0x28bb2
movsd 0x620(%r15), %xmm0
leaq 0x2c15d(%rip), %rsi     # 0x557ff
movsd 0x2bade(%rip), %xmm1    # 0x55188
movq %rbx, %rdi
callq 0x28d54
movl 0x628(%r15), %edx
leaq 0x2c16b(%rip), %rsi     # 0x5582b
movl $0xa, %ecx
movq %rbx, %rdi
callq 0x28d05
movq 0x660(%r15), %rdx
leaq 0x2c271(%rip), %rsi     # 0x5594c
leaq 0x294c7(%rip), %rcx     # 0x52ba9
movq %rbx, %rdi
callq 0x28c70
movq 0x658(%r15), %rdx
leaq 0x2c268(%rip), %rsi     # 0x55960
movl $0x3a98, %ecx           # imm = 0x3A98
movq %rbx, %rdi
callq 0x28d05
movq 0x670(%r15), %rdx
leaq 0x2c28c(%rip), %rsi     # 0x5599f
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x28d05
movl 0x44(%r15), %edx
leaq 0x2c12c(%rip), %rsi     # 0x55854
movq %rbx, %rdi
movl $0x1, %ecx
callq 0x28c12
movq %rbx, %rdi
callq 0x29000
movslq 0x20(%r15), %rdx
leaq 0x2c126(%rip), %rsi     # 0x5586e
movl $0xa, %ecx
movq %rbx, %rdi
callq 0x28d05
movl 0x5b4(%r15), %edx
leaq 0x2c309(%rip), %rsi     # 0x55a6c
leaq 0x45796(%rip), %rcx     # 0x6ef00
movq %rbx, %rdi
xorl %r8d, %r8d
callq 0x28dfc
movq %rbx, %rdi
callq 0x2928b
movq %rbx, %rdi
callq 0x291b5
movq %rax, %r14
movq 0x8(%r15), %rdi
movq %rax, %rsi
callq 0x29339
movl %eax, %ebp
movq %r14, %rdi
callq 0x1dc25
movq %rbx, %rdi
callq 0x29261
movl %ebp, %eax
jmp 0x297af
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq