// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/ae.c
// Function: aeProcessEvents
int aeProcessEvents(aeEventLoop *eventLoop, int flags)
{
    int processed = 0, numevents;

    /* Nothing to do? return ASAP */
    if (!(flags & AE_TIME_EVENTS) && !(flags & AE_FILE_EVENTS)) return 0;

    /* Note that we want call select() even if there are no
     * file events to process as long as we want to process time
     * events, in order to sleep until the next time event is ready
     * to fire. */
    if (eventLoop->maxfd != -1 ||
        ((flags & AE_TIME_EVENTS) && !(flags & AE_DONT_WAIT))) {
        int j;
        aeTimeEvent *shortest = NULL;
        struct timeval tv, *tvp;

        if (flags & AE_TIME_EVENTS && !(flags & AE_DONT_WAIT))
            shortest = aeSearchNearestTimer(eventLoop);
        if (shortest) {
            long now_sec, now_ms;

            aeGetTime(&now_sec, &now_ms);
            tvp = &tv;

            /* How many milliseconds we need to wait for the next
             * time event to fire? */
            long long ms =
                (shortest->when_sec - now_sec)*1000 +
                shortest->when_ms - now_ms;

            if (ms > 0) {
                tvp->tv_sec = ms/1000;
                tvp->tv_usec = (ms % 1000)*1000;
            } else {
                tvp->tv_sec = 0;
                tvp->tv_usec = 0;
            }
        } else {
            /* If we have to check for events but need to return
             * ASAP because of AE_DONT_WAIT we need to set the timeout
             * to zero */
            if (flags & AE_DONT_WAIT) {
                tv.tv_sec = tv.tv_usec = 0;
                tvp = &tv;
            } else {
                /* Otherwise we can block */
                tvp = NULL; /* wait forever */
            }
        }

        numevents = aeApiPoll(eventLoop, tvp);
        for (j = 0; j < numevents; j++) {
            aeFileEvent *fe = &eventLoop->events[eventLoop->fired[j].fd];
            int mask = eventLoop->fired[j].mask;
            int fd = eventLoop->fired[j].fd;
            int rfired = 0;

	    /* note the fe->mask & mask & ... code: maybe an already processed
             * event removed an element that fired and we still didn't
             * processed, so we check if the event is still valid. */
            if (fe->mask & mask & AE_READABLE) {
                rfired = 1;
                fe->rfileProc(eventLoop,fd,fe->clientData,mask);
            }
            if (fe->mask & mask & AE_WRITABLE) {
                if (!rfired || fe->wfileProc != fe->rfileProc)
                    fe->wfileProc(eventLoop,fd,fe->clientData,mask);
            }
            processed++;
        }
    }
    /* Check time events */
    if (flags & AE_TIME_EVENTS)
        processed += processTimeEvents(eventLoop);

    return processed; /* return the number of processed file/time events */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x14(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x1a9f8
movl -0x14(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x1a9f8
movl $0x0, -0x4(%rbp)
jmp 0x1ac39
movq -0x10(%rbp), %rax
cmpl $-0x1, (%rax)
jne 0x1aa1f
movl -0x14(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x1ac19
movl -0x14(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x1ac19
movq $0x0, -0x28(%rbp)
movl -0x14(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x1aa4a
movl -0x14(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x1aa4a
movq -0x10(%rbp), %rdi
callq 0x1ac50
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x1aae4
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x1acd0
leaq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
subq -0x48(%rbp), %rax
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
movq -0x28(%rbp), %rcx
addq 0x10(%rcx), %rax
subq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jle 0x1aacb
movq -0x58(%rbp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x58(%rbp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
imulq $0x3e8, %rdx, %rcx      # imm = 0x3E8
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x1aae2
movq -0x40(%rbp), %rax
movq $0x0, (%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0x8(%rax)
jmp 0x1ab13
movl -0x14(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x1ab09
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
leaq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x1ab11
movq $0x0, -0x40(%rbp)
jmp 0x1ab13
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x1ad20
movl %eax, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x1ac17
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x20(%rcx), %rcx
movslq -0x20(%rbp), %rdx
movslq (%rcx,%rdx,8), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x20(%rbp), %rcx
movl 0x4(%rax,%rcx,8), %eax
movl %eax, -0x64(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x20(%rbp), %rcx
movl (%rax,%rcx,8), %eax
movl %eax, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
movq -0x60(%rbp), %rax
movl (%rax), %eax
andl -0x64(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1abb9
movl $0x1, -0x6c(%rbp)
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rdi
movl -0x68(%rbp), %esi
movq -0x60(%rbp), %rcx
movq 0x18(%rcx), %rdx
movl -0x64(%rbp), %ecx
callq *%rax
movq -0x60(%rbp), %rax
movl (%rax), %eax
andl -0x64(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x1ac00
cmpl $0x0, -0x6c(%rbp)
je 0x1abe2
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x60(%rbp), %rcx
cmpq 0x8(%rcx), %rax
je 0x1abfe
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rdi
movl -0x68(%rbp), %esi
movq -0x60(%rbp), %rcx
movq 0x18(%rcx), %rdx
movl -0x64(%rbp), %ecx
callq *%rax
jmp 0x1ac00
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1ab2a
jmp 0x1ac19
movl -0x14(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x1ac33
movq -0x10(%rbp), %rdi
callq 0x1aea0
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)