// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
movl $0x1, %esi
movl $0x1, %edi
callq 0x124b0
movl $0x1, %esi
movl $0xd, %edi
callq 0x124b0
callq 0x1beca
cmpl $0x0, 0x53ac6(%rip)     # 0x6f680
je 0x1bbd3
movq 0x53ac5(%rip), %rdi     # 0x6f688
movl 0x53ac7(%rip), %edx     # 0x6f690
movl $0x19, %esi
callq 0x12840
callq 0x121f0
movl %eax, 0x534aa(%rip)     # 0x6f088
movq $0x0, 0x5369f(%rip) # 0x6f288
callq 0x16a2c
movq %rax, 0x53673(%rip)     # 0x6f268
callq 0x16a2c
movq %rax, 0x5366f(%rip)     # 0x6f270
callq 0x16a2c
movq %rax, 0x53673(%rip)     # 0x6f280
callq 0x16a2c
movq %rax, 0x5365f(%rip)     # 0x6f278
callq 0x16a2c
movq %rax, 0x53a9b(%rip)     # 0x6f6c0
callq 0x16a2c
movq %rax, 0x53a97(%rip)     # 0x6f6c8
movl $0x0, 0x53655(%rip)     # 0x6f290
callq 0x1ad84
callq 0x1b78a
movl 0x53a49(%rip), %edi     # 0x6f694
subl $-0x80, %edi
callq 0x16e60
movq %rax, 0x53466(%rip)     # 0x6f0c0
movl 0x534dc(%rip), %edi     # 0x6f13c
testl %edi, %edi
je 0x1bc80
leaq 0x53571(%rip), %rsi     # 0x6f1dc
leaq 0x535aa(%rip), %rdx     # 0x6f21c
callq 0x1b96a
cmpl $-0x1, %eax
je 0x1beab
movq 0x53549(%rip), %rdi     # 0x6f1d0
testq %rdi, %rdi
je 0x1bcc8
callq 0x120f0
movq 0x53538(%rip), %rsi     # 0x6f1d0
movl 0x5353a(%rip), %edx     # 0x6f1d8
movl 0x5349c(%rip), %ecx     # 0x6f140
leaq 0x535f5(%rip), %rdi     # 0x6f2a0
callq 0x18253
movl %eax, 0x5356a(%rip)     # 0x6f220
cmpl $-0x1, %eax
je 0x1be91
xorl %edi, %edi
movl %eax, %esi
callq 0x178ed
cmpl $0x0, 0x5354d(%rip)     # 0x6f21c
jne 0x1bcde
cmpl $0x0, 0x53548(%rip)     # 0x6f220
js 0x1be67
leaq 0x530bb(%rip), %rdi     # 0x6eda0
xorl %ebx, %ebx
xorl %esi, %esi
callq 0x18875
movq %rax, 0x539ab(%rip)     # 0x6f6a0
movl %ebx, 0x533e9(%rip)     # 0x6f0e4
movl $0xffffffff, 0x53a33(%rip) # imm = 0xFFFFFFFF
movl %ebx, 0x53a75(%rip)     # 0x6f780
xorl %edi, %edi
callq 0x12550
movq %rax, 0x53a47(%rip)     # 0x6f760
movq %rbx, 0x53a48(%rip)     # 0x6f768
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x53a44(%rip)    # 0x6f770
movq %rbx, 0x539f5(%rip)     # 0x6f728
callq 0x1bacb
xorl %edi, %edi
callq 0x12550
movq %rax, 0x536b2(%rip)     # 0x6f3f8
movq %rbx, 0x536c3(%rip)     # 0x6f410
movq %rbx, 0x536dc(%rip)     # 0x6f430
callq 0x1a99d
movq 0x53360(%rip), %rdi     # 0x6f0c0
leaq -0x1377(%rip), %rdx     # 0x1a9f0
movl $0x1, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x1720f
cmpq $-0x1, %rax
je 0x1be7c
cmpl $0x0, 0x53495(%rip)     # 0x6f21c
jle 0x1bdd1
xorl %r14d, %r14d
leaq 0x532f5(%rip), %r15     # 0x6f088
leaq 0x6e3a(%rip), %rbx      # 0x22bd4
movq 0x5331f(%rip), %rdi     # 0x6f0c0
movl 0x154(%r15,%r14,4), %esi
movl $0x1, %edx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x17077
cmpl $-0x1, %eax
je 0x1be45
incq %r14
movslq 0x53450(%rip), %rax     # 0x6f21c
cmpq %rax, %r14
jl 0x1bd9a
movl 0x53449(%rip), %esi     # 0x6f220
testl %esi, %esi
jle 0x1bdff
movq 0x532de(%rip), %rdi     # 0x6f0c0
leaq 0x6f2f(%rip), %rcx      # 0x22d18
movl $0x1, %edx
xorl %r8d, %r8d
callq 0x17077
cmpl $-0x1, %eax
je 0x1beb5
cmpl $0x20, 0x532da(%rip)    # 0x6f0e0
jne 0x1be31
cmpq $0x0, 0x53888(%rip)     # 0x6f698
jne 0x1be31
leaq 0x371ab(%rip), %rsi     # 0x52fc4
movl $0x3, %edi
xorl %eax, %eax
callq 0x19fb1
movl $0xc0000000, %eax       # imm = 0xC0000000
movq %rax, 0x53867(%rip)     # 0x6f698
callq 0x2c390
callq 0x30327
popq %rbx
popq %r14
popq %r15
jmp 0x2f214
leaq 0x3710a(%rip), %rdi     # 0x52f56
leaq 0x370fa(%rip), %rsi     # 0x52f4d
movl $0x4fe, %edx            # imm = 0x4FE
callq 0x2ade4
movl $0x1, %edi
callq 0x12120
leaq 0x37089(%rip), %rsi     # 0x52ef7
movl $0x3, %edi
xorl %eax, %eax
callq 0x19fb1
jmp 0x1beab
leaq 0x370a0(%rip), %rdi     # 0x52f23
leaq 0x370c3(%rip), %rsi     # 0x52f4d
movl $0x4f3, %edx            # imm = 0x4F3
jmp 0x1be58
leaq 0x37047(%rip), %rsi     # 0x52edf
leaq 0x53401(%rip), %rdx     # 0x6f2a0
movl $0x3, %edi
xorl %eax, %eax
callq 0x19fb1
movl $0x1, %edi
callq 0x12870
leaq 0x370d1(%rip), %rdi     # 0x52f8d
leaq 0x3708a(%rip), %rsi     # 0x52f4d
movl $0x502, %edx            # imm = 0x502
jmp 0x1be58