// File: /workspace/github_c_makefile_star2_O2/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 0x226ac
testq %rax, %rax
je 0x234a6
movq %rax, %rbx
leaq 0x46eed(%rip), %r15     # 0x6a088
movl 0x5b8(%r15), %edx
leaq 0x2bf0b(%rip), %rsi     # 0x4f0b4
movq %rax, %rdi
xorl %ecx, %ecx
callq 0x229f3
movq 0x50(%r15), %rdx
leaq 0x2bf3f(%rip), %rsi     # 0x4f0fd
leaq 0x298e7(%rip), %rcx     # 0x4caac
movq %rbx, %rdi
callq 0x22a51
movslq 0xb4(%r15), %rdx
leaq 0x2bc8f(%rip), %rsi     # 0x4ee6a
movl $0x148e, %ecx           # imm = 0x148E
movq %rbx, %rdi
callq 0x22ae2
movslq 0xb8(%r15), %rdx
leaq 0x2bc79(%rip), %rsi     # 0x4ee6f
movl $0x1ff, %ecx            # imm = 0x1FF
movq %rbx, %rdi
callq 0x22ae2
movq %rbx, %rdi
callq 0x22e89
movq 0x148(%r15), %rdx
leaq 0x28ed6(%rip), %rsi     # 0x4c0ef
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x22a51
movl 0x150(%r15), %edx
leaq 0x2bc87(%rip), %rsi     # 0x4eeb8
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x22b8d
movslq 0x59c(%r15), %rdx
leaq 0x2bf74(%rip), %rsi     # 0x4f1bd
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x22ae2
movslq 0x5a0(%r15), %rdx
leaq 0x2bbd7(%rip), %rsi     # 0x4ee38
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x22ae2
movl 0x598(%r15), %edx
leaq 0x2bca2(%rip), %rsi     # 0x4ef1b
leaq 0x46c30(%rip), %rcx     # 0x69eb0
pushq $0x2
popq %r8
movq %rbx, %rdi
callq 0x22bd9
movq 0x5f0(%r15), %rdx
leaq 0x2bccc(%rip), %rsi     # 0x4ef66
leaq 0x2b8ac(%rip), %rcx     # 0x4eb4d
movq %rbx, %rdi
callq 0x22a51
movl 0x5f8(%r15), %edx
leaq 0x2bcd3(%rip), %rsi     # 0x4ef8a
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x229f3
movq 0x600(%r15), %rdx
leaq 0x2bce9(%rip), %rsi     # 0x4efb8
leaq 0x297cf(%rip), %rcx     # 0x4caa5
movq %rbx, %rdi
callq 0x22a51
movq %rbx, %rdi
callq 0x22c40
movq %rbx, %rdi
callq 0x22caf
movl 0x700(%r15), %edx
leaq 0x2bfa4(%rip), %rsi     # 0x4f2a0
pushq $0x1
popq %rbp
movq %rbx, %rdi
movl %ebp, %ecx
callq 0x229f3
movl 0x6d4(%r15), %edx
leaq 0x2bd81(%rip), %rsi     # 0x4f098
movq %rbx, %rdi
movl %ebp, %ecx
callq 0x229f3
movq 0x6c8(%r15), %rdx
leaq 0x2bdd6(%rip), %rsi     # 0x4f105
leaq 0x2978a(%rip), %rcx     # 0x4cac0
movq %rbx, %rdi
callq 0x22a51
movq %rbx, %rdi
callq 0x22d3d
movq 0x48(%r15), %rdx
leaq 0x2bd70(%rip), %rsi     # 0x4f0c1
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x22a51
movl 0x60c(%r15), %edx
leaq 0x2bcb7(%rip), %rsi     # 0x4f020
movl $0x2710, %ecx           # imm = 0x2710
movq %rbx, %rdi
callq 0x22ae2
movq 0x610(%r15), %rdx
leaq 0x2bcc1(%rip), %rsi     # 0x4f045
movl $0x40000000, %ecx       # imm = 0x40000000
movq %rbx, %rdi
callq 0x22995
movsd 0x620(%r15), %xmm0
leaq 0x2bcae(%rip), %rsi     # 0x4f04f
movsd 0x2b75f(%rip), %xmm1    # 0x4eb08
movq %rbx, %rdi
callq 0x22b31
movl 0x628(%r15), %edx
leaq 0x2bcbc(%rip), %rsi     # 0x4f07b
pushq $0xa
popq %r14
movq %rbx, %rdi
movq %r14, %rcx
callq 0x22ae2
movq 0x660(%r15), %rdx
leaq 0x2bdc0(%rip), %rsi     # 0x4f19c
leaq 0x296e6(%rip), %rcx     # 0x4cac9
movq %rbx, %rdi
callq 0x22a51
movq 0x658(%r15), %rdx
leaq 0x2bdb7(%rip), %rsi     # 0x4f1b0
movl $0x3a98, %ecx           # imm = 0x3A98
movq %rbx, %rdi
callq 0x22ae2
movq 0x670(%r15), %rdx
leaq 0x2bddb(%rip), %rsi     # 0x4f1ef
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x22ae2
movl 0x44(%r15), %edx
leaq 0x2bc7b(%rip), %rsi     # 0x4f0a4
movq %rbx, %rdi
movl %ebp, %ecx
callq 0x229f3
movq %rbx, %rdi
callq 0x22d81
movslq 0x20(%r15), %rdx
leaq 0x2bc78(%rip), %rsi     # 0x4f0be
movq %rbx, %rdi
movq %r14, %rcx
callq 0x22ae2
movl 0x5b4(%r15), %edx
leaq 0x2be5d(%rip), %rsi     # 0x4f2bc
leaq 0x46a9a(%rip), %rcx     # 0x69f00
movq %rbx, %rdi
xorl %r8d, %r8d
callq 0x22bd9
movq %rbx, %rdi
callq 0x22fd7
movq %rbx, %rdi
callq 0x22f2c
movq %rax, %r14
movq 0x8(%r15), %rdi
movq %rax, %rsi
callq 0x2307a
movl %eax, %ebp
movq %r14, %rdi
callq 0x19548
movq %rbx, %rdi
callq 0x22fad
movl %ebp, %eax
jmp 0x234a9
pushq $-0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq