// File: romkatv[P]hcproxy/src/event_loop.cc
// Function: hcproxy::EventLoop::EventLoop(std::chrono::duration<long, std::ratio<1l, 1000000000l>>)
EventLoop::EventLoop(Duration timeout) : timeout_(std::move(timeout)) {
  CHECK(timeout_ > Duration::zero());
  // Passing O_DIRECT to pipe2() doesn't work on WSL.
  // Setting it via fcntl() doesn't work on Linux.
  if (pipe2(pipe_, O_DIRECT) != 0) {
    CHECK(pipe(pipe_) == 0) << Errno();
    for (int fd : pipe_) AddFlags(fd, O_DIRECT);
  }
  epoll_.Add(pipe_[0], EPOLLIN, nullptr);
  loop_ = std::thread(&EventLoop::Loop, this);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rsi, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
addq $0x8, %rdi
movq %rdi, -0xe0(%rbp)
callq 0x2be70
movq -0xd8(%rbp), %rdi
addq $0x38, %rdi
callq 0x34170
movq -0xd8(%rbp), %rdi
movq %rdi, %rax
addq $0x48, %rax
movq %rax, -0xc8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, 0x48(%rdi)
addq $0x50, %rdi
movq %rdi, -0xd0(%rbp)
callq 0x34190
callq 0x1b2a0
movq -0xc8(%rbp), %rdi
movq %rax, -0x18(%rbp)
movb $0x0, -0x49(%rbp)
leaq -0x18(%rbp), %rsi
callq 0x341b0
movb %al, -0xb9(%rbp)
jmp 0x324b0
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x324bc
jmp 0x324be
jmp 0x3253c
leaq 0xb2f17(%rip), %rsi     # 0xe53dc
leaq -0x48(%rbp), %rdi
movl $0x2c, %edx
movl $0x3, %ecx
callq 0x194b0
jmp 0x324da
movb $0x1, -0x49(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x194e0
movq %rax, -0xe8(%rbp)
jmp 0x324f0
movq -0xe8(%rbp), %rdi
leaq 0xb2ef0(%rip), %rsi     # 0xe53ee
callq 0x1d940
movq %rax, -0xf0(%rbp)
jmp 0x3250c
movq -0xf0(%rbp), %rdi
leaq 0xb6e71(%rip), %rsi     # 0xe938b
callq 0x19450
movq %rax, -0xf8(%rbp)
jmp 0x32528
movq -0xf8(%rbp), %rsi
leaq -0x4a(%rbp), %rdi
callq 0x194f0
jmp 0x3253a
jmp 0x3253c
testb $0x1, -0x49(%rbp)
jne 0x32544
jmp 0x32579
leaq -0x48(%rbp), %rdi
callq 0x19500
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x32785
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
testb $0x1, -0x49(%rbp)
jne 0x32658
jmp 0x32661
movq -0xd8(%rbp), %rdi
movl $0x4000, %esi           # imm = 0x4000
callq 0x15070
cmpl $0x0, %eax
je 0x326f6
movq -0xd8(%rbp), %rdi
callq 0x15470
movb $0x0, -0x71(%rbp)
cmpl $0x0, %eax
jne 0x325ad
jmp 0x32647
leaq 0xb2e28(%rip), %rsi     # 0xe53dc
leaq -0x70(%rbp), %rdi
movl $0x30, %edx
movl $0x3, %ecx
callq 0x194b0
jmp 0x325c9
movb $0x1, -0x71(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x194e0
movq %rax, -0x100(%rbp)
jmp 0x325df
movq -0x100(%rbp), %rdi
leaq 0xb2e1d(%rip), %rsi     # 0xe540a
callq 0x19650
movq %rax, -0x108(%rbp)
jmp 0x325fb
movq -0x108(%rbp), %rdi
leaq 0xb6d82(%rip), %rsi     # 0xe938b
callq 0x19450
movq %rax, -0x110(%rbp)
jmp 0x32617
callq 0x1c0c0
jmp 0x3261e
movq -0x110(%rbp), %rdi
callq 0x1c050
movq %rax, -0x118(%rbp)
jmp 0x32633
movq -0x118(%rbp), %rsi
leaq -0x74(%rbp), %rdi
callq 0x194f0
jmp 0x32645
jmp 0x32647
testb $0x1, -0x71(%rbp)
jne 0x3264f
jmp 0x3267a
leaq -0x70(%rbp), %rdi
callq 0x19500
leaq -0x48(%rbp), %rdi
callq 0x19500
jmp 0x32785
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
testb $0x1, -0x71(%rbp)
jne 0x326e6
jmp 0x326ef
movq -0xd8(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x90(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x90(%rbp), %rax
je 0x326f4
movq -0x88(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %edi
movl $0x4000, %esi           # imm = 0x4000
callq 0x327b0
jmp 0x326d0
jmp 0x326d2
movq -0x88(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x88(%rbp)
jmp 0x3269f
leaq -0x70(%rbp), %rdi
callq 0x19500
jmp 0x32785
jmp 0x326f6
movq -0xd8(%rbp), %rax
movq %rax, %rdi
addq $0x8, %rdi
movl (%rax), %esi
xorl %eax, %eax
movl %eax, %ecx
movl $0x1, %edx
callq 0x2c080
jmp 0x32716
movq -0xd8(%rbp), %rax
leaq 0x18c(%rip), %rcx       # 0x328b0
movq %rcx, -0xb0(%rbp)
movq $0x0, -0xa8(%rbp)
movq %rax, -0xb8(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
callq 0x341e0
jmp 0x32759
movq -0xd8(%rbp), %rdi
addq $0x50, %rdi
leaq -0xa0(%rbp), %rsi
callq 0x342a0
leaq -0xa0(%rbp), %rdi
callq 0x27be0
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq -0xd0(%rbp), %rdi
callq 0x27be0
movq -0xe0(%rbp), %rdi
callq 0x2bfa0
movq -0x20(%rbp), %rdi
callq 0xe1080
nopw %cs:(%rax,%rax)