// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x10, %rsp
movl $0x1, %edi
movl $0x1, %esi
callq 0x12490
movl $0xd, %edi
movl $0x1, %esi
callq 0x12490
callq 0x1b510
cmpl $0x0, 0xa455e(%rip)     # 0xbf6e0
je 0x1b19b
movq 0xa455d(%rip), %rdi     # 0xbf6e8
movl 0xa455f(%rip), %edx     # 0xbf6f0
movl $0x19, %esi
callq 0x12830
callq 0x121d0
movl %eax, 0xa3f42(%rip)     # 0xbf0e8
movq $0x0, 0xa4137(%rip) # 0xbf2e8
callq 0x12b00
movq %rax, 0xa410b(%rip)     # 0xbf2c8
callq 0x12b00
movq %rax, 0xa4107(%rip)     # 0xbf2d0
callq 0x12b00
movq %rax, 0xa410b(%rip)     # 0xbf2e0
callq 0x12b00
movq %rax, 0xa40f7(%rip)     # 0xbf2d8
callq 0x12b00
movq %rax, 0xa4533(%rip)     # 0xbf720
callq 0x12b00
movq %rax, 0xa452f(%rip)     # 0xbf728
movl $0x0, 0xa40ed(%rip)     # 0xbf2f0
callq 0x19ed0
callq 0x1aaf0
movl 0xa44e1(%rip), %edi     # 0xbf6f4
addl $0x80, %edi
callq 0x133c0
movq %rax, 0xa3efb(%rip)     # 0xbf120
cmpl $0x0, 0xa3f70(%rip)     # 0xbf19c
je 0x1b260
movl 0xa3f68(%rip), %edi     # 0xbf19c
leaq 0xa3ead(%rip), %rdx     # 0xbf0e8
movq %rdx, %rsi
addq $0x154, %rsi            # imm = 0x154
addq $0x194, %rdx            # imm = 0x194
callq 0x1ad70
cmpl $-0x1, %eax
jne 0x1b260
movl $0x1, %edi
callq 0x12870
cmpq $0x0, 0xa3fc8(%rip)     # 0xbf230
je 0x1b2e5
movq 0xa3fbf(%rip), %rdi     # 0xbf230
callq 0x120d0
movq 0xa3fb3(%rip), %rsi     # 0xbf230
movl 0xa3fb5(%rip), %edx     # 0xbf238
movl 0xa3f17(%rip), %ecx     # 0xbf1a0
leaq 0xa3e58(%rip), %rdi     # 0xbf0e8
addq $0x218, %rdi            # imm = 0x218
callq 0x15690
movl %eax, 0xa3fde(%rip)     # 0xbf280
cmpl $-0x1, 0xa3fd7(%rip)    # 0xbf280
jne 0x1b2d6
movl $0x3, %edi
leaq 0x88c48(%rip), %rsi     # 0xa3eff
leaq 0xa3e2a(%rip), %rdx     # 0xbf0e8
addq $0x218, %rdx            # imm = 0x218
movb $0x0, %al
callq 0x18b10
movl $0x1, %edi
callq 0x12870
movl 0xa3fa4(%rip), %esi     # 0xbf280
xorl %eax, %eax
movl %eax, %edi
callq 0x14750
cmpl $0x0, 0xa3f90(%rip)     # 0xbf27c
jne 0x1b314
cmpl $0x0, 0xa3f8b(%rip)     # 0xbf280
jge 0x1b314
movl $0x3, %edi
leaq 0x88c14(%rip), %rsi     # 0xa3f17
movb $0x0, %al
callq 0x18b10
movl $0x1, %edi
callq 0x12870
leaq 0xa3a85(%rip), %rdi     # 0xbeda0
xorl %eax, %eax
movl %eax, %esi
callq 0x16120
movq %rax, 0xa43d5(%rip)     # 0xbf700
movl $0x0, 0xa3e0f(%rip)     # 0xbf144
movl $0xffffffff, 0xa4459(%rip) # imm = 0xFFFFFFFF
movl $0x0, 0xa4497(%rip)     # 0xbf7e0
xorl %eax, %eax
movl %eax, %edi
callq 0x12530
movq %rax, 0xa4467(%rip)     # 0xbf7c0
movq $0x0, 0xa4464(%rip) # 0xbf7c8
movq $-0x1, 0xa4461(%rip) # 0xbf7d0
movq $-0x1, 0xa445e(%rip) # 0xbf7d8
movq $0x0, 0xa4403(%rip) # 0xbf788
callq 0x1b020
xorl %eax, %eax
movl %eax, %edi
callq 0x12530
movq %rax, 0xa40be(%rip)     # 0xbf458
movq $0x0, 0xa40cb(%rip) # 0xbf470
movq $0x0, 0xa40e0(%rip) # 0xbf490
callq 0x19a30
movq 0xa3d64(%rip), %rdi     # 0xbf120
movl $0x1, %esi
leaq -0x1968(%rip), %rdx     # 0x19a60
xorl %eax, %eax
movl %eax, %r8d
movq %r8, %rcx
callq 0x13b70
cmpq $-0x1, %rax
jne 0x1b3fd
leaq 0x88b61(%rip), %rdi     # 0xa3f43
leaq 0x88b84(%rip), %rsi     # 0xa3f6d
movl $0x4f3, %edx            # imm = 0x4F3
callq 0x304a0
movl $0x1, %edi
callq 0x12100
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
cmpl 0xa3e6f(%rip), %eax     # 0xbf27c
jge 0x1b472
movq 0xa3d0a(%rip), %rdi     # 0xbf120
movslq -0x4(%rbp), %rcx
leaq 0xa3cc7(%rip), %rax     # 0xbf0e8
movl 0x154(%rax,%rcx,4), %esi
movl $0x1, %edx
leaq 0x9a0c(%rip), %rcx      # 0x24e40
xorl %eax, %eax
movl %eax, %r8d
callq 0x137d0
cmpl $-0x1, %eax
jne 0x1b465
leaq 0x88b2c(%rip), %rdi     # 0xa3f76
leaq 0x88b1c(%rip), %rsi     # 0xa3f6d
movl $0x4fe, %edx            # imm = 0x4FE
callq 0x304a0
movl $0x1, %edi
callq 0x12100
jmp 0x1b467
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x1b404
cmpl $0x0, 0xa3e07(%rip)     # 0xbf280
jle 0x1b4c5
movq 0xa3c9e(%rip), %rdi     # 0xbf120
movl 0xa3df8(%rip), %esi     # 0xbf280
movl $0x1, %edx
leaq 0x9b8c(%rip), %rcx      # 0x25020
xorl %eax, %eax
movl %eax, %r8d
callq 0x137d0
cmpl $-0x1, %eax
jne 0x1b4c5
leaq 0x88b03(%rip), %rdi     # 0xa3fad
leaq 0x88abc(%rip), %rsi     # 0xa3f6d
movl $0x502, %edx            # imm = 0x502
callq 0x304a0
movl $0x1, %edi
callq 0x12100
cmpl $0x20, 0xa3c74(%rip)    # 0xbf140
jne 0x1b4f7
cmpq $0x0, 0xa4222(%rip)     # 0xbf6f8
jne 0x1b4f7
movl $0x3, %edi
leaq 0x88b00(%rip), %rsi     # 0xa3fe4
movb $0x0, %al
callq 0x18b10
movl $0xc0000000, %eax       # imm = 0xC0000000
movq %rax, 0xa4201(%rip)     # 0xbf6f8
callq 0x32320
callq 0x37f40
callq 0x363d0
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)