// File: /workspace/github_c_makefile_star2_O3/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
movl $0x1, %esi
movl $0x1, %edi
callq 0x267d0
movl $0x1, %esi
movl $0xd, %edi
callq 0x267d0
callq 0x32b73
cmpl $0x0, 0xcf9e4(%rip)     # 0x102050
je 0x32685
movq 0xcf9e3(%rip), %rdi     # 0x102058
movl 0xcf9e5(%rip), %edx     # 0x102060
movl $0x19, %esi
callq 0x262a0
callq 0x26420
movl %eax, 0xcf218(%rip)     # 0x1018a8
movq $0x0, 0xcf3fd(%rip) # 0x101a98
callq 0x2b17c
movq %rax, 0xcf3c9(%rip)     # 0x101a70
callq 0x2b17c
movq %rax, 0xcf3c5(%rip)     # 0x101a78
callq 0x2b17c
movq %rax, 0xcf3c9(%rip)     # 0x101a88
callq 0x2b17c
movq %rax, 0xcf3c5(%rip)     # 0x101a90
callq 0x2b17c
movq %rax, 0xcf3a9(%rip)     # 0x101a80
movl $0xffffffff, 0xcf983(%rip) # imm = 0xFFFFFFFF
callq 0x2b17c
movq %rax, 0xcfadb(%rip)     # 0x1021c8
callq 0x2b17c
movq %rax, 0xcfad7(%rip)     # 0x1021d0
callq 0x2b17c
movq %rax, 0xcfa9b(%rip)     # 0x1021a0
xorl %eax, %eax
movl %eax, 0xcfa9b(%rip)     # 0x1021a8
movl %eax, 0xcf38d(%rip)     # 0x101aa0
callq 0x386b4
movq %rax, 0xcfbd1(%rip)     # 0x1022f0
callq 0x313cb
callq 0x32185
movl 0xcfa7d(%rip), %edi     # 0x1021ac
subl $-0x80, %edi
callq 0x2ca44
movq %rax, 0xcf1aa(%rip)     # 0x1018e8
movslq 0xcf773(%rip), %rdi     # 0x101eb8
shlq $0x6, %rdi
callq 0x382d1
movq %rax, 0xcf17b(%rip)     # 0x1018d0
movl 0xcf1ed(%rip), %edi     # 0x101948
testl %edi, %edi
je 0x3277b
leaq 0xcf27e(%rip), %rsi     # 0x1019e4
leaq 0xcf2b7(%rip), %rdx     # 0x101a24
callq 0x3239b
cmpl $-0x1, %eax
je 0x32b69
movq 0xcf256(%rip), %rdi     # 0x1019d8
testq %rdi, %rdi
je 0x327c3
callq 0x263b0
movq 0xcf245(%rip), %rsi     # 0x1019d8
movl 0xcf247(%rip), %edx     # 0x1019e0
movl 0xcf1ad(%rip), %ecx     # 0x10194c
leaq 0xcf30a(%rip), %rdi     # 0x101ab0
callq 0x2e074
movl %eax, 0xcf277(%rip)     # 0x101a28
cmpl $-0x1, %eax
je 0x32b1d
xorl %edi, %edi
movl %eax, %esi
callq 0x2d6a1
cmpl $0x0, 0xcf25a(%rip)     # 0x101a24
jne 0x327d9
cmpl $0x0, 0xcf255(%rip)     # 0x101a28
js 0x32af3
cmpl $0x0, 0xcf6d8(%rip)     # 0x101eb8
jle 0x328bc
xorl %ebp, %ebp
leaq 0xce681(%rip), %r14     # 0x100e70
leaq 0xce70a(%rip), %r15     # 0x100f00
leaq 0xce5b3(%rip), %r12     # 0x100db0
xorl %ebx, %ebx
leaq 0xce60a(%rip), %rdi     # 0x100e10
xorl %esi, %esi
callq 0x2e68c
movq 0xcf0bc(%rip), %rcx     # 0x1018d0
movq %rax, (%rcx,%rbp)
movq %r14, %rdi
xorl %esi, %esi
callq 0x2e68c
movq 0xcf0a7(%rip), %rcx     # 0x1018d0
movq %rax, 0x8(%rcx,%rbp)
movq %r15, %rdi
xorl %esi, %esi
callq 0x2e68c
movq 0xcf091(%rip), %rcx     # 0x1018d0
movq %rax, 0x10(%rcx,%rbp)
movq %r12, %rdi
xorl %esi, %esi
callq 0x2e68c
movq 0xcf07b(%rip), %rcx     # 0x1018d0
movq %rax, 0x18(%rcx,%rbp)
movq %r15, %rdi
xorl %esi, %esi
callq 0x2e68c
movq 0xcf065(%rip), %rcx     # 0x1018d0
movq %rax, 0x20(%rcx,%rbp)
movl $0x100, %edi            # imm = 0x100
callq 0x382d1
movq %rax, %r13
movl $0x100, %edx            # imm = 0x100
movq %rax, %rdi
xorl %esi, %esi
callq 0x26110
movq 0xcf03d(%rip), %rax     # 0x1018d0
movq %r13, 0x28(%rax,%rbp)
movl %ebx, 0x30(%rax,%rbp)
movq $0x0, 0x38(%rax,%rbp)
incq %rbx
movslq 0xcf609(%rip), %rax     # 0x101eb8
addq $0x40, %rbp
cmpq %rax, %rbx
jl 0x327ff
leaq 0xce63d(%rip), %rdi     # 0x100f00
xorl %ebx, %ebx
xorl %esi, %esi
callq 0x2e68c
movq %rax, 0xcf95d(%rip)     # 0x102230
callq 0x2b17c
movq %rax, 0xcf959(%rip)     # 0x102238
leaq 0x2d4ea(%rip), %rcx     # 0x5fdd0
movq %rcx, 0x18(%rax)
leaq 0x2d4f5(%rip), %rcx     # 0x5fde6
movq %rcx, 0x20(%rax)
movl %ebx, 0xcf019(%rip)     # 0x101914
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0xcf6d2(%rip)     # 0x101fd8
movl %eax, 0xcf638(%rip)     # 0x101f44
movq %rbx, 0xcf70d(%rip)     # 0x102020
callq 0x5ccf4
callq 0x3628d
movq %rax, 0xcf62c(%rip)     # 0x101f50
xorl %edi, %edi
callq 0x26cd0
movq %rax, 0xcf6ce(%rip)     # 0x102000
movq %rbx, 0xcf6cf(%rip)     # 0x102008
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0xcf6cb(%rip)    # 0x102010
movq %rbx, 0xcf67c(%rip)     # 0x101fc8
callq 0x32562
xorl %edi, %edi
callq 0x26cd0
movq %rax, 0xcf2d1(%rip)     # 0x101c30
movq %rbx, 0xcf302(%rip)     # 0x101c68
movq %rbx, 0xcf353(%rip)     # 0x101cc0
movl %ebx, 0xcf6b5(%rip)     # 0x102028
movq %rbx, 0xcf61a(%rip)     # 0x101f94
movl %ebx, 0xcf738(%rip)     # 0x1020b8
callq 0x30c41
movq 0xcef5c(%rip), %rdi     # 0x1018e8
leaq -0x1cff(%rip), %rdx     # 0x30c94
movl $0x1, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2cfeb
cmpq $-0x1, %rax
je 0x32b08
cmpl $0x0, 0xcf071(%rip)     # 0x101a24
jle 0x329fd
xorl %r14d, %r14d
leaq 0xceee9(%rip), %r15     # 0x1018a8
leaq 0xaad7(%rip), %rbx      # 0x3d49d
movq 0xcef1b(%rip), %rdi     # 0x1018e8
movl 0x13c(%r15,%r14,4), %esi
movl $0x1, %edx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x2ce46
cmpl $-0x1, %eax
je 0x32ad1
incq %r14
movslq 0xcf02c(%rip), %rax     # 0x101a24
cmpq %rax, %r14
jl 0x329c6
movl 0xcf025(%rip), %esi     # 0x101a28
testl %esi, %esi
jle 0x32a2b
movq 0xceeda(%rip), %rdi     # 0x1018e8
leaq 0xac50(%rip), %rcx      # 0x3d665
movl $0x1, %edx
xorl %r8d, %r8d
callq 0x2ce46
cmpl $-0x1, %eax
je 0x32b32
cmpl $0x1, 0xcf4de(%rip)     # 0x101f10
jne 0x32a5b
movq 0xcf4dd(%rip), %rdi     # 0x101f18
movl $0x441, %esi            # imm = 0x441
movl $0x1a4, %edx            # imm = 0x1A4
xorl %eax, %eax
callq 0x26690
movl %eax, 0xcf506(%rip)     # 0x101f58
cmpl $-0x1, %eax
je 0x32b47
cmpl $0x20, 0xceeae(%rip)    # 0x101910
jne 0x32a97
cmpq $0x0, 0xcf744(%rip)     # 0x1021b0
jne 0x32a97
leaq 0x8ab2e(%rip), %rsi     # 0xbd5a3
movl $0x3, %edi
xorl %eax, %eax
callq 0x2fdad
movl $0xc0000000, %eax       # imm = 0xC0000000
movq %rax, 0xcf723(%rip)     # 0x1021b0
movl $0x5, 0xcf721(%rip)     # 0x1021b8
cmpl $0x0, 0xcf7a6(%rip)     # 0x102244
je 0x32aa5
callq 0x65d92
callq 0x471af
movl $0x1, %edi
callq 0x6ed66
callq 0x6d38e
callq 0x7eb56
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x722d0
leaq 0x8aa39(%rip), %rdi     # 0xbd511
leaq 0x8aa29(%rip), %rsi     # 0xbd508
movl $0x7bb, %edx            # imm = 0x7BB
callq 0x619b4
movl $0x1, %edi
callq 0x263c0
leaq 0x8a9b8(%rip), %rsi     # 0xbd4b2
movl $0x3, %edi
xorl %eax, %eax
callq 0x2fdad
jmp 0x32b69
leaq 0x8a9cf(%rip), %rdi     # 0xbd4de
leaq 0x8a9f2(%rip), %rsi     # 0xbd508
movl $0x7b0, %edx            # imm = 0x7B0
jmp 0x32ae4
leaq 0x8a976(%rip), %rsi     # 0xbd49a
leaq 0xcef85(%rip), %rdx     # 0x101ab0
movl $0x3, %edi
jmp 0x32b62
leaq 0x8aa0f(%rip), %rdi     # 0xbd548
leaq 0x8a9c8(%rip), %rsi     # 0xbd508
movl $0x7bf, %edx            # imm = 0x7BF
jmp 0x32ae4
callq 0x26880
movl (%rax), %edi
callq 0x26680
leaq 0x8aa25(%rip), %rsi     # 0xbd57f
movl $0x3, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2fdad
movl $0x1, %edi
callq 0x262c0