// File: /workspace/github_cpp_makefile_star2_O1/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 0x1e154
movslq 0x30(%rbx), %rax
testq %rax, %rax
je 0x20520
movq 0x10(%rbx), %r14
shlq $0x2, %rax
leaq (%rax,%rax,2), %r12
xorl %r13d, %r13d
movq 0x4(%r14,%r13), %rdi
testq %rdi, %rdi
je 0x20517
callq 0x1ffce
addq $0xc, %r13
cmpq %r13, %r12
jne 0x20508
movslq 0x30(%rbx), %rax
testq %rax, %rax
je 0x205ca
movq 0x10(%rbx), %r13
shlq $0x2, %rax
leaq (%rax,%rax,2), %rbp
xorl %r14d, %r14d
movq 0x4(%r13,%r14), %r12
testq %r12, %r12
je 0x20568
cmpq %rbx, 0x28(%r12)
jne 0x2055e
movl (%r13,%r14), %edx
movq (%r12), %rax
movq %r12, %rdi
movq %rbx, %rsi
callq *(%rax)
movq %r12, %rdi
callq 0x20036
jmp 0x205bd
movl (%rbx), %edi
movl $0x8, %edx
movq %r15, %rsi
callq 0x15250
cmpl $0x8, %eax
jne 0x20687
movq 0x30(%rsp), %r12
cmpq $0x0, 0x10(%r12)
je 0x20682
movq %r12, %rdi
callq *0x18(%r12)
movq 0x10(%r12), %rax
testq %rax, %rax
je 0x205b0
movq %r12, %rdi
movq %r12, %rsi
movl $0x3, %edx
callq *%rax
movl $0x20, %esi
movq %r12, %rdi
callq 0x21280
addq $0xc, %r14
cmpq %r14, %rbp
jne 0x2053c
movq 0x38(%rbx), %r12
testq %r12, %r12
je 0x204dd
addq $-0x8, %r12
callq 0x2b520
cmpq 0x20(%r12), %rax
jl 0x204dd
cmpq %rbx, 0x28(%r12)
jne 0x20637
movq %r12, %rdi
callq 0x1ffce
movq (%r12), %rax
movq %r12, %rdi
movq %rbx, %rsi
callq *0x8(%rax)
cmpq %rbx, 0x28(%r12)
jne 0x20619
movq %rbx, %rdi
movq %r12, %rsi
callq 0x20d76
movq %r12, %rdi
callq 0x20036
movq 0x38(%rbx), %rax
leaq -0x8(%rax), %r12
testq %rax, %rax
cmoveq %rax, %r12
jne 0x205db
jmp 0x204dd
leaq 0xafd1e(%rip), %rsi     # 0xd035c
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0x79, %edx
movl $0x3, %ecx
callq 0x2019c
movq 0x18(%rbx), %rdi
leaq 0xafd7c(%rip), %rsi     # 0xd03dc
movl $0x17, %edx
callq 0x8bab0
movq 0x20(%rsp), %rdi
leaq 0xb3c95(%rip), %rsi     # 0xd430b
movl $0x2, %edx
callq 0x8bab0
jmp 0x206ea
callq 0x17320
leaq 0xafcce(%rip), %rsi     # 0xd035c
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl $0x1f, %edx
movl $0x3, %ecx
callq 0x2019c
movq 0x18(%rbx), %rdi
leaq 0xafddd(%rip), %rsi     # 0xd048d
movl $0x2c, %edx
callq 0x8bab0
movq 0x20(%rsp), %rdi
leaq 0xb3c45(%rip), %rsi     # 0xd430b
movl $0x2, %edx
callq 0x8bab0
movl 0x8(%rsp), %esi
movq 0x20(%rsp), %rdi
callq 0x2023b
jmp 0x206ea
movq %rax, %rdi
callq 0x18abd
jmp 0x206ea
leaq 0x8(%rsp), %rdi
callq 0x18aaa