// File: /workspace/github_c_makefile_star2_O0/wahern[P]cqueues/src/cqueues.c
// Function: cqueue_process
static cqs_status_t cqueue_process(lua_State *L, struct cqueue *Q, struct callinfo *I) {
	int onalert = 0;
	kpoll_event_t *ke;
	struct fileno *fileno;
	struct event *event;
	struct thread *T;
	struct timer *timer;
	double curtime;
	short events;
	int status;

	KPOLL_FOREACH(ke, &Q->kp) {
		if (kpoll_isalert(&Q->kp, ke)) {
			onalert = 1;

			continue;
		}

		fileno = kpoll_udata(ke);
		events = kpoll_pending(ke);

		fileno_signal(Q, fileno, events);
		fileno->state = kpoll_diff(ke, fileno->state);
	}

	curtime = monotime();

	LLRB_FOREACH(timer, timers, &Q->timers) {
		if (isgreater(timer->timeout, curtime))
			break;

		T = timer2thread(timer);

		TAILQ_FOREACH(event, &T->events, tqe) {
			if (islessequal(event->timeout, curtime))
				event->pending = 1;
		}

		thread_move(T, &Q->thread.pending);
	}

	assert(NULL == Q->thread.current);
	Q->thread.current = LIST_FIRST(&Q->thread.pending);
	if (LUA_OK != (status = cqueue_process_threads(L, Q, I))) {
		return status;
	}

	if (onalert) {
		kpoll_calm(&Q->kp);
	}

	return LUA_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x18(%rbp), %rcx
addq $0x8, %rcx
movq -0x18(%rbp), %rdx
imulq $0xc, 0x188(%rdx), %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0x1341b
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x13c00
cmpw $0x0, %ax
je 0x133c3
movl $0x1, -0x24(%rbp)
jmp 0x1340a
movq -0x30(%rbp), %rdi
callq 0x13c40
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0x13c60
movw %ax, -0x5a(%rbp)
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rsi
movswl -0x5a(%rbp), %edx
callq 0x11e60
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rax
movswl 0x4(%rax), %esi
callq 0x13c70
movw %ax, %cx
movq -0x38(%rbp), %rax
movw %cx, 0x4(%rax)
movq -0x30(%rbp), %rax
addq $0xc, %rax
movq %rax, -0x30(%rbp)
jmp 0x13387
callq 0x13a00
movsd %xmm0, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq 0x228(%rax), %rdi
callq 0x139c0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x134ca
movq -0x50(%rbp), %rax
movsd (%rax), %xmm0
ucomisd -0x58(%rbp), %xmm0
jbe 0x13455
jmp 0x134ca
movq -0x50(%rbp), %rax
addq $-0x40, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x134a0
movq -0x40(%rbp), %rax
movsd 0x8(%rax), %xmm1
movsd -0x58(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x13490
movq -0x40(%rbp), %rax
movb $0x1, 0x10(%rax)
jmp 0x13492
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x1346d
movq -0x48(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x208, %rsi            # imm = 0x208
addq $0x8, %rsi
callq 0x120f0
movq -0x50(%rbp), %rdi
callq 0x13c90
movq %rax, -0x50(%rbp)
jmp 0x13439
movq -0x18(%rbp), %rcx
xorl %eax, %eax
cmpq 0x218(%rcx), %rax
jne 0x134db
jmp 0x134fa
leaq 0x34d72(%rip), %rdi     # 0x48254
leaq 0x34d85(%rip), %rsi     # 0x4826e
movl $0x886, %edx            # imm = 0x886
leaq 0x34dbe(%rip), %rcx     # 0x482b3
callq 0xf920
movq -0x18(%rbp), %rax
movq 0x210(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x218(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x13d50
movl %eax, %ecx
movl %ecx, -0x60(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
je 0x13534
movl -0x60(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1354a
cmpl $0x0, -0x24(%rbp)
je 0x13543
movq -0x18(%rbp), %rdi
callq 0x13de0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)