// File: dak98[P]SocketIO/src/epoll.cpp
// Function: socket_io::epoll::get_event() const
auto epoll::get_event() const -> event
{
    epoll_event events[1];
    int error_code = epoll_wait(handle, events, 1, -1);
    if (error_code == -1 && errno == EINTR)
	throw std::system_error{std::make_error_code(std::errc::interrupted)};
    if (error_code == -1)
	throw std::runtime_error{"An error occured while acquiring an event: " +
		                 get_errno_as_string()};

    auto it = std::find_if(std::begin(monitored_sockets),
			   std::end(monitored_sockets),
			   [=](socket_view const& view)
			   { return view.get_native_handle() ==
			            events[0].data.fd; });
    return {events[0].events, *it};
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xd0(%rbp)
movl (%rax), %edi
leaq -0x24(%rbp), %rsi
movl $0x1, %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x1ea50
movl %eax, -0x28(%rbp)
cmpl $-0x1, -0x28(%rbp)
jne 0x2e517
callq 0x1e0e0
cmpl $0x4, (%rax)
jne 0x2e517
movl $0x20, %edi
callq 0x1ea70
movq %rax, -0xd8(%rbp)
movq %rax, -0xe0(%rbp)
movl $0x4, %edi
callq 0x1e970
movq -0xd8(%rbp), %rdi
movl %eax, -0x38(%rbp)
movq %rdx, -0x30(%rbp)
movl -0x38(%rbp), %esi
movq -0x30(%rbp), %rdx
callq 0x1eee0
jmp 0x2e4e0
movq -0xe0(%rbp), %rdi
movq 0xca1a(%rip), %rsi      # 0x3af08
movq 0xca3b(%rip), %rdx      # 0x3af30
callq 0x20690
movq -0xe0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
callq 0x1efc0
jmp 0x2e6e6
cmpl $-0x1, -0x28(%rbp)
jne 0x2e5f1
movb $0x1, -0x89(%rbp)
movl $0x10, %edi
callq 0x1ea70
movq %rax, -0xe8(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x1f040
jmp 0x2e547
leaq 0x3542(%rip), %rsi      # 0x31a90
leaq -0x68(%rbp), %rdi
leaq -0x88(%rbp), %rdx
callq 0x20610
jmp 0x2e560
movq -0xe8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x204c0
jmp 0x2e572
movq -0xe8(%rbp), %rdi
movb $0x0, -0x89(%rbp)
movq 0xca69(%rip), %rsi      # 0x3aff0
movq 0xc99a(%rip), %rdx      # 0x3af28
callq 0x20690
jmp 0x2e6ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2e5d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2e5c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x1ed60
leaq -0x88(%rbp), %rdi
callq 0x1ed60
testb $0x1, -0x89(%rbp)
jne 0x2e5e0
jmp 0x2e5ec
movq -0xe8(%rbp), %rdi
callq 0x1efc0
jmp 0x2e6e6
movq -0xd0(%rbp), %rdi
addq $0x8, %rdi
callq 0x1e700
movq -0xd0(%rbp), %rdi
movq %rax, -0xa0(%rbp)
addq $0x8, %rdi
callq 0x1e560
movq %rax, -0xa8(%rbp)
leaq -0xb8(%rbp), %rax
movq %rax, -0xf8(%rbp)
xorl %eax, %eax
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rax
movq -0xf8(%rbp), %rcx
imulq $0xc, %rax, %rdx
addq %rdx, %rcx
leaq -0x24(%rbp), %rdx
imulq $0xc, %rax, %rsi
addq %rsi, %rdx
movq (%rdx), %rsi
movq %rsi, (%rcx)
movl 0x8(%rdx), %edx
movl %edx, 0x8(%rcx)
addq $0x1, %rax
cmpq $0x1, %rax
movq %rax, -0xf0(%rbp)
jne 0x2e636
movq -0xa0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
movl -0xb0(%rbp), %ecx
movq %rsp, %rax
movl %ecx, 0x8(%rax)
movq -0xb8(%rbp), %rcx
movq %rcx, (%rax)
callq 0x2e6f0
movq %rax, -0x98(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0xc(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x1f190
movq (%rax), %rax
movq %rax, -0x8(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0xc0(%rbp)
movq -0xc(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movl -0xc0(%rbp), %edx
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x20840
nop