// File: /workspace/github_c_makefile_star2_O1/erikdubbelboer[P]discnt/src/server.c
// Function: serverCron
int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
    UNUSED(eventLoop);
    UNUSED(id);
    UNUSED(clientData);
    int j;

    /* Software watchdog: deliver the SIGALRM that will reach the signal
     * handler if we don't return here fast enough. */
    if (server.watchdog_period) watchdogScheduleSignal(server.watchdog_period);

    /* Update the time cache. */
    updateCachedTime();

    run_with_period(100) {
        trackInstantaneousMetric(STAT_METRIC_COMMAND,server.stat_numcommands);
        trackInstantaneousMetric(STAT_METRIC_NET_INPUT,
                server.stat_net_input_bytes);
        trackInstantaneousMetric(STAT_METRIC_NET_OUTPUT,
                server.stat_net_output_bytes);
    }

    /* Record the max memory used since the server was started. */
    if (zmalloc_used_memory() > server.stat_peak_memory)
        server.stat_peak_memory = zmalloc_used_memory();

    /* Sample the RSS here since this is a relatively slow call. */
    server.resident_set_size = zmalloc_get_rss();

    /* We received a SIGTERM, shutting down here in a safe way, as it is
     * not ok doing so inside the signal handler. */
    if (server.shutdown_asap) {
        if (prepareForShutdown(SHUTDOWN_NOFLAGS) == C_OK) exit(0);
        serverLog(LL_WARNING,"SIGTERM received but errors trying to shut down the server, check the logs for more information");
        server.shutdown_asap = 0;
    }

    /* Show information, */
    run_with_period(5000) {
        serverLog(LL_VERBOSE,
            "%lu clients connected, %zu bytes in use",
            listLength(server.clients),
            zmalloc_used_memory());

        serverLog(LL_VERBOSE,"DB: %lu keys in %lu slots HT.",dictSize(server.counters),dictSlots(server.counters));
    }

    /* We need to do a few operations on clients asynchronously. */
    clientsCron();

    /* Handle background operations on Discnt. */
    databasesCron();

    run_with_period(1000) {
        countersCron();
    }

    run_with_period(1000) {
        countersCleanupCron();
    }

    /* Check if a background saving in progress terminated. */
    if (server.ddb_child_pid != -1) {
        int statloc;
        pid_t pid;

        if ((pid = wait3(&statloc,WNOHANG,NULL)) != 0) {
            int exitcode = WEXITSTATUS(statloc);
            int bysignal = 0;

            if (WIFSIGNALED(statloc)) bysignal = WTERMSIG(statloc);

            if (pid == -1) {
                serverLog(LL_WARNING,"wait3() returned an error: %s. "
                    "ddb_child_pid = %d",
                    strerror(errno),
                    (int) server.ddb_child_pid);
            } else if (pid == server.ddb_child_pid) {
                backgroundSaveDoneHandler(exitcode,bysignal);
            } else {
                serverLog(LL_WARNING,
                    "Warning, detected child with unmatched pid: %ld",
                    (long)pid);
            }
            updateDictResizePolicy();
        }
    } else {
        /* If there is not a background saving/rewrite in progress check if
         * we have to save/rewrite now */
         for (j = 0; j < server.saveparamslen; j++) {
            struct saveparam *sp = server.saveparams+j;

            /* Save if we reached the given amount of changes,
             * the given amount of seconds, and if the latest bgsave was
             * successful or if, in case of an error, at least
             * CONFIG_BGSAVE_RETRY_DELAY seconds already elapsed. */
            if (server.dirty >= sp->changes &&
                server.unixtime-server.lastsave > sp->seconds &&
                (server.unixtime-server.lastbgsave_try >
                 CONFIG_BGSAVE_RETRY_DELAY ||
                 server.lastbgsave_status == C_OK))
            {
                serverLog(LL_NOTICE,"%lld changes in %d seconds. Saving...",
                    server.dirty, (int)sp->seconds);
                ddbSaveBackground(server.ddb_filename);
                break;
            }
        }
    }

    /* Close clients that need to be closed asynchronous */
    freeClientsInAsyncFreeQueue();

    /* Clear the paused clients flag if needed. */
    clientsArePaused(); /* Don't check return value, just use the side effect.*/

    /* Run the Discnt Cluster cron. */
    run_with_period(100) {
        clusterCron();
    }

    server.cronloops++;
    return 1000/server.hz;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movl 0x54d25(%rip), %edi     # 0x6f720
