// File: /workspace/github_c_makefile_star2_O3/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 0x124a0
movl $0x1, %esi
movl $0xd, %edi
callq 0x124a0
callq 0x1bb75
cmpl $0x0, 0x53e1b(%rip)     # 0x6f680
je 0x1b87e
movq 0x53e1a(%rip), %rdi     # 0x6f688
movl 0x53e1c(%rip), %edx     # 0x6f690
movl $0x19, %esi
callq 0x12830
callq 0x121f0
movl %eax, 0x537ff(%rip)     # 0x6f088
movq $0x0, 0x539f4(%rip) # 0x6f288
callq 0x164dc
movq %rax, 0x539c8(%rip)     # 0x6f268
callq 0x164dc
movq %rax, 0x539c4(%rip)     # 0x6f270
callq 0x164dc
movq %rax, 0x539c8(%rip)     # 0x6f280
callq 0x164dc
movq %rax, 0x539b4(%rip)     # 0x6f278
callq 0x164dc
movq %rax, 0x53df0(%rip)     # 0x6f6c0
callq 0x164dc
movq %rax, 0x53dec(%rip)     # 0x6f6c8
movl $0x0, 0x539aa(%rip)     # 0x6f290
callq 0x1a9fb
callq 0x1b401
movl 0x53d9e(%rip), %edi     # 0x6f694
subl $-0x80, %edi
callq 0x16900
movq %rax, 0x537bb(%rip)     # 0x6f0c0
movl 0x53831(%rip), %edi     # 0x6f13c
testl %edi, %edi
je 0x1b92b
leaq 0x538c6(%rip), %rsi     # 0x6f1dc
leaq 0x538ff(%rip), %rdx     # 0x6f21c
callq 0x1b612
cmpl $-0x1, %eax
je 0x1bb56
movq 0x5389e(%rip), %rdi     # 0x6f1d0
testq %rdi, %rdi
je 0x1b973
callq 0x120f0
movq 0x5388d(%rip), %rsi     # 0x6f1d0
movl 0x5388f(%rip), %edx     # 0x6f1d8
movl 0x537f1(%rip), %ecx     # 0x6f140
leaq 0x5394a(%rip), %rdi     # 0x6f2a0
callq 0x17ee8
movl %eax, 0x538bf(%rip)     # 0x6f220
cmpl $-0x1, %eax
je 0x1bb3c
xorl %edi, %edi
movl %eax, %esi
callq 0x17589
cmpl $0x0, 0x538a2(%rip)     # 0x6f21c
jne 0x1b989
cmpl $0x0, 0x5389d(%rip)     # 0x6f220
js 0x1bb12
leaq 0x53410(%rip), %rdi     # 0x6eda0
xorl %ebx, %ebx
xorl %esi, %esi
callq 0x184d5
movq %rax, 0x53d00(%rip)     # 0x6f6a0
movl %ebx, 0x5373e(%rip)     # 0x6f0e4
movl $0xffffffff, 0x53d88(%rip) # imm = 0xFFFFFFFF
movl %ebx, 0x53dca(%rip)     # 0x6f780
xorl %edi, %edi
callq 0x12540
movq %rax, 0x53d9c(%rip)     # 0x6f760
movq %rbx, 0x53d9d(%rip)     # 0x6f768
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x53d99(%rip)    # 0x6f770
movq %rbx, 0x53d4a(%rip)     # 0x6f728
callq 0x1b776
xorl %edi, %edi
callq 0x12540
movq %rax, 0x53a07(%rip)     # 0x6f3f8
movq %rbx, 0x53a18(%rip)     # 0x6f410
movq %rbx, 0x53a31(%rip)     # 0x6f430
callq 0x1a603
movq 0x536b5(%rip), %rdi     # 0x6f0c0
leaq -0x13bc(%rip), %rdx     # 0x1a656
movl $0x1, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x16eb3
cmpq $-0x1, %rax
je 0x1bb27
cmpl $0x0, 0x537ea(%rip)     # 0x6f21c
jle 0x1ba7c
xorl %r14d, %r14d
leaq 0x5364a(%rip), %r15     # 0x6f088
leaq 0x6e8d(%rip), %rbx      # 0x228d2
movq 0x53674(%rip), %rdi     # 0x6f0c0
movl 0x154(%r15,%r14,4), %esi
movl $0x1, %edx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x16d02
cmpl $-0x1, %eax
je 0x1baf0
incq %r14
movslq 0x537a5(%rip), %rax     # 0x6f21c
cmpq %rax, %r14
jl 0x1ba45
movl 0x5379e(%rip), %esi     # 0x6f220
testl %esi, %esi
jle 0x1baaa
movq 0x53633(%rip), %rdi     # 0x6f0c0
leaq 0x6f82(%rip), %rcx      # 0x22a16
movl $0x1, %edx
xorl %r8d, %r8d
callq 0x16d02
cmpl $-0x1, %eax
je 0x1bb60
cmpl $0x20, 0x5362f(%rip)    # 0x6f0e0
jne 0x1badc
cmpq $0x0, 0x53bdd(%rip)     # 0x6f698
jne 0x1badc
leaq 0x37550(%rip), %rsi     # 0x53014
movl $0x3, %edi
xorl %eax, %eax
callq 0x19c06
movl $0xc0000000, %eax       # imm = 0xC0000000
movq %rax, 0x53bbc(%rip)     # 0x6f698
callq 0x2bda5
callq 0x2fd77
popq %rbx
popq %r14
popq %r15
jmp 0x2ec34
leaq 0x374af(%rip), %rdi     # 0x52fa6
leaq 0x3749f(%rip), %rsi     # 0x52f9d
movl $0x4fe, %edx            # imm = 0x4FE
callq 0x2a81d
movl $0x1, %edi
callq 0x12120
leaq 0x3742e(%rip), %rsi     # 0x52f47
movl $0x3, %edi
xorl %eax, %eax
callq 0x19c06
jmp 0x1bb56
leaq 0x37445(%rip), %rdi     # 0x52f73
leaq 0x37468(%rip), %rsi     # 0x52f9d
movl $0x4f3, %edx            # imm = 0x4F3
jmp 0x1bb03
leaq 0x373ec(%rip), %rsi     # 0x52f2f
leaq 0x53756(%rip), %rdx     # 0x6f2a0
movl $0x3, %edi
xorl %eax, %eax
callq 0x19c06
movl $0x1, %edi
callq 0x12860
leaq 0x37476(%rip), %rdi     # 0x52fdd
leaq 0x3742f(%rip), %rsi     # 0x52f9d
movl $0x502, %edx            # imm = 0x502
jmp 0x1bb03