// File: /workspace/github_c_makefile_star2_O1/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 0x28db1
testq %rax, %rax
je 0x29d40
movq %rax, %rbx
leaq 0x4565b(%rip), %r15     # 0x6f088
movl 0x5b8(%r15), %edx
leaq 0x2be2d(%rip), %rsi     # 0x55868
movq %rax, %rdi
xorl %ecx, %ecx
callq 0x291b0
movq 0x50(%r15), %rdx
leaq 0x2be61(%rip), %rsi     # 0x558b1
leaq 0x290e5(%rip), %rcx     # 0x52b3c
movq %rbx, %rdi
callq 0x2920e
movslq 0xb4(%r15), %rdx
leaq 0x2bbb1(%rip), %rsi     # 0x5561e
movl $0x148e, %ecx           # imm = 0x148E
movq %rbx, %rdi
callq 0x292a3
movslq 0xb8(%r15), %rdx
leaq 0x2bb9b(%rip), %rsi     # 0x55623
movl $0x1ff, %ecx            # imm = 0x1FF
movq %rbx, %rdi
callq 0x292a3
movq %rbx, %rdi
callq 0x296a5
movq 0x148(%r15), %rdx
leaq 0x28644(%rip), %rsi     # 0x520ef
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x2920e
movl 0x150(%r15), %edx
leaq 0x2bba9(%rip), %rsi     # 0x5566c
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x2934e
movslq 0x59c(%r15), %rdx
leaq 0x2be96(%rip), %rsi     # 0x55971
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x292a3
movslq 0x5a0(%r15), %rdx
leaq 0x2baf9(%rip), %rsi     # 0x555ec
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x292a3
movl 0x598(%r15), %edx
leaq 0x2bbc4(%rip), %rsi     # 0x556cf
leaq 0x4539e(%rip), %rcx     # 0x6eeb0
movq %rbx, %rdi
movl $0x2, %r8d
callq 0x2939a
movq 0x5f0(%r15), %rdx
leaq 0x2bbec(%rip), %rsi     # 0x5571a
leaq 0x2b6d0(%rip), %rcx     # 0x55205
movq %rbx, %rdi
callq 0x2920e
movl 0x5f8(%r15), %edx
leaq 0x2bbf3(%rip), %rsi     # 0x5573e
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x291b0
movq 0x600(%r15), %rdx
leaq 0x2bc09(%rip), %rsi     # 0x5576c
leaq 0x28fcb(%rip), %rcx     # 0x52b35
movq %rbx, %rdi
callq 0x2920e
movq %rbx, %rdi
callq 0x2941d
movq %rbx, %rdi
callq 0x294bd
movl 0x700(%r15), %edx
leaq 0x2bec4(%rip), %rsi     # 0x55a54
movq %rbx, %rdi
movl $0x1, %ecx
callq 0x291b0
movl 0x6d4(%r15), %edx
leaq 0x2bca1(%rip), %rsi     # 0x5584c
movq %rbx, %rdi
movl $0x1, %ecx
callq 0x291b0
movq 0x6c8(%r15), %rdx
leaq 0x2bcf3(%rip), %rsi     # 0x558b9
leaq 0x28f83(%rip), %rcx     # 0x52b50
movq %rbx, %rdi
callq 0x2920e
movq %rbx, %rdi
callq 0x2955a
movq 0x48(%r15), %rdx
leaq 0x2bc8d(%rip), %rsi     # 0x55875
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x2920e
movl 0x60c(%r15), %edx
leaq 0x2bbd4(%rip), %rsi     # 0x557d4
movl $0x2710, %ecx           # imm = 0x2710
movq %rbx, %rdi
callq 0x292a3
movq 0x610(%r15), %rdx
leaq 0x2bbde(%rip), %rsi     # 0x557f9
movl $0x40000000, %ecx       # imm = 0x40000000
movq %rbx, %rdi
callq 0x29150
movsd 0x620(%r15), %xmm0
leaq 0x2bbcb(%rip), %rsi     # 0x55803
movsd 0x2b530(%rip), %xmm1    # 0x55170
movq %rbx, %rdi
callq 0x292f2
movl 0x628(%r15), %edx
leaq 0x2bbd9(%rip), %rsi     # 0x5582f
movl $0xa, %ecx
movq %rbx, %rdi
callq 0x292a3
movq 0x660(%r15), %rdx
leaq 0x2bcdf(%rip), %rsi     # 0x55950
leaq 0x28ee1(%rip), %rcx     # 0x52b59
movq %rbx, %rdi
callq 0x2920e
movq 0x658(%r15), %rdx
leaq 0x2bcd6(%rip), %rsi     # 0x55964
movl $0x3a98, %ecx           # imm = 0x3A98
movq %rbx, %rdi
callq 0x292a3
movq 0x670(%r15), %rdx
leaq 0x2bcfa(%rip), %rsi     # 0x559a3
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x292a3
movl 0x44(%r15), %edx
leaq 0x2bb9a(%rip), %rsi     # 0x55858
movq %rbx, %rdi
movl $0x1, %ecx
callq 0x291b0
movq %rbx, %rdi
callq 0x2959e
movslq 0x20(%r15), %rdx
leaq 0x2bb94(%rip), %rsi     # 0x55872
movl $0xa, %ecx
movq %rbx, %rdi
callq 0x292a3
movl 0x5b4(%r15), %edx
leaq 0x2bd77(%rip), %rsi     # 0x55a70
leaq 0x45200(%rip), %rcx     # 0x6ef00
movq %rbx, %rdi
xorl %r8d, %r8d
callq 0x2939a
movq %rbx, %rdi
callq 0x29821
movq %rbx, %rdi
callq 0x2974c
movq %rax, %r14
movq 0x8(%r15), %rdi
movq %rax, %rsi
callq 0x298cf
movl %eax, %ebp
movq %r14, %rdi
callq 0x1ded3
movq %rbx, %rdi
callq 0x297f7
movl %ebp, %eax
jmp 0x29d45
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq