// File: /workspace/github_c_makefile_star2_O0/erikdubbelboer[P]discnt/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;

            /* Calculate the time missing for the nearest
             * timer to fire. */
            aeGetTime(&now_sec, &now_ms);
            tvp = &tv;
            tvp->tv_sec = shortest->when_sec - now_sec;
            if (shortest->when_ms < now_ms) {
                tvp->tv_usec = ((shortest->when_ms+1000) - now_ms)*1000;
                tvp->tv_sec --;
            } else {
                tvp->tv_usec = (shortest->when_ms - now_ms)*1000;
            }
            if (tvp->tv_sec < 0) tvp->tv_sec = 0;
            if (tvp->tv_usec < 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 0x13df8
movl -0x14(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x13df8
movl $0x0, -0x4(%rbp)
jmp 0x1405a
movq -0x10(%rbp), %rax
cmpl $-0x1, (%rax)
jne 0x13e1f
movl -0x14(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x1403a
movl -0x14(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x1403a
movq $0x0, -0x28(%rbp)
movl -0x14(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x13e4a
movl -0x14(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x13e4a
movq -0x10(%rbp), %rdi
callq 0x14070
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x13f05
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x140f0
leaq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rcx
subq -0x48(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
cmpq -0x50(%rbp), %rax
jge 0x13ebc
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
addq $0x3e8, %rax            # imm = 0x3E8
subq -0x50(%rbp), %rax
imulq $0x3e8, %rax, %rcx      # imm = 0x3E8
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rax
movq (%rax), %rcx
addq $-0x1, %rcx
movq %rcx, (%rax)
jmp 0x13ed7
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
subq -0x50(%rbp), %rax
imulq $0x3e8, %rax, %rcx      # imm = 0x3E8
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rax
cmpq $0x0, (%rax)
jge 0x13eec
movq -0x40(%rbp), %rax
movq $0x0, (%rax)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jge 0x13f03
movq -0x40(%rbp), %rax
movq $0x0, 0x8(%rax)
jmp 0x13f34
movl -0x14(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x13f2a
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
leaq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x13f32
movq $0x0, -0x40(%rbp)
jmp 0x13f34
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x14140
movl %eax, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x14038
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, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x20(%rbp), %rcx
movl 0x4(%rax,%rcx,8), %eax
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x20(%rbp), %rcx
movl (%rax,%rcx,8), %eax
movl %eax, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
movq -0x58(%rbp), %rax
movl (%rax), %eax
andl -0x5c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x13fda
movl $0x1, -0x64(%rbp)
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rdi
movl -0x60(%rbp), %esi
movq -0x58(%rbp), %rcx
movq 0x18(%rcx), %rdx
movl -0x5c(%rbp), %ecx
callq *%rax
movq -0x58(%rbp), %rax
movl (%rax), %eax
andl -0x5c(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x14021
cmpl $0x0, -0x64(%rbp)
je 0x14003
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x58(%rbp), %rcx
cmpq 0x8(%rcx), %rax
je 0x1401f
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rdi
movl -0x60(%rbp), %esi
movq -0x58(%rbp), %rcx
movq 0x18(%rcx), %rdx
movl -0x5c(%rbp), %ecx
callq *%rax
jmp 0x14021
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x13f4b
jmp 0x1403a
movl -0x14(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x14054
movq -0x10(%rbp), %rdi
callq 0x142c0
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)