// File: /workspace/github_c_makefile_star2_O2/erikdubbelboer[P]discnt/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.monitors = listCreate();
    server.clients_pending_write = listCreate();
    server.unblocked_clients = listCreate();
    server.ready_keys = listCreate();
    server.clients_paused = 0;

    createSharedObjects();
    adjustOpenFilesLimit();
    server.el = aeCreateEventLoop(server.maxclients+CONFIG_FDSET_INCR);
    /* 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 Discnt data structures, and init other internal state. */
    server.counters = dictCreate(&counterDictType,NULL);
    server.cronloops = 0;
    server.ddb_child_pid = -1;
    server.ddb_child_type = DDB_CHILD_TYPE_NONE;
    server.lastsave = time(NULL); /* At startup we consider the DB saved. */
    server.lastbgsave_try = 0;    /* At startup we never tried to BGSAVE. */
    server.ddb_save_time_last = -1;
    server.ddb_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;
    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.");

    /* 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 Discnt 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 */
    }

    clusterInit();
    latencyMonitorInit();
    bioInit();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
pushq $0x1
popq %rdi
pushq $0x1
popq %rbx
movq %rbx, %rsi
callq 0x124a0
pushq $0xd
popq %rdi
movq %rbx, %rsi
callq 0x124a0
callq 0x1779a
cmpl $0x0, 0x531df(%rip)     # 0x6a680
je 0x174b8
movq 0x531de(%rip), %rdi     # 0x6a688
movl 0x531e0(%rip), %edx     # 0x6a690
pushq $0x19
popq %rsi
callq 0x12830
callq 0x121f0
movl %eax, 0x52bc5(%rip)     # 0x6a088
andq $0x0, 0x52dbd(%rip)     # 0x6a288
callq 0x12aec
movq %rax, 0x52d91(%rip)     # 0x6a268
callq 0x12aec
movq %rax, 0x52d8d(%rip)     # 0x6a270
callq 0x12aec
movq %rax, 0x52d91(%rip)     # 0x6a280
callq 0x12aec
movq %rax, 0x52d7d(%rip)     # 0x6a278
callq 0x12aec
movq %rax, 0x531b9(%rip)     # 0x6a6c0
callq 0x12aec
movq %rax, 0x531b5(%rip)     # 0x6a6c8
andl $0x0, 0x52d76(%rip)     # 0x6a290
callq 0x166b7
callq 0x170ca
movl 0x5316a(%rip), %edi     # 0x6a694
subl $-0x80, %edi
callq 0x12e80
movq %rax, 0x52b87(%rip)     # 0x6a0c0
movl 0x52bfd(%rip), %edi     # 0x6a13c
testl %edi, %edi
je 0x1755f
leaq 0x52c92(%rip), %rsi     # 0x6a1dc
leaq 0x52ccb(%rip), %rdx     # 0x6a21c
callq 0x1729d
cmpl $-0x1, %eax
je 0x1777a
movq 0x52c6a(%rip), %rdi     # 0x6a1d0
testq %rdi, %rdi
je 0x175a7
callq 0x120f0
movq 0x52c59(%rip), %rsi     # 0x6a1d0
movl 0x52c5b(%rip), %edx     # 0x6a1d8
movl 0x52bbd(%rip), %ecx     # 0x6a140
leaq 0x52d16(%rip), %rdi     # 0x6a2a0
callq 0x140e5
movl %eax, 0x52c8b(%rip)     # 0x6a220
cmpl $-0x1, %eax
je 0x17762
xorl %edi, %edi
movl %eax, %esi
callq 0x1382c
cmpl $0x0, 0x52c6e(%rip)     # 0x6a21c
jne 0x175bd
cmpl $0x0, 0x52c69(%rip)     # 0x6a220
js 0x17737
leaq 0x527dc(%rip), %rdi     # 0x69da0
xorl %esi, %esi
callq 0x1464a
movq %rax, 0x530ce(%rip)     # 0x6a6a0
andl $0x0, 0x52b0b(%rip)     # 0x6a0e4
orl $-0x1, 0x53158(%rip)    # 0x6a738
andl $0x0, 0x53199(%rip)     # 0x6a780
xorl %edi, %edi
callq 0x12540
movq %rax, 0x5316b(%rip)     # 0x6a760
andq $0x0, 0x5316b(%rip)     # 0x6a768
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x53167(%rip)    # 0x6a770
andq $0x0, 0x53117(%rip)     # 0x6a728
callq 0x173fa
xorl %edi, %edi
callq 0x12540
movq %rax, 0x52dd4(%rip)     # 0x6a3f8
andq $0x0, 0x52de4(%rip)     # 0x6a410
andq $0x0, 0x52dfc(%rip)     # 0x6a430
callq 0x1631a
movq 0x52a80(%rip), %rdi     # 0x6a0c0
leaq -0x1310(%rip), %rdx     # 0x16337
pushq $0x1
popq %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x1320e
cmpq $-0x1, %rax
je 0x1774a
xorl %r14d, %r14d
leaq 0x52a20(%rip), %r15     # 0x6a088
leaq 0x5bb4(%rip), %rbx      # 0x1d223
pushq $0x1
popq %rbp
movslq 0x52ba3(%rip), %rax     # 0x6a21c
cmpq %rax, %r14
jge 0x176c2
movq 0x52a3b(%rip), %rdi     # 0x6a0c0
movl 0x154(%r15,%r14,4), %esi
movl %ebp, %edx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x1306c
incq %r14
cmpl $-0x1, %eax
jne 0x17672
leaq 0x3581d(%rip), %rdi     # 0x4cec6
leaq 0x3580d(%rip), %rsi     # 0x4cebd
movl $0x4fe, %edx            # imm = 0x4FE
callq 0x24359
pushq $0x1
popq %rdi
callq 0x12120
movl 0x52b58(%rip), %esi     # 0x6a220
testl %esi, %esi
jle 0x176ee
movq 0x529ed(%rip), %rdi     # 0x6a0c0
leaq 0x5c87(%rip), %rcx      # 0x1d361
pushq $0x1
popq %rdx
xorl %r8d, %r8d
callq 0x1306c
cmpl $-0x1, %eax
je 0x17782
cmpl $0x20, 0x529eb(%rip)    # 0x6a0e0
jne 0x1771e
cmpq $0x0, 0x52f99(%rip)     # 0x6a698
jne 0x1771e
leaq 0x3582c(%rip), %rsi     # 0x4cf34
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x15b9e
movl $0xc0000000, %eax       # imm = 0xC0000000
movq %rax, 0x52f7a(%rip)     # 0x6a698
callq 0x2562d
callq 0x28f03
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x27ef0
leaq 0x35729(%rip), %rsi     # 0x4ce67
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x15b9e
jmp 0x1777a
leaq 0x35742(%rip), %rdi     # 0x4ce93
leaq 0x35765(%rip), %rsi     # 0x4cebd
movl $0x4f3, %edx            # imm = 0x4F3
jmp 0x176b5
leaq 0x356e6(%rip), %rsi     # 0x4ce4f
leaq 0x52b30(%rip), %rdx     # 0x6a2a0
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x15b9e
pushq $0x1
popq %rdi
callq 0x12860
leaq 0x35774(%rip), %rdi     # 0x4cefd
leaq 0x3572d(%rip), %rsi     # 0x4cebd
movl $0x502, %edx            # imm = 0x502
jmp 0x176b5