// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/server.c
// Function: initServer
void initServer(void) {
    int j;

    signal(SIGHUP, SIG_IGN);
    signal(SIGPIPE, SIG_IGN);
    setupSignalHandlers();

    if (server.syslog_enabled) {
        openlog(server.syslog_ident, LOG_PID | LOG_NDELAY | LOG_NOWAIT,
            server.syslog_facility);
    }

    server.pid = getpid();
    server.current_client = NULL;
    server.clients = listCreate();
    server.clients_to_close = listCreate();
    server.slaves = listCreate();
    server.monitors = listCreate();
    server.clients_pending_write = listCreate();
    server.slaveseldb = -1; /* Force to emit the first SELECT command. */
    server.unblocked_clients = listCreate();
    server.ready_keys = listCreate();
    server.clients_waiting_acks = listCreate();
    server.get_ack_from_slaves = 0;
    server.clients_paused = 0;
    server.system_memory_size = zmalloc_get_memory_size();

    createSharedObjects();
    adjustOpenFilesLimit();
    server.el = aeCreateEventLoop(server.maxclients+CONFIG_FDSET_INCR);
    server.db = zmalloc(sizeof(redisDb)*server.dbnum);

    /* Open the TCP listening socket for the user commands. */
    if (server.port != 0 &&
        listenToPort(server.port,server.ipfd,&server.ipfd_count) == C_ERR)
        exit(1);

    /* Open the listening Unix domain socket. */
    if (server.unixsocket != NULL) {
        unlink(server.unixsocket); /* don't care if this fails */
        server.sofd = anetUnixServer(server.neterr,server.unixsocket,
            server.unixsocketperm, server.tcp_backlog);
        if (server.sofd == ANET_ERR) {
            serverLog(LL_WARNING, "Opening Unix socket: %s", server.neterr);
            exit(1);
        }
        anetNonBlock(NULL,server.sofd);
    }

    /* Abort if there are no listening sockets at all. */
    if (server.ipfd_count == 0 && server.sofd < 0) {
        serverLog(LL_WARNING, "Configured to not listen anywhere, exiting.");
        exit(1);
    }

    /* Create the Redis databases, and initialize other internal state. */
    for (j = 0; j < server.dbnum; j++) {
        server.db[j].dict = dictCreate(&dbDictType,NULL);
        server.db[j].expires = dictCreate(&keyptrDictType,NULL);
        server.db[j].blocking_keys = dictCreate(&keylistDictType,NULL);
        server.db[j].ready_keys = dictCreate(&setDictType,NULL);
        server.db[j].watched_keys = dictCreate(&keylistDictType,NULL);
        server.db[j].eviction_pool = evictionPoolAlloc();
        server.db[j].id = j;
        server.db[j].avg_ttl = 0;
    }
    server.pubsub_channels = dictCreate(&keylistDictType,NULL);
    server.pubsub_patterns = listCreate();
    listSetFreeMethod(server.pubsub_patterns,freePubsubPattern);
    listSetMatchMethod(server.pubsub_patterns,listMatchPubsubPattern);
    server.cronloops = 0;
    server.rdb_child_pid = -1;
    server.aof_child_pid = -1;
    server.rdb_child_type = RDB_CHILD_TYPE_NONE;
    server.rdb_bgsave_scheduled = 0;
    aofRewriteBufferReset();
    server.aof_buf = sdsempty();
    server.lastsave = time(NULL); /* At startup we consider the DB saved. */
    server.lastbgsave_try = 0;    /* At startup we never tried to BGSAVE. */
    server.rdb_save_time_last = -1;
    server.rdb_save_time_start = -1;
    server.dirty = 0;
    resetServerStats();
    /* A few stats we don't want to reset: server startup time, and peak mem. */
    server.stat_starttime = time(NULL);
    server.stat_peak_memory = 0;
    server.resident_set_size = 0;
    server.lastbgsave_status = C_OK;
    server.aof_last_write_status = C_OK;
    server.aof_last_write_errno = 0;
    server.repl_good_slaves_count = 0;
    updateCachedTime();

    /* Create the serverCron() time event, that's our main way to process
     * background operations. */
    if(aeCreateTimeEvent(server.el, 1, serverCron, NULL, NULL) == AE_ERR) {
        serverPanic("Can't create the serverCron time event.");
        exit(1);
    }

    /* Create an event handler for accepting new connections in TCP and Unix
     * domain sockets. */
    for (j = 0; j < server.ipfd_count; j++) {
        if (aeCreateFileEvent(server.el, server.ipfd[j], AE_READABLE,
            acceptTcpHandler,NULL) == AE_ERR)
            {
                serverPanic(
                    "Unrecoverable error creating server.ipfd file event.");
            }
    }
    if (server.sofd > 0 && aeCreateFileEvent(server.el,server.sofd,AE_READABLE,
        acceptUnixHandler,NULL) == AE_ERR) serverPanic("Unrecoverable error creating server.sofd file event.");

    /* Open the AOF file if needed. */
    if (server.aof_state == AOF_ON) {
        server.aof_fd = open(server.aof_filename,
                               O_WRONLY|O_APPEND|O_CREAT,0644);
        if (server.aof_fd == -1) {
            serverLog(LL_WARNING, "Can't open the append-only file: %s",
                strerror(errno));
            exit(1);
        }
    }

    /* 32 bit instances are limited to 4GB of address space, so if there is
     * no explicit limit in the user provided configuration we set a limit
     * at 3 GB using maxmemory with 'noeviction' policy'. This avoids
     * useless crashes of the Redis instance for out of memory. */
    if (server.arch_bits == 32 && server.maxmemory == 0) {
        serverLog(LL_WARNING,"Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now.");
        server.maxmemory = 3072LL*(1024*1024); /* 3 GB */
        server.maxmemory_policy = MAXMEMORY_NO_EVICTION;
    }

    if (server.cluster_enabled) clusterInit();
    replicationScriptCacheInit();
    scriptingInit(1);
    slowlogInit();
    latencyMonitorInit();
    bioInit();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
pushq $0x1
popq %rdi
pushq $0x1
popq %rbx
movq %rbx, %rsi
callq 0x267d0
pushq $0xd
popq %rdi
movq %rbx, %rsi
callq 0x267d0
callq 0x2df4c
cmpl $0x0, 0xcc5d1(%rip)     # 0xfa050
je 0x2da96
movq 0xcc5d0(%rip), %rdi     # 0xfa058
movl 0xcc5d2(%rip), %edx     # 0xfa060
pushq $0x19
popq %rsi
callq 0x262a0
callq 0x26420
movl %eax, 0xcbe07(%rip)     # 0xf98a8
andq $0x0, 0xcbfef(%rip)     # 0xf9a98
callq 0x26e0c
movq %rax, 0xcbfbb(%rip)     # 0xf9a70
callq 0x26e0c
movq %rax, 0xcbfb7(%rip)     # 0xf9a78
callq 0x26e0c
movq %rax, 0xcbfbb(%rip)     # 0xf9a88
callq 0x26e0c
movq %rax, 0xcbfb7(%rip)     # 0xf9a90
callq 0x26e0c
movq %rax, 0xcbf9b(%rip)     # 0xf9a80
orl $-0x1, 0xcc578(%rip)    # 0xfa064
callq 0x26e0c
movq %rax, 0xcc6d0(%rip)     # 0xfa1c8
callq 0x26e0c
movq %rax, 0xcc6cc(%rip)     # 0xfa1d0
callq 0x26e0c
movq %rax, 0xcc690(%rip)     # 0xfa1a0
andl $0x0, 0xcc691(%rip)     # 0xfa1a8
andl $0x0, 0xcbf82(%rip)     # 0xf9aa0
callq 0x32b9c
movq %rax, 0xcc7c6(%rip)     # 0xfa2f0
callq 0x2c897
callq 0x2d623
movl 0xcc672(%rip), %edi     # 0xfa1ac
subl $-0x80, %edi
callq 0x288fc
movq %rax, 0xcbd9f(%rip)     # 0xf98e8
movslq 0xcc368(%rip), %rdi     # 0xf9eb8
shlq $0x6, %rdi
callq 0x327b9
movq %rax, 0xcbd70(%rip)     # 0xf98d0
movl 0xcbde2(%rip), %edi     # 0xf9948
testl %edi, %edi
je 0x2db86
leaq 0xcbe73(%rip), %rsi     # 0xf99e4
leaq 0xcbeac(%rip), %rdx     # 0xf9a24
callq 0x2d7ff
cmpl $-0x1, %eax
je 0x2df44
movq 0xcbe4b(%rip), %rdi     # 0xf99d8
testq %rdi, %rdi
je 0x2dbce
callq 0x263b0
movq 0xcbe3a(%rip), %rsi     # 0xf99d8
movl 0xcbe3c(%rip), %edx     # 0xf99e0
movl 0xcbda2(%rip), %ecx     # 0xf994c
leaq 0xcbeff(%rip), %rdi     # 0xf9ab0
callq 0x29bc2
movl %eax, 0xcbe6c(%rip)     # 0xf9a28
cmpl $-0x1, %eax
je 0x2def9
xorl %edi, %edi
movl %eax, %esi
callq 0x2929c
cmpl $0x0, 0xcbe4f(%rip)     # 0xf9a24
jne 0x2dbe4
cmpl $0x0, 0xcbe4a(%rip)     # 0xf9a28
js 0x2dece
xorl %r13d, %r13d
leaq 0xcb222(%rip), %rbx     # 0xf8e10
leaq 0xcb27b(%rip), %r14     # 0xf8e70
leaq 0xcb304(%rip), %r15     # 0xf8f00
leaq 0xcb1ad(%rip), %r12     # 0xf8db0
xorl %ebp, %ebp
movslq 0xcc2ac(%rip), %rax     # 0xf9eb8
cmpq %rax, %rbp
jge 0x2dcaa
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2a155
movq 0xcbcaa(%rip), %rcx     # 0xf98d0
movq %rax, (%rcx,%r13)
movq %r14, %rdi
xorl %esi, %esi
callq 0x2a155
movq 0xcbc95(%rip), %rcx     # 0xf98d0
movq %rax, 0x8(%rcx,%r13)
movq %r15, %rdi
xorl %esi, %esi
callq 0x2a155
movq 0xcbc7f(%rip), %rcx     # 0xf98d0
movq %rax, 0x10(%rcx,%r13)
movq %r12, %rdi
xorl %esi, %esi
callq 0x2a155
movq 0xcbc69(%rip), %rcx     # 0xf98d0
movq %rax, 0x18(%rcx,%r13)
movq %r15, %rdi
xorl %esi, %esi
callq 0x2a155
movq 0xcbc53(%rip), %rcx     # 0xf98d0
movq %rax, 0x20(%rcx,%r13)
callq 0x2dfee
movq 0xcbc42(%rip), %rcx     # 0xf98d0
movq %rax, 0x28(%rcx,%r13)
movl %ebp, 0x30(%rcx,%r13)
andq $0x0, 0x38(%rcx,%r13)
incq %rbp
addq $0x40, %r13
jmp 0x2dc05
leaq 0xcb24f(%rip), %rdi     # 0xf8f00
xorl %esi, %esi
callq 0x2a155
movq %rax, 0xcc571(%rip)     # 0xfa230
callq 0x26e0c
movq %rax, 0xcc56d(%rip)     # 0xfa238
leaq 0x28612(%rip), %rcx     # 0x562e4
movq %rcx, 0x18(%rax)
leaq 0x2861d(%rip), %rcx     # 0x562fa
movq %rcx, 0x20(%rax)
andl $0x0, 0xcbc2c(%rip)     # 0xf9914
orl $-0x1, 0xcc2e9(%rip)    # 0xf9fd8
orl $-0x1, 0xcc24e(%rip)    # 0xf9f44
andq $0x0, 0xcc322(%rip)     # 0xfa020
callq 0x53798
callq 0x3114c
movq %rax, 0xcc241(%rip)     # 0xf9f50
xorl %edi, %edi
callq 0x26cd0
movq %rax, 0xcc2e3(%rip)     # 0xfa000
andq $0x0, 0xcc2e3(%rip)     # 0xfa008
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0xcc2df(%rip)    # 0xfa010
andq $0x0, 0xcc28f(%rip)     # 0xf9fc8
callq 0x2d9bf
xorl %edi, %edi
callq 0x26cd0
movq %rax, 0xcbee4(%rip)     # 0xf9c30
andq $0x0, 0xcbf14(%rip)     # 0xf9c68
andq $0x0, 0xcbf64(%rip)     # 0xf9cc0
andl $0x0, 0xcc2c5(%rip)     # 0xfa028
andq $0x0, 0xcc229(%rip)     # 0xf9f94
andl $0x0, 0xcc346(%rip)     # 0xfa0b8
callq 0x2c1ab
movq 0xcbb6a(%rip), %rdi     # 0xf98e8
leaq -0x1bbd(%rip), %rdx     # 0x2c1c8
pushq $0x1
popq %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x28c7e
cmpq $-0x1, %rax
je 0x2dee1
xorl %r14d, %r14d
leaq 0xcbb02(%rip), %r15     # 0xf98a8
leaq 0x94df(%rip), %rbx      # 0x3728c
pushq $0x1
popq %rbp
movslq 0xcbc6d(%rip), %rax     # 0xf9a24
cmpq %rax, %r14
jge 0x2de00
movq 0xcbb25(%rip), %rdi     # 0xf98e8
movl 0x13c(%r15,%r14,4), %esi
movl %ebp, %edx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x28ae8
incq %r14
cmpl $-0x1, %eax
jne 0x2ddb0
leaq 0x8161a(%rip), %rdi     # 0xaf401
leaq 0x8160a(%rip), %rsi     # 0xaf3f8
movl $0x7bb, %edx            # imm = 0x7BB
callq 0x57b45
pushq $0x1
popq %rdi
callq 0x263c0
movl 0xcbc22(%rip), %esi     # 0xf9a28
testl %esi, %esi
jle 0x2de2c
movq 0xcbad7(%rip), %rdi     # 0xf98e8
leaq 0x9636(%rip), %rcx      # 0x3744e
pushq $0x1
popq %rdx
xorl %r8d, %r8d
callq 0x28ae8
cmpl $-0x1, %eax
je 0x2df0c
cmpl $0x1, 0xcc0dd(%rip)     # 0xf9f10
jne 0x2de5c
movq 0xcc0dc(%rip), %rdi     # 0xf9f18
movl $0x441, %esi            # imm = 0x441
movl $0x1a4, %edx            # imm = 0x1A4
xorl %eax, %eax
callq 0x26690
movl %eax, 0xcc105(%rip)     # 0xf9f58
cmpl $-0x1, %eax
je 0x2df24
cmpl $0x20, 0xcbaad(%rip)    # 0xf9910
jne 0x2de96
cmpq $0x0, 0xcc343(%rip)     # 0xfa1b0
jne 0x2de96
leaq 0x8161d(%rip), %rsi     # 0xaf493
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x2b699
movl $0xc0000000, %eax       # imm = 0xC0000000
movq %rax, 0xcc324(%rip)     # 0xfa1b0
movl $0x5, 0xcc322(%rip)     # 0xfa1b8
cmpl $0x0, 0xcc3a7(%rip)     # 0xfa244
je 0x2dea4
callq 0x5b700
callq 0x3fbc4
pushq $0x1
popq %rdi
callq 0x639f4
callq 0x62181
callq 0x71e66
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x666fc
leaq 0x814cd(%rip), %rsi     # 0xaf3a2
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x2b699
jmp 0x2df44
leaq 0x814e6(%rip), %rdi     # 0xaf3ce
leaq 0x81509(%rip), %rsi     # 0xaf3f8
movl $0x7b0, %edx            # imm = 0x7B0
jmp 0x2ddf3
leaq 0x8148a(%rip), %rsi     # 0xaf38a
leaq 0xcbba9(%rip), %rdx     # 0xf9ab0
pushq $0x3
popq %rdi
jmp 0x2df3d
leaq 0x81525(%rip), %rdi     # 0xaf438
leaq 0x814de(%rip), %rsi     # 0xaf3f8
movl $0x7bf, %edx            # imm = 0x7BF
jmp 0x2ddf3
callq 0x26880
movl (%rax), %edi
callq 0x26680
leaq 0x81538(%rip), %rsi     # 0xaf46f
pushq $0x3
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2b699
pushq $0x1
popq %rdi
callq 0x262c0