// File: /workspace/github_cpp_makefile_star2_O3/romkatv[P]hcproxy/src/event_loop.cc
// Function: hcproxy::EventLoop::Loop()
void EventLoop::Loop() {
  while (true) {
    epoll_.Wait(timeout_);
    for (const epoll_event& ev : epoll_) {
      if (ev.data.ptr != nullptr) {
        static_cast<EventHandler*>(ev.data.ptr)->IncRef();
      }
    }
    for (const epoll_event& ev : epoll_) {
      if (ev.data.ptr == nullptr) {
        PopFunc(pipe_[0]);
      } else {
        auto* eh = static_cast<EventHandler*>(ev.data.ptr);
        if (eh->event_loop_ == this) {
          eh->OnEvent(this, ev.events);
        }
        eh->DecRef();
      }
    }
    while (true) {
      auto* eh = static_cast<EventHandler*>(expire_.head());
      if (!eh || eh->deadline_ > Clock::now()) break;
      CHECK(eh->event_loop_ == this);
      eh->IncRef();
      eh->OnTimeout(this);
      if (eh->event_loop_ == this) Refresh(eh);
      eh->DecRef();
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
leaq 0x8(%rdi), %rax
movq %rax, 0x28(%rsp)
leaq 0x30(%rsp), %r15
movq 0x48(%rbx), %rsi
movq 0x28(%rsp), %rdi
movl $0x1, %edx
callq 0x1dfbe
movslq 0x30(%rbx), %rax
testq %rax, %rax
je 0x204a4
movq 0x10(%rbx), %r14
shlq $0x2, %rax
leaq (%rax,%rax,2), %r12
xorl %r13d, %r13d
movq 0x4(%r14,%r13), %rdi
testq %rdi, %rdi
je 0x203bb
callq 0x1fe64
addq $0xc, %r13
cmpq %r13, %r12
jne 0x203ac
movslq 0x30(%rbx), %rax
testq %rax, %rax
je 0x204a4
movq 0x10(%rbx), %r13
shlq $0x2, %rax
leaq (%rax,%rax,2), %rbp
xorl %r14d, %r14d
movq 0x4(%r13,%r14), %r12
testq %r12, %r12
je 0x2040c
cmpq %rbx, 0x28(%r12)
jne 0x20402
movl (%r13,%r14), %edx
movq (%r12), %rax
movq %r12, %rdi
movq %rbx, %rsi
callq *(%rax)
movq %r12, %rdi
callq 0x1fed0
jmp 0x20461
movl (%rbx), %edi
movl $0x8, %edx
movq %r15, %rsi
callq 0x15250
cmpl $0x8, %eax
jne 0x20515
movq 0x30(%rsp), %r12
cmpq $0x0, 0x10(%r12)
je 0x20510
movq %r12, %rdi
callq *0x18(%r12)
movq 0x10(%r12), %rax
testq %rax, %rax
je 0x20454
movq %r12, %rdi
movq %r12, %rsi
movl $0x3, %edx
callq *%rax
movl $0x20, %esi
movq %r12, %rdi
callq 0x210c0
addq $0xc, %r14
cmpq %r14, %rbp
jne 0x203e0
jmp 0x204a4
cmpq %rbx, 0x20(%r14)
jne 0x204c5
movq %r12, %rdi
callq 0x1fe64
movq -0x8(%r14), %rax
movq %r12, %rdi
movq %rbx, %rsi
callq *0x8(%rax)
cmpq %rbx, 0x20(%r14)
jne 0x2049c
movq %rbx, %rdi
movq %r12, %rsi
callq 0x20bce
movq %r12, %rdi
callq 0x1fed0
movq 0x38(%rbx), %r14
testq %r14, %r14
je 0x2037d
leaq -0x8(%r14), %r12
callq 0x2b360
cmpq 0x18(%r14), %rax
jge 0x20470
jmp 0x2037d
leaq 0xafe5c(%rip), %rsi     # 0xd0328
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0x79, %edx
movl $0x3, %ecx
callq 0x2003c
movq 0x18(%rbx), %rdi
leaq 0xafeba(%rip), %rsi     # 0xd03a8
movl $0x17, %edx
callq 0x8b8f0
movq 0x20(%rsp), %rdi
leaq 0xb3dc7(%rip), %rsi     # 0xd42cb
movl $0x2, %edx
callq 0x8b8f0
jmp 0x20578
callq 0x1731e
leaq 0xafe0c(%rip), %rsi     # 0xd0328
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0x1f, %edx
movl $0x3, %ecx
callq 0x2003c
movq 0x18(%rbx), %rdi
leaq 0xaff1b(%rip), %rsi     # 0xd0459
movl $0x2c, %edx
callq 0x8b8f0
movq 0x20(%rsp), %rdi
leaq 0xb3d77(%rip), %rsi     # 0xd42cb
movl $0x2, %edx
callq 0x8b8f0
movl 0x8(%rsp), %esi
movq 0x20(%rsp), %rdi
callq 0x200db
jmp 0x20578
movq %rax, %rdi
callq 0x18a37
jmp 0x20578
leaq 0x8(%rsp), %rdi
callq 0x18a24