// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/liball/../libcperciva/events/events_network.c
// Function: events_network_get
struct eventrec *
events_network_get(void)
{
	struct eventrec * r;

	/* We haven't found any events yet. */
	r = NULL;

	/* Scan through the pollfds looking for ready descriptors. */
	for (; fdscanpos < nfds; fdscanpos--) {
		/* Did we poll on an invalid descriptor? */
		assert((fds[fdscanpos].revents & POLLNVAL) == 0);

		/*
		 * If either POLLERR ("an exceptional condition") or POLLHUP
		 * ("has been disconnected") is set, then we should invoke
		 * whatever callbacks we have available.
		 */
		if (fds[fdscanpos].revents & (POLLERR | POLLHUP)) {
			fds[fdscanpos].revents &= ~(POLLERR | POLLHUP);
			fds[fdscanpos].revents |= fds[fdscanpos].events;
		}

		/* Are we ready for reading? */
		if (fds[fdscanpos].revents & POLLIN) {
			r = socketlist_get(S,
			    (size_t)fds[fdscanpos].fd)->reader;
			socketlist_get(S,
			    (size_t)fds[fdscanpos].fd)->reader = NULL;
			clearbit(fdscanpos, POLLIN);
			break;
		}

		/* Are we ready for writing? */
		if (fds[fdscanpos].revents & POLLOUT) {
			r = socketlist_get(S,
			    (size_t)fds[fdscanpos].fd)->writer;
			socketlist_get(S,
			    (size_t)fds[fdscanpos].fd)->writer = NULL;
			clearbit(fdscanpos, POLLOUT);
			break;
		}
	}

	/* If we're returning the last registered event, stop the clock. */
	if ((r != NULL) && (nfds == 0))
		events_network_selectstats_stopclock();

	/* Return the event we found, or NULL if we didn't find any. */
	return (r);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq $0x0, -0x8(%rbp)
movq 0x1a861(%rip), %rax     # 0x1e4e8
cmpq 0x1a84a(%rip), %rax     # 0x1e4d8
jae 0x3e41
movq 0x1a845(%rip), %rax     # 0x1e4e0
movq 0x1a846(%rip), %rcx     # 0x1e4e8
movswl 0x6(%rax,%rcx,8), %eax
andl $0x20, %eax
cmpl $0x0, %eax
jne 0x3cb1
jmp 0x3cd0
leaq 0x653f(%rip), %rdi      # 0xa1f7
leaq 0x6561(%rip), %rsi      # 0xa220
movl $0x1b0, %edx            # imm = 0x1B0
leaq 0x657c(%rip), %rcx      # 0xa247
callq 0x2180
movq 0x1a809(%rip), %rax     # 0x1e4e0
movq 0x1a80a(%rip), %rcx     # 0x1e4e8
movswl 0x6(%rax,%rcx,8), %eax
andl $0x18, %eax
cmpl $0x0, %eax
je 0x3d33
movq 0x1a7ee(%rip), %rax     # 0x1e4e0
movq 0x1a7ef(%rip), %rcx     # 0x1e4e8
movswl 0x6(%rax,%rcx,8), %edx
andl $-0x19, %edx
movw %dx, 0x6(%rax,%rcx,8)
movq 0x1a7d3(%rip), %rax     # 0x1e4e0
movq 0x1a7d4(%rip), %rcx     # 0x1e4e8
movswl 0x4(%rax,%rcx,8), %esi
movq 0x1a7c0(%rip), %rax     # 0x1e4e0
movq 0x1a7c1(%rip), %rcx     # 0x1e4e8
movswl 0x6(%rax,%rcx,8), %edx
orl %esi, %edx
movw %dx, 0x6(%rax,%rcx,8)
movq 0x1a7a6(%rip), %rax     # 0x1e4e0
movq 0x1a7a7(%rip), %rcx     # 0x1e4e8
movswl 0x6(%rax,%rcx,8), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x3dae
movq 0x1a77b(%rip), %rdi     # 0x1e4d0
movq 0x1a784(%rip), %rax     # 0x1e4e0
movq 0x1a785(%rip), %rcx     # 0x1e4e8
movslq (%rax,%rcx,8), %rsi
callq 0x36b0
movq (%rax), %rax
movq %rax, -0x8(%rbp)
movq 0x1a756(%rip), %rdi     # 0x1e4d0
movq 0x1a75f(%rip), %rax     # 0x1e4e0
movq 0x1a760(%rip), %rcx     # 0x1e4e8
movslq (%rax,%rcx,8), %rsi
callq 0x36b0
movq $0x0, (%rax)
movq 0x1a749(%rip), %rdi     # 0x1e4e8
movl $0x1, %esi
callq 0x3a30
jmp 0x3e41
movq 0x1a72b(%rip), %rax     # 0x1e4e0
movq 0x1a72c(%rip), %rcx     # 0x1e4e8
movswl 0x6(%rax,%rcx,8), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x3e28
movq 0x1a700(%rip), %rdi     # 0x1e4d0
movq 0x1a709(%rip), %rax     # 0x1e4e0
movq 0x1a70a(%rip), %rcx     # 0x1e4e8
movslq (%rax,%rcx,8), %rsi
callq 0x36b0
movq 0x8(%rax), %rax
movq %rax, -0x8(%rbp)
movq 0x1a6da(%rip), %rdi     # 0x1e4d0
movq 0x1a6e3(%rip), %rax     # 0x1e4e0
movq 0x1a6e4(%rip), %rcx     # 0x1e4e8
movslq (%rax,%rcx,8), %rsi
callq 0x36b0
movq $0x0, 0x8(%rax)
movq 0x1a6cc(%rip), %rdi     # 0x1e4e8
movl $0x4, %esi
callq 0x3a30
jmp 0x3e41
jmp 0x3e2a
movq 0x1a6b7(%rip), %rax     # 0x1e4e8
addq $-0x1, %rax
movq %rax, 0x1a6ac(%rip)     # 0x1e4e8
jmp 0x3c80
cmpq $0x0, -0x8(%rbp)
je 0x3e57
cmpq $0x0, 0x1a688(%rip)     # 0x1e4d8
jne 0x3e57
callq 0x3f80
movq -0x8(%rbp), %rax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)