testl %edi, %edi
je 0x1aa04
callq 0x2b74c
callq 0x1a99d
movl $0x3e8, %eax            # imm = 0x3E8
xorl %edx, %edx
idivl 0x54692(%rip)           # 0x6f0a8
cmpl $0x63, %eax
jg 0x1aa37
movl %eax, %ecx
movl 0x546c1(%rip), %esi     # 0x6f0e4
movl $0x64, %eax
xorl %edx, %edx
idivl %ecx
movl %eax, %ecx
movl %esi, %eax
cltd
idivl %ecx
testl %edx, %edx
jne 0x1aa67
movq 0x549c2(%rip), %rsi     # 0x6f400
xorl %edi, %edi
callq 0x1a654
movq 0x549ec(%rip), %rsi     # 0x6f438
movl $0x1, %edi
callq 0x1a654
movq 0x549e3(%rip), %rsi     # 0x6f440
movl $0x2, %edi
callq 0x1a654
callq 0x2006e
cmpq 0x5499d(%rip), %rax     # 0x6f410
jbe 0x1aa81
callq 0x2006e
movq %rax, 0x5498f(%rip)     # 0x6f410
callq 0x2008d
movq %rax, 0x549a3(%rip)     # 0x6f430
cmpl $0x0, 0x54634(%rip)     # 0x6f0c8
je 0x1aac2
xorl %edi, %edi
callq 0x1c570
testl %eax, %eax
je 0x1ad5e
leaq 0x37ac5(%rip), %rsi     # 0x52571
movl $0x3, %edi
xorl %eax, %eax
callq 0x19fb1
movl $0x0, 0x54606(%rip)     # 0x6f0c8
movl $0x3e8, %eax            # imm = 0x3E8
xorl %edx, %edx
idivl 0x545d9(%rip)           # 0x6f0a8
movl %eax, %ecx
movl 0x5460d(%rip), %esi     # 0x6f0e4
movl $0x1388, %eax           # imm = 0x1388
xorl %edx, %edx
idivl %ecx
movl %eax, %ecx
movl %esi, %eax
cltd
idivl %ecx
testl %edx, %edx
jne 0x1ab3e
movq 0x54776(%rip), %rax     # 0x6f268
movq 0x28(%rax), %rbx
callq 0x2006e
leaq 0x37acf(%rip), %rsi     # 0x525d1
movl $0x1, %edi
movq %rbx, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x19fb1
movq 0x54b85(%rip), %rax     # 0x6f6a0
movq 0x38(%rax), %rcx
movq 0x48(%rax), %rdx
addq 0x28(%rax), %rdx
addq 0x18(%rax), %rcx
leaq 0x37ac7(%rip), %rsi     # 0x525f9
movl $0x1, %edi
xorl %eax, %eax
callq 0x19fb1
callq 0x1a8f2
callq 0x1a970
movl $0x3e8, %eax            # imm = 0x3E8
xorl %edx, %edx
idivl 0x54553(%rip)           # 0x6f0a8
cmpl $0x3e7, %eax            # imm = 0x3E7
jg 0x1ab78
movl %eax, %ecx
movl 0x54580(%rip), %esi     # 0x6f0e4
movl $0x3e8, %eax            # imm = 0x3E8
xorl %edx, %edx
idivl %ecx
movl %eax, %ecx
movl %esi, %eax
cltd
idivl %ecx
testl %edx, %edx
jne 0x1ab7d
callq 0x321e1
movl $0x3e8, %eax            # imm = 0x3E8
xorl %edx, %edx
idivl 0x5451e(%rip)           # 0x6f0a8
cmpl $0x3e7, %eax            # imm = 0x3E7
jg 0x1abad
movl %eax, %ecx
movl 0x5454b(%rip), %esi     # 0x6f0e4
movl $0x3e8, %eax            # imm = 0x3E8
xorl %edx, %edx
idivl %ecx
movl %eax, %ecx
movl %esi, %eax
cltd
idivl %ecx
testl %edx, %edx
jne 0x1abb2
callq 0x323f3
cmpl $-0x1, 0x54b7f(%rip)    # 0x6f738
je 0x1ac17
xorl %ebx, %ebx
leaq 0xc(%rsp), %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0x12230
testl %eax, %eax
je 0x1ad08
movl 0xc(%rsp), %ecx
movl %ecx, %edx
andl $0x7f, %edx
movl %edx, %esi
shll $0x18, %esi
addl $0x1000000, %esi        # imm = 0x1000000
cmpl $0x2000000, %esi        # imm = 0x2000000
cmovgel %edx, %ebx
cmpl $-0x1, %eax
je 0x1ac92
cmpl 0x54b36(%rip), %eax     # 0x6f738
jne 0x1acbc
movzbl %ch, %edi
movl %ebx, %esi
callq 0x33a97
jmp 0x1acd2
movslq 0x54b2a(%rip), %rax     # 0x6f748
testq %rax, %rax
jle 0x1ad08
movq 0x54b12(%rip), %rsi     # 0x6f740
movq 0x54af3(%rip), %rdx     # 0x6f728
movq 0x54a94(%rip), %rcx     # 0x6f6d0
movq %rcx, %rdi
subq 0x54b1a(%rip), %rdi     # 0x6f760
subq 0x54b1b(%rip), %rcx     # 0x6f768
cmpq $0x6, %rcx
setl %cl
cmpl $0x0, 0x54b29(%rip)     # 0x6f784
setne %r8b
andb %cl, %r8b
shlq $0x4, %rax
xorl %r9d, %r9d
movslq 0x8(%rsi,%r9), %rcx
cmpq %rcx, %rdx
jl 0x1ac87
movq (%rsi,%r9), %rcx
cmpq %rcx, %rdi
setle %r10b
orb %r8b, %r10b
testb $0x1, %r10b
je 0x1ace9
addq $0x10, %r9
cmpq %r9, %rax
jne 0x1ac69
jmp 0x1ad08
callq 0x120d0
movl (%rax), %edi
callq 0x128f0
movl 0x54a94(%rip), %ecx     # 0x6f738
leaq 0x3796c(%rip), %rsi     # 0x52617
movl $0x3, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x19fb1
jmp 0x1acd2
movslq %eax, %rdx
leaq 0x37983(%rip), %rsi     # 0x52649
movl $0x3, %edi
xorl %eax, %eax
callq 0x19fb1
cmpl $-0x1, 0x54a5f(%rip)    # 0x6f738
je 0x1ace2
callq 0x197f4
jmp 0x1ad08
callq 0x197ec
jmp 0x1ad08
leaq 0x37989(%rip), %rsi     # 0x52679
movl $0x2, %edi
xorl %eax, %eax
callq 0x19fb1
movq 0x54a4d(%rip), %rdi     # 0x6f750
callq 0x331b8
callq 0x230aa
callq 0x23d83
movl $0x3e8, %eax            # imm = 0x3E8
xorl %edx, %edx
idivl 0x54389(%rip)           # 0x6f0a8
cmpl $0x63, %eax
jg 0x1ad40
movl %eax, %ecx
movl 0x543b8(%rip), %esi     # 0x6f0e4
movl $0x64, %eax
xorl %edx, %edx
idivl %ecx
movl %eax, %ecx
movl %esi, %eax
cltd
idivl %ecx
testl %edx, %edx
jne 0x1ad45
callq 0x2e04b
incl 0x54399(%rip)           # 0x6f0e4
movl $0x3e8, %eax            # imm = 0x3E8
xorl %edx, %edx
idivl 0x54350(%rip)           # 0x6f0a8
addq $0x10, %rsp
popq %rbx
retq
xorl %edi, %edi
callq 0x12870