// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x10, %rsp
movl $0x1, %edi
movl $0x1, %esi
callq 0x267d0
movl $0xd, %edi
movl $0x1, %esi
callq 0x267d0
callq 0x337f0
cmpl $0x0, 0x1457ae(%rip)    # 0x178980
je 0x331eb
movq 0x1457ad(%rip), %rdi    # 0x178988
movl 0x1457af(%rip), %edx    # 0x178990
movl $0x19, %esi
callq 0x262b0
callq 0x26420
movl %eax, 0x144fe2(%rip)    # 0x1781d8
movq $0x0, 0x1451c7(%rip) # 0x1783c8
callq 0x26e20
movq %rax, 0x145193(%rip)    # 0x1783a0
callq 0x26e20
movq %rax, 0x14518f(%rip)    # 0x1783a8
callq 0x26e20
movq %rax, 0x145193(%rip)    # 0x1783b8
callq 0x26e20
movq %rax, 0x14518f(%rip)    # 0x1783c0
callq 0x26e20
movq %rax, 0x145173(%rip)    # 0x1783b0
movl $0xffffffff, 0x14574d(%rip) # imm = 0xFFFFFFFF
callq 0x26e20
movq %rax, 0x1458a5(%rip)    # 0x178af8
callq 0x26e20
movq %rax, 0x1458a1(%rip)    # 0x178b00
callq 0x26e20
movq %rax, 0x145865(%rip)    # 0x178ad0
movl $0x0, 0x145863(%rip)    # 0x178ad8
movl $0x0, 0x145151(%rip)    # 0x1783d0
callq 0x3b4c0
movq %rax, 0x145995(%rip)    # 0x178c20
callq 0x319f0
callq 0x32a90
movl 0x145841(%rip), %edi    # 0x178adc
addl $0x80, %edi
callq 0x2a4e0
movq %rax, 0x144f6b(%rip)    # 0x178218
movslq 0x145534(%rip), %rdi    # 0x1787e8
shlq $0x6, %rdi
callq 0x3acd0
movq %rax, 0x144f3c(%rip)    # 0x178200
cmpl $0x0, 0x144fad(%rip)    # 0x178278
je 0x332ff
movl 0x144fa5(%rip), %edi    # 0x178278
leaq 0x144efe(%rip), %rdx    # 0x1781d8
movq %rdx, %rsi
addq $0x13c, %rsi            # imm = 0x13C
addq $0x17c, %rdx            # imm = 0x17C
callq 0x32d10
cmpl $-0x1, %eax
jne 0x332ff
movl $0x1, %edi
callq 0x262d0
cmpq $0x0, 0x145001(%rip)    # 0x178308
je 0x33384
movq 0x144ff8(%rip), %rdi    # 0x178308
callq 0x263b0
movq 0x144fec(%rip), %rsi    # 0x178308
movl 0x144fee(%rip), %edx    # 0x178310
movl 0x144f54(%rip), %ecx    # 0x17827c
leaq 0x144ea9(%rip), %rdi    # 0x1781d8
addq $0x208, %rdi            # imm = 0x208
callq 0x2c840
movl %eax, 0x145017(%rip)    # 0x178358
cmpl $-0x1, 0x145010(%rip)   # 0x178358
jne 0x33375
movl $0x3, %edi
leaq 0x1050b4(%rip), %rsi    # 0x13840a
leaq 0x144e7b(%rip), %rdx    # 0x1781d8
addq $0x208, %rdx            # imm = 0x208
movb $0x0, %al
callq 0x2fc60
movl $0x1, %edi
callq 0x262d0
movl 0x144fdd(%rip), %esi    # 0x178358
xorl %eax, %eax
movl %eax, %edi
callq 0x2b860
cmpl $0x0, 0x144fc9(%rip)    # 0x178354
jne 0x333b3
cmpl $0x0, 0x144fc4(%rip)    # 0x178358
jge 0x333b3
movl $0x3, %edi
leaq 0x105080(%rip), %rsi    # 0x138422
movb $0x0, %al
callq 0x2fc60
movl $0x1, %edi
callq 0x262d0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
cmpl 0x145425(%rip), %eax    # 0x1787e8
jge 0x334f3
leaq 0x143a40(%rip), %rdi    # 0x176e10
xorl %eax, %eax
movl %eax, %esi
callq 0x2d330
movq %rax, %rcx
movq 0x144e1d(%rip), %rax    # 0x178200
movslq -0x4(%rbp), %rdx
shlq $0x6, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
leaq 0x143a78(%rip), %rdi    # 0x176e70
xorl %eax, %eax
movl %eax, %esi
callq 0x2d330
movq %rax, %rcx
movq 0x144df5(%rip), %rax    # 0x178200
movslq -0x4(%rbp), %rdx
shlq $0x6, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
leaq 0x143adf(%rip), %rdi    # 0x176f00
xorl %eax, %eax
movl %eax, %esi
callq 0x2d330
movq %rax, %rcx
movq 0x144dcc(%rip), %rax    # 0x178200
movslq -0x4(%rbp), %rdx
shlq $0x6, %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
leaq 0x143966(%rip), %rdi    # 0x176db0
xorl %eax, %eax
movl %eax, %esi
callq 0x2d330
movq %rax, %rcx
movq 0x144da3(%rip), %rax    # 0x178200
movslq -0x4(%rbp), %rdx
shlq $0x6, %rdx
addq %rdx, %rax
movq %rcx, 0x18(%rax)
leaq 0x143a8d(%rip), %rdi    # 0x176f00
xorl %eax, %eax
movl %eax, %esi
callq 0x2d330
movq %rax, %rcx
movq 0x144d7a(%rip), %rax    # 0x178200
movslq -0x4(%rbp), %rdx
shlq $0x6, %rdx
addq %rdx, %rax
movq %rcx, 0x20(%rax)
callq 0x338d0
movq %rax, %rcx
movq 0x144d5c(%rip), %rax    # 0x178200
movslq -0x4(%rbp), %rdx
shlq $0x6, %rdx
addq %rdx, %rax
movq %rcx, 0x28(%rax)
movl -0x4(%rbp), %ecx
movq 0x144d43(%rip), %rax    # 0x178200
movslq -0x4(%rbp), %rdx
shlq $0x6, %rdx
addq %rdx, %rax
movl %ecx, 0x30(%rax)
movq 0x144d2e(%rip), %rax    # 0x178200
movslq -0x4(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq $0x0, 0x38(%rax)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x333ba
leaq 0x143a06(%rip), %rdi    # 0x176f00
xorl %eax, %eax
movl %eax, %esi
callq 0x2d330
movq %rax, 0x145656(%rip)    # 0x178b60
callq 0x26e20
movq %rax, 0x145652(%rip)    # 0x178b68
movq 0x14564b(%rip), %rax    # 0x178b68
leaq 0x412ac(%rip), %rcx     # 0x747d0
movq %rcx, 0x18(%rax)
movq 0x145639(%rip), %rax    # 0x178b68
leaq 0x412ca(%rip), %rcx     # 0x74800
movq %rcx, 0x20(%rax)
movl $0x0, 0x144d00(%rip)    # 0x178244
movl $0xffffffff, 0x1453ba(%rip) # imm = 0xFFFFFFFF
movl $0xffffffff, 0x14531c(%rip) # imm = 0xFFFFFFFF
movl $0x0, 0x1453f2(%rip)    # 0x178954
movl $0x0, 0x1453e4(%rip)    # 0x178950
callq 0x705a0
callq 0x384f0
movq %rax, 0x145303(%rip)    # 0x178880
xorl %eax, %eax
movl %eax, %edi
callq 0x26ce0
movq %rax, 0x1453a3(%rip)    # 0x178930
movq $0x0, 0x1453a0(%rip) # 0x178938
movq $-0x1, 0x14539d(%rip) # 0x178940
movq $-0x1, 0x14539a(%rip) # 0x178948
movq $0x0, 0x14533f(%rip) # 0x1788f8
callq 0x33030
xorl %eax, %eax
movl %eax, %edi
callq 0x26ce0
movq %rax, 0x144f92(%rip)    # 0x178560
movq $0x0, 0x144fbf(%rip) # 0x178598
movq $0x0, 0x14500c(%rip) # 0x1785f0
movl $0x0, 0x14536a(%rip)    # 0x178958
movl $0x0, 0x1452cc(%rip)    # 0x1788c4
movl $0x0, 0x1452c6(%rip)    # 0x1788c8
movl $0x0, 0x1453dc(%rip)    # 0x1789e8
callq 0x310e0
movq 0x144c00(%rip), %rdi    # 0x178218
movl $0x1, %esi
leaq -0x2514(%rip), %rdx     # 0x31110
xorl %eax, %eax
movl %eax, %r8d
movq %r8, %rcx
callq 0x2ac90
cmpq $-0x1, %rax
jne 0x33659
leaq 0x104e10(%rip), %rdi    # 0x13844e
leaq 0x104e33(%rip), %rsi    # 0x138478
movl $0x7b0, %edx            # imm = 0x7B0
callq 0x76d80
movl $0x1, %edi
callq 0x263c0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
cmpl 0x144ceb(%rip), %eax    # 0x178354
jge 0x336ce
movq 0x144ba6(%rip), %rdi    # 0x178218
movslq -0x4(%rbp), %rcx
leaq 0x144b5b(%rip), %rax    # 0x1781d8
movl 0x13c(%rax,%rcx,4), %esi
movl $0x1, %edx
leaq 0x10430(%rip), %rcx     # 0x43ac0
xorl %eax, %eax
movl %eax, %r8d
callq 0x2a8f0
cmpl $-0x1, %eax
jne 0x336c1
leaq 0x104ddb(%rip), %rdi    # 0x138481
leaq 0x104dcb(%rip), %rsi    # 0x138478
movl $0x7bb, %edx            # imm = 0x7BB
callq 0x76d80
movl $0x1, %edi
callq 0x263c0
jmp 0x336c3
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x33660
cmpl $0x0, 0x144c83(%rip)    # 0x178358
jle 0x33721
movq 0x144b3a(%rip), %rdi    # 0x178218
movl 0x144c74(%rip), %esi    # 0x178358
movl $0x1, %edx
leaq 0x106a0(%rip), %rcx     # 0x43d90
xorl %eax, %eax
movl %eax, %r8d
callq 0x2a8f0
cmpl $-0x1, %eax
jne 0x33721
leaq 0x104db2(%rip), %rdi    # 0x1384b8
leaq 0x104d6b(%rip), %rsi    # 0x138478
movl $0x7bf, %edx            # imm = 0x7BF
callq 0x76d80
movl $0x1, %edi
callq 0x263c0
cmpl $0x1, 0x145118(%rip)    # 0x178840
jne 0x3377f
movq 0x145117(%rip), %rdi    # 0x178848
movl $0x441, %esi            # imm = 0x441
movl $0x1a4, %edx            # imm = 0x1A4
movb $0x0, %al
callq 0x266a0
movl %eax, 0x145140(%rip)    # 0x178888
cmpl $-0x1, 0x145139(%rip)   # 0x178888
jne 0x3377d
callq 0x26880
movl (%rax), %edi
callq 0x26690
movq %rax, %rdx
movl $0x3, %edi
leaq 0x104d83(%rip), %rsi    # 0x1384ef
movb $0x0, %al
callq 0x2fc60
movl $0x1, %edi
callq 0x262d0
jmp 0x3377f
cmpl $0x20, 0x144aba(%rip)   # 0x178240
jne 0x337bb
cmpq $0x0, 0x145350(%rip)    # 0x178ae0
jne 0x337bb
movl $0x3, %edi
leaq 0x104d75(%rip), %rsi    # 0x138513
movb $0x0, %al
callq 0x2fc60
movl $0xc0000000, %eax       # imm = 0xC0000000
movq %rax, 0x14532f(%rip)    # 0x178ae0
movl $0x5, 0x14532d(%rip)    # 0x178ae8
cmpl $0x0, 0x1453b2(%rip)    # 0x178b74
je 0x337c9
callq 0x7d120
callq 0x51f10
movl $0x1, %edi
callq 0x8a1e0
callq 0x87bb0
callq 0xa11e0
callq 0x8e0b0
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)