// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: initServerConfig
void initServerConfig() {
    int j;

    // 服务器状态

    // 设置服务器的运行 ID
    getRandomHexChars(server.runid,REDIS_RUN_ID_SIZE);
    // 设置默认配置文件路径
    server.configfile = NULL;
    // 设置默认服务器频率
    server.hz = REDIS_DEFAULT_HZ;
    // 为运行 ID 加上结尾字符
    server.runid[REDIS_RUN_ID_SIZE] = '\0';
    // 设置服务器的运行架构
    server.arch_bits = (sizeof(long) == 8) ? 64 : 32;
    // 设置默认服务器端口号
    server.port = REDIS_SERVERPORT;
    server.tcp_backlog = REDIS_TCP_BACKLOG;
    server.bindaddr_count = 0;
    server.unixsocket = NULL;
    server.unixsocketperm = REDIS_DEFAULT_UNIX_SOCKET_PERM;
    server.ipfd_count = 0;
    server.sofd = -1;
    server.dbnum = REDIS_DEFAULT_DBNUM;
    server.verbosity = REDIS_DEFAULT_VERBOSITY;
    server.maxidletime = REDIS_MAXIDLETIME;
    server.tcpkeepalive = REDIS_DEFAULT_TCP_KEEPALIVE;
    server.active_expire_enabled = 1;
    server.client_max_querybuf_len = REDIS_MAX_QUERYBUF_LEN;
    server.saveparams = NULL;
    server.loading = 0;
    server.logfile = zstrdup(REDIS_DEFAULT_LOGFILE);
    server.syslog_enabled = REDIS_DEFAULT_SYSLOG_ENABLED;
    server.syslog_ident = zstrdup(REDIS_DEFAULT_SYSLOG_IDENT);
    server.syslog_facility = LOG_LOCAL0;
    server.daemonize = REDIS_DEFAULT_DAEMONIZE;
    server.aof_state = REDIS_AOF_OFF;
    server.aof_fsync = REDIS_DEFAULT_AOF_FSYNC;
    server.aof_no_fsync_on_rewrite = REDIS_DEFAULT_AOF_NO_FSYNC_ON_REWRITE;
    server.aof_rewrite_perc = REDIS_AOF_REWRITE_PERC;
    server.aof_rewrite_min_size = REDIS_AOF_REWRITE_MIN_SIZE;
    server.aof_rewrite_base_size = 0;
    server.aof_rewrite_scheduled = 0;
    server.aof_last_fsync = time(NULL);
    server.aof_rewrite_time_last = -1;
    server.aof_rewrite_time_start = -1;
    server.aof_lastbgrewrite_status = REDIS_OK;
    server.aof_delayed_fsync = 0;
    server.aof_fd = -1;
    server.aof_selected_db = -1; /* Make sure the first time will not match */
    server.aof_flush_postponed_start = 0;
    server.aof_rewrite_incremental_fsync = REDIS_DEFAULT_AOF_REWRITE_INCREMENTAL_FSYNC;
    server.pidfile = zstrdup(REDIS_DEFAULT_PID_FILE);
    server.rdb_filename = zstrdup(REDIS_DEFAULT_RDB_FILENAME);
    server.aof_filename = zstrdup(REDIS_DEFAULT_AOF_FILENAME);
    server.requirepass = NULL;
    server.rdb_compression = REDIS_DEFAULT_RDB_COMPRESSION;
    server.rdb_checksum = REDIS_DEFAULT_RDB_CHECKSUM;
    server.stop_writes_on_bgsave_err = REDIS_DEFAULT_STOP_WRITES_ON_BGSAVE_ERROR;
    server.activerehashing = REDIS_DEFAULT_ACTIVE_REHASHING;
    server.notify_keyspace_events = 0;
    server.maxclients = REDIS_MAX_CLIENTS;
    server.bpop_blocked_clients = 0;
    server.maxmemory = REDIS_DEFAULT_MAXMEMORY;
    server.maxmemory_policy = REDIS_DEFAULT_MAXMEMORY_POLICY;
    server.maxmemory_samples = REDIS_DEFAULT_MAXMEMORY_SAMPLES;
    server.hash_max_ziplist_entries = REDIS_HASH_MAX_ZIPLIST_ENTRIES;
    server.hash_max_ziplist_value = REDIS_HASH_MAX_ZIPLIST_VALUE;
    server.list_max_ziplist_entries = REDIS_LIST_MAX_ZIPLIST_ENTRIES;
    server.list_max_ziplist_value = REDIS_LIST_MAX_ZIPLIST_VALUE;
    server.set_max_intset_entries = REDIS_SET_MAX_INTSET_ENTRIES;
    server.zset_max_ziplist_entries = REDIS_ZSET_MAX_ZIPLIST_ENTRIES;
    server.zset_max_ziplist_value = REDIS_ZSET_MAX_ZIPLIST_VALUE;
    server.hll_sparse_max_bytes = REDIS_DEFAULT_HLL_SPARSE_MAX_BYTES;
    server.shutdown_asap = 0;
    server.repl_ping_slave_period = REDIS_REPL_PING_SLAVE_PERIOD;
    server.repl_timeout = REDIS_REPL_TIMEOUT;
    server.repl_min_slaves_to_write = REDIS_DEFAULT_MIN_SLAVES_TO_WRITE;
    server.repl_min_slaves_max_lag = REDIS_DEFAULT_MIN_SLAVES_MAX_LAG;
    server.cluster_enabled = 0;
    server.cluster_node_timeout = REDIS_CLUSTER_DEFAULT_NODE_TIMEOUT;
    server.cluster_migration_barrier = REDIS_CLUSTER_DEFAULT_MIGRATION_BARRIER;
    server.cluster_configfile = zstrdup(REDIS_DEFAULT_CLUSTER_CONFIG_FILE);
    server.lua_caller = NULL;
    server.lua_time_limit = REDIS_LUA_TIME_LIMIT;
    server.lua_client = NULL;
    server.lua_timedout = 0;
    server.migrate_cached_sockets = dictCreate(&migrateCacheDictType,NULL);
    server.loading_process_events_interval_bytes = (1024*1024*2);

    // 初始化 LRU 时间
    server.lruclock = getLRUClock();

    // 初始化并设置保存条件
    resetServerSaveParams();

    appendServerSaveParams(60*60,1);  /* save after 1 hour and 1 change */
    appendServerSaveParams(300,100);  /* save after 5 minutes and 100 changes */
    appendServerSaveParams(60,10000); /* save after 1 minute and 10000 changes */

    /* Replication related */
    // 初始化和复制相关的状态
    server.masterauth = NULL;
    server.masterhost = NULL;
    server.masterport = 6379;
    server.master = NULL;
    server.cached_master = NULL;
    server.repl_master_initial_offset = -1;
    server.repl_state = REDIS_REPL_NONE;
    server.repl_syncio_timeout = REDIS_REPL_SYNCIO_TIMEOUT;
    server.repl_serve_stale_data = REDIS_DEFAULT_SLAVE_SERVE_STALE_DATA;
    server.repl_slave_ro = REDIS_DEFAULT_SLAVE_READ_ONLY;
    server.repl_down_since = 0; /* Never connected, repl is down since EVER. */
    server.repl_disable_tcp_nodelay = REDIS_DEFAULT_REPL_DISABLE_TCP_NODELAY;
    server.slave_priority = REDIS_DEFAULT_SLAVE_PRIORITY;
    server.master_repl_offset = 0;

    /* Replication partial resync backlog */
    // 初始化 PSYNC 命令所使用的 backlog
    server.repl_backlog = NULL;
    server.repl_backlog_size = REDIS_DEFAULT_REPL_BACKLOG_SIZE;
    server.repl_backlog_histlen = 0;
    server.repl_backlog_idx = 0;
    server.repl_backlog_off = 0;
    server.repl_backlog_time_limit = REDIS_DEFAULT_REPL_BACKLOG_TIME_LIMIT;
    server.repl_no_slaves_since = time(NULL);

    /* Client output buffer limits */
    // 设置客户端的输出缓冲区限制
    for (j = 0; j < REDIS_CLIENT_LIMIT_NUM_CLASSES; j++)
        server.client_obuf_limits[j] = clientBufferLimitsDefaults[j];

    /* Double constants initialization */
    // 初始化浮点常量
    R_Zero = 0.0;
    R_PosInf = 1.0/R_Zero;
    R_NegInf = -1.0/R_Zero;
    R_Nan = R_Zero/R_Zero;

    /* Command table -- we initiialize it here as it is part of the
     * initial configuration, since command names may be changed via
     * redis.conf using the rename-command directive. */
    // 初始化命令表
    // 在这里初始化是因为接下来读取 .conf 文件时可能会用到这些命令
    server.commands = dictCreate(&commandTableDictType,NULL);
    server.orig_commands = dictCreate(&commandTableDictType,NULL);
    populateCommandTable();
    server.delCommand = lookupCommandByCString("del");
    server.multiCommand = lookupCommandByCString("multi");
    server.lpushCommand = lookupCommandByCString("lpush");
    server.lpopCommand = lookupCommandByCString("lpop");
    server.rpopCommand = lookupCommandByCString("rpop");
    
    /* Slow log */
    // 初始化慢查询日志
    server.slowlog_log_slower_than = REDIS_SLOWLOG_LOG_SLOWER_THAN;
    server.slowlog_max_len = REDIS_SLOWLOG_MAX_LEN;

    /* Debugging */
    // 初始化调试项
    server.assert_failed = "<no assertion failed>";
    server.assert_file = "<no file>";
    server.assert_line = 0;
    server.bug_report_start = 0;
    server.watchdog_period = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
leaq 0xec8e9(%rip), %rdi     # 0x1138f8
addq $0x58, %rdi
movl $0x28, %esi
callq 0x39c50
movq $0x0, 0xec8d0(%rip) # 0x1138f8
movl $0xa, 0xec8ce(%rip)     # 0x113900
movb $0x0, 0xec93f(%rip)     # 0x113978
movl $0x40, 0xec905(%rip)    # 0x113948
movl $0x18eb, 0xec933(%rip)  # imm = 0x18EB
movl $0x1ff, 0xec92d(%rip)   # imm = 0x1FF
movl $0x0, 0xec9a7(%rip)     # 0x113a08
movq $0x0, 0xec9a4(%rip) # 0x113a10
movl $0x0, 0xec9a2(%rip)     # 0x113a18
movl $0x0, 0xec9dc(%rip)     # 0x113a5c
movl $0xffffffff, 0xec9d6(%rip) # imm = 0xFFFFFFFF
movl $0x10, 0xecce4(%rip)    # 0x113d78
movl $0x2, 0xeccbe(%rip)     # 0x113d5c
movl $0x0, 0xeccb8(%rip)     # 0x113d60
movl $0x0, 0xeccb2(%rip)     # 0x113d64
movl $0x1, 0xeccac(%rip)     # 0x113d68
movq $0x40000000, 0xecca9(%rip) # imm = 0x40000000
movq $0x0, 0xecd9e(%rip) # 0x113e70
movl $0x0, 0xecb0c(%rip)     # 0x113be8
leaq 0xba316(%rip), %rdi     # 0xe13f9
callq 0x2e430
movq %rax, 0xecdd9(%rip)     # 0x113ec8
movl $0x0, 0xecdd7(%rip)     # 0x113ed0
leaq 0xb7c79(%rip), %rdi     # 0xded79
callq 0x2e430
movq %rax, 0xecdcc(%rip)     # 0x113ed8
movl $0x80, 0xecdca(%rip)    # 0x113ee0
movl $0x0, 0xecc5c(%rip)     # 0x113d7c
movl $0x0, 0xecc9e(%rip)     # 0x113dc8
movl $0x2, 0xecc98(%rip)     # 0x113dcc
movl $0x0, 0xecc9a(%rip)     # 0x113dd8
movl $0x64, 0xecc94(%rip)    # 0x113ddc
movq $0x4000000, 0xecc8d(%rip) # imm = 0x4000000
movq $0x0, 0xecc8a(%rip) # 0x113de8
movl $0x0, 0xecc90(%rip)     # 0x113df8
xorl %eax, %eax
movl %eax, %edi
callq 0x1fc70
movq %rax, 0xecca8(%rip)     # 0x113e20
movq $-0x1, 0xecca5(%rip) # 0x113e28
movq $-0x1, 0xecca2(%rip) # 0x113e30
movl $0x0, 0xecca0(%rip)     # 0x113e38
movq $0x0, 0xecc9d(%rip) # 0x113e40
movl $0xffffffff, 0xecc63(%rip) # imm = 0xFFFFFFFF
movl $0xffffffff, 0xecc5d(%rip) # imm = 0xFFFFFFFF
movq $0x0, 0xecc56(%rip) # 0x113e18
movl $0x1, 0xecc7c(%rip)     # 0x113e48
leaq 0xb7bac(%rip), %rdi     # 0xded7f
callq 0x2e430
movq %rax, 0xec761(%rip)     # 0x113940
leaq 0xb7bac(%rip), %rdi     # 0xded92
callq 0x2e430
movq %rax, 0xecc8e(%rip)     # 0x113e80
leaq 0xb7ba2(%rip), %rdi     # 0xded9b
callq 0x2e430
movq %rax, 0xecbcb(%rip)     # 0x113dd0
movq $0x0, 0xec728(%rip) # 0x113938
movl $0x1, 0xecc6e(%rip)     # 0x113e88
movl $0x1, 0xecc68(%rip)     # 0x113e8c
movl $0x1, 0xecc86(%rip)     # 0x113eb4
movl $0x1, 0xec6f8(%rip)     # 0x113930
movl $0x0, 0xece6e(%rip)     # 0x1140b0
movl $0x2710, 0xecdc8(%rip)  # imm = 0x2710
movl $0x0, 0xecdd2(%rip)     # 0x114028
movq $0x0, 0xecdb7(%rip) # 0x114018
movl $0x5, 0xecdb5(%rip)     # 0x114020
movl $0x5, 0xecdaf(%rip)     # 0x114024
movq $0x200, 0xecdd0(%rip) # imm = 0x200
movq $0x40, 0xecdcd(%rip) # 0x114058
movq $0x200, 0xecdca(%rip) # imm = 0x200
movq $0x40, 0xecdc7(%rip) # 0x114068
movq $0x200, 0xecdc4(%rip) # imm = 0x200
movq $0x80, 0xecdc1(%rip) # 0x114078
movq $0x40, 0xecdbe(%rip) # 0x114080
movq $0xbb8, 0xecdbb(%rip) # imm = 0xBB8
movl $0x0, 0xec655(%rip)     # 0x11392c
movl $0xa, 0xecc0f(%rip)     # 0x113ef0
movl $0x3c, 0xecc69(%rip)    # 0x113f54
movl $0x0, 0xecc3b(%rip)     # 0x113f30
movl $0xa, 0xecc35(%rip)     # 0x113f34
movl $0x0, 0xecdab(%rip)     # 0x1140b4
movq $0x3a98, 0xecda4(%rip) # imm = 0x3A98
movl $0x1, 0xecdb2(%rip)     # 0x1140d0
leaq 0xb7a85(%rip), %rdi     # 0xdedaa
callq 0x2e430
movq %rax, 0xecd8f(%rip)     # 0x1140c0
movq $0x0, 0xecdac(%rip) # 0x1140e8
movq $0x1388, 0xecdb1(%rip) # imm = 0x1388
movq $0x0, 0xecd8e(%rip) # 0x1140e0
movl $0x0, 0xecdb4(%rip)     # 0x114110
leaq 0xeb6fd(%rip), %rdi     # 0x112a60
xorl %eax, %eax
movl %eax, %esi
callq 0x231a0
movq %rax, 0xec86d(%rip)     # 0x113be0
movq $0x200000, 0xec88a(%rip) # imm = 0x200000
callq 0x25cb0
movl %eax, %ecx
movl 0xec59d(%rip), %eax     # 0x113928
andl $0xffffff, %ecx         # imm = 0xFFFFFF
andl $0xff000000, %eax       # imm = 0xFF000000
orl %ecx, %eax
movl %eax, 0xec58a(%rip)     # 0x113928
movb $0x0, %al
callq 0x571f0
movl $0xe10, %edi            # imm = 0xE10
movl $0x1, %esi
callq 0x57130
movl $0x12c, %edi            # imm = 0x12C
movl $0x64, %esi
callq 0x57130
movl $0x3c, %edi
movl $0x2710, %esi           # imm = 0x2710
callq 0x57130
movq $0x0, 0xecb63(%rip) # 0x113f40
movq $0x0, 0xecb60(%rip) # 0x113f48
movl $0x18eb, 0xecb5e(%rip)  # imm = 0x18EB
movq $0x0, 0xecb5b(%rip) # 0x113f58
movq $0x0, 0xecb58(%rip) # 0x113f60
movq $-0x1, 0xecbd5(%rip) # 0x113fe8
movl $0x0, 0xecb4f(%rip)     # 0x113f6c
movl $0x5, 0xecb41(%rip)     # 0x113f68
movl $0x1, 0xecb6f(%rip)     # 0x113fa0
movl $0x1, 0xecb69(%rip)     # 0x113fa4
movq $0x0, 0xecb62(%rip) # 0x113fa8
movl $0x0, 0xecb60(%rip)     # 0x113fb0
movl $0x64, 0xecb5a(%rip)    # 0x113fb4
movq $0x0, 0xeca83(%rip) # 0x113ee8
movq $0x0, 0xeca88(%rip) # 0x113ef8
movq $0x100000, 0xeca85(%rip) # imm = 0x100000
movq $0x0, 0xeca82(%rip) # 0x113f08
movq $0x0, 0xeca7f(%rip) # 0x113f10
movq $0x0, 0xeca7c(%rip) # 0x113f18
movq $0xe10, 0xeca79(%rip) # imm = 0xE10
xorl %eax, %eax
movl %eax, %edi
callq 0x1fc70
movq %rax, 0xeca71(%rip)     # 0x113f28
movl $0x0, -0x4(%rbp)
cmpl $0x3, -0x4(%rbp)
jge 0x2750f
movslq -0x4(%rbp), %rcx
leaq 0xec429(%rip), %rax     # 0x1138f8
addq $0x488, %rax            # imm = 0x488
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x4(%rbp), %rdx
leaq 0xeb5f9(%rip), %rcx     # 0x112ae0
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rax)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x274be
xorps %xmm0, %xmm0
movsd %xmm0, 0x100866(%rip)   # 0x127d80
movsd 0xb6cb6(%rip), %xmm0    # 0xde1d8
divsd 0x100856(%rip), %xmm0   # 0x127d80
movsd %xmm0, 0x100856(%rip)   # 0x127d88
movsd 0xb6c96(%rip), %xmm0    # 0xde1d0
divsd 0x10083e(%rip), %xmm0   # 0x127d80
movsd %xmm0, 0x100846(%rip)   # 0x127d90
movsd 0x10082e(%rip), %xmm0   # 0x127d80
divsd 0x100826(%rip), %xmm0   # 0x127d80
movsd %xmm0, 0x100836(%rip)   # 0x127d98
leaq 0xeb407(%rip), %rdi     # 0x112970
xorl %eax, %eax
movl %eax, %esi
callq 0x231a0
movq %rax, 0xec397(%rip)     # 0x113910
leaq 0xeb3f0(%rip), %rdi     # 0x112970
xorl %eax, %eax
movl %eax, %esi
callq 0x231a0
movq %rax, 0xec388(%rip)     # 0x113918
callq 0x27650
leaq 0xb6f69(%rip), %rdi     # 0xde505
callq 0x27880
movq %rax, 0xec668(%rip)     # 0x113c10
leaq 0xb7006(%rip), %rdi     # 0xde5b5
callq 0x27880
movq %rax, 0xec65d(%rip)     # 0x113c18
leaq 0xb6d8d(%rip), %rdi     # 0xde34f
callq 0x27880
movq %rax, 0xec652(%rip)     # 0x113c20
leaq 0xb6d85(%rip), %rdi     # 0xde35a
callq 0x27880
movq %rax, 0xec647(%rip)     # 0x113c28
leaq 0xb6d5a(%rip), %rdi     # 0xde342
callq 0x27880
movq %rax, 0xec63c(%rip)     # 0x113c30
movq $0x2710, 0xec6b1(%rip) # imm = 0x2710
movq $0x80, 0xec6ae(%rip) # 0x113cb8
leaq 0xb77a4(%rip), %rax     # 0xdedb5
movq %rax, 0xecb00(%rip)     # 0x114118
leaq 0xb77ac(%rip), %rax     # 0xdedcb
movq %rax, 0xecafa(%rip)     # 0x114120
movl $0x0, 0xecaf8(%rip)     # 0x114128
movl $0x0, 0xecaf2(%rip)     # 0x11412c
movl $0x0, 0xecaec(%rip)     # 0x114130
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)