// File: /workspace/github_cpp_makefile_star2_O3/romkatv[P]hcproxy/src/dns.cc
// Function: hcproxy::DnsResolver::ProcessCacheEntry(std::_Rb_tree_iterator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, hcproxy::DnsResolver::CacheData>>)
void DnsResolver::ProcessCacheEntry(Cache::iterator it) {
  CacheData& c = it->second;
  Time now = Clock::now();
  std::unique_lock<std::mutex> lock(mutex_);
  if (c.callbacks.empty() && c.used_at + opt_.dns_cache_refresh_duration <= now) {
    cache_.erase(it);
    return;
  }
  if (c.resolved_at + opt_.dns_cache_refresh_period <= now) {
    lock.unlock();
    std::shared_ptr<const addrinfo> addr = ResolveSync(it->first);
    now = Clock::now();
    lock.lock();
    c.resolved_at = now;
    if (addr) {
      c.addr = addr;
      c.successfully_resolved_at = now;
      for (int64_t i = 0; c.use_count; ++i) {
        --c.use_count;
        Advance(c.addr);
        if (c.addr == addr) c.use_count %= i + 1;
      }
    }
  }
  if (!c.callbacks.empty()) {
    std::vector<Callback> callbacks = std::exchange(c.callbacks, {});
    std::shared_ptr<const addrinfo> addr = c.addr;
    for (size_t i = 0; i != callbacks.size(); ++i) c.Use(now);
    lock.unlock();
    for (const auto& f : callbacks) f(Advance(addr));
    lock.lock();
  }
  Time next = std::min(c.resolved_at + opt_.dns_cache_refresh_period,
                       c.used_at + opt_.dns_cache_refresh_duration);
  lock.unlock();
  threads_.Schedule(next, [=] { ProcessCacheEntry(it); });
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movq %rsi, %r14
movq %rdi, %r13
callq 0x2b360
movq %rax, %r15
movq %rax, 0x38(%rsp)
leaq 0x20(%r13), %rax
leaq 0x20(%rsp), %r12
movq %rax, (%r12)
movb $0x0, 0x8(%r12)
movq %r12, %rdi
callq 0x1b4ea
movb $0x1, 0x8(%r12)
movq 0x40(%r14), %rax
movq 0x48(%r14), %rcx
cmpq %rcx, %rax
jne 0x1aac5
movq 0x18(%r13), %rdx
addq 0x68(%r14), %rdx
cmpq %rdx, %r15
jge 0x1abfe
movq 0x10(%r13), %rdx
addq 0x70(%r14), %rdx
cmpq %rdx, %r15
jl 0x1af08
leaq 0x20(%rsp), %rdi
callq 0x1b490
movq 0x20(%r14), %r12
movq %r12, %rdi
movl $0x3a, %esi
callq 0x155c0
testq %rax, %rax
je 0x1ac12
movq %rax, %r15
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x40(%rsp), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x1b66a
incq %r15
xorps %xmm0, %xmm0
leaq 0x98(%rsp), %rdx
movups %xmm0, 0x8(%rdx)
movups %xmm0, 0x18(%rdx)
movq $0x0, 0x28(%rdx)
movl $0x1, 0x8(%rdx)
movabsq $0x200000400, %rax      # imm = 0x200000400
movq %rax, (%rdx)
movq 0x40(%rsp), %rdi
leaq 0x30(%rsp), %rcx
movq %r15, %rsi
callq 0x151e0
movl %eax, %ebp
testl %eax, %eax
je 0x1ac77
leaq 0xb4bd7(%rip), %rsi     # 0xcf742
leaq 0x120(%rsp), %rdi
movl $0x3f, %edx
movl $0x1, %ecx
callq 0x2003c
movq 0x138(%rsp), %rdi
leaq 0xb4bd2(%rip), %rsi     # 0xcf763
movl $0xf, %edx
callq 0x8b8f0
movq 0x138(%rsp), %rdi
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
callq 0x8b8f0
movq 0x138(%rsp), %rdi
leaq 0xb4bb4(%rip), %rsi     # 0xcf773
movl $0x3, %edx
callq 0x8b8f0
movl %ebp, %edi
callq 0x15860
leaq 0x78(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x120(%rsp), %rdi
callq 0x19da4
leaq 0x120(%rsp), %rdi
callq 0x19574
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
jmp 0x1ae2b
addq $0x48, %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x1bd50
jmp 0x1b116
leaq 0xb4b29(%rip), %rsi     # 0xcf742
leaq 0x120(%rsp), %rdi
movl $0x33, %edx
movl $0x1, %ecx
callq 0x2003c
movq 0x138(%rsp), %rdi
leaq 0xb4b0e(%rip), %rsi     # 0xcf74d
movl $0x15, %edx
callq 0x8b8f0
movq 0x138(%rsp), %rdi
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
callq 0x8b8f0
leaq 0x120(%rsp), %rdi
callq 0x19574
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
jmp 0x1ae47
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rax
cmpw $0x2, (%rax)
jne 0x1b137
leaq 0xb4ab1(%rip), %rsi     # 0xcf742
leaq 0x78(%rsp), %rdi
movl $0x43, %edx
xorl %ecx, %ecx
callq 0x2003c
movq 0x90(%rsp), %rdi
leaq 0xb4ac6(%rip), %rsi     # 0xcf777
movl $0x9, %edx
callq 0x8b8f0
movq 0x90(%rsp), %rdi
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
callq 0x8b8f0
movq 0x90(%rsp), %rdi
leaq 0xb4aa2(%rip), %rsi     # 0xcf781
movl $0x4, %edx
callq 0x8b8f0
movq %r14, 0x18(%rsp)
movq %r13, %r14
movq 0x30(%rsp), %rbx
leaq 0x120(%rsp), %rdi
callq 0x94040
leaq 0x118(%rsp), %r15
leaq 0x120(%rsp), %r12
leaq 0xb4a96(%rip), %r13     # 0xcf7b0
movq %rbx, %rbp
cmpq %rbx, %rbp
je 0x1ad32
movl $0x2, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x8b8f0
movq %r15, %rdi
movq %rbp, %rsi
callq 0x1be16
movq %r12, %rdi
movq %r15, %rsi
callq 0x1be91
movq 0x28(%rbp), %rbp
testq %rbp, %rbp
jne 0x1ad1d
leaq 0x128(%rsp), %rsi
leaq 0xc8(%rsp), %rdi
callq 0x91a30
leaq 0xf40fb(%rip), %rsi     # 0x10ee68
leaq 0x120(%rsp), %rdi
callq 0x948f0
leaq 0x190(%rsp), %rdi
callq 0x6de60
movq 0x90(%rsp), %rdi
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
callq 0x8b8f0
movq %r14, %r13
leaq 0xd8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
movq 0x18(%rsp), %r14
je 0x1adcd
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x210c0
leaq 0x78(%rsp), %rdi
callq 0x1959e
movq 0x30(%rsp), %r15
movq %r15, %rax
movq %rax, %rbx
movq 0x28(%rax), %rax
testq %rax, %rax
jne 0x1addf
movq %r15, 0x28(%rbx)
movq %r15, (%rsp)
movq $0x0, 0x8(%rsp)
movl $0x20, %edi
callq 0x22050
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x8(%rax)
leaq 0xef80d(%rip), %rcx     # 0x10a628
movq %rcx, (%rax)
movq %rbx, 0x10(%rax)
movq %r15, 0x18(%rax)
movq %rax, 0x8(%rsp)
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x1ae47
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x210c0
callq 0x2b360
movq %rax, %r15
movq %rax, 0x38(%rsp)
leaq 0x20(%rsp), %rdi
callq 0x1b4ea
movq %r15, 0x70(%r14)
movq (%rsp), %rax
testq %rax, %rax
je 0x1aef1
movq %rax, 0x58(%r14)
leaq 0x60(%r14), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1b702
movq %r15, 0x78(%r14)
movq 0x80(%r14), %rax
testq %rax, %rax
je 0x1aef1
leaq 0x58(%r14), %r15
movl $0x1, %ebx
leaq 0x108(%rsp), %r12
decq %rax
movq %rax, 0x80(%r14)
movq %r12, %rdi
movq %r15, %rsi
callq 0x1b32f
movq 0x110(%rsp), %rdi
testq %rdi, %rdi
je 0x1aec9
callq 0x1b5fa
movq 0x58(%r14), %rcx
movq 0x80(%r14), %rax
cmpq (%rsp), %rcx
jne 0x1aee9
cqto
idivq %rbx
movq %rdx, %rax
movq %rdx, 0x80(%r14)
incq %rbx
testq %rax, %rax
jne 0x1aea2
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1af00
callq 0x1b5fa
movq 0x40(%r14), %rax
movq 0x48(%r14), %rcx
cmpq %rcx, %rax
je 0x1b099
leaq 0x40(%r14), %r12
movq %rax, 0x98(%rsp)
movq %rcx, 0xa0(%rsp)
movq 0x50(%r14), %rax
movq %rax, 0xa8(%rsp)
xorl %eax, %eax
movq %rax, 0x10(%r12)
xorps %xmm0, %xmm0
movups %xmm0, (%r12)
leaq 0x120(%rsp), %rdi
movq %rax, 0x10(%rdi)
movaps %xmm0, (%rdi)
leaq 0x40(%rsp), %r15
movaps %xmm0, (%r15)
movq %rax, 0x10(%r15)
callq 0x1b526
movq %r15, %rdi
callq 0x1b526
movq 0x58(%r14), %rbp
movq 0x60(%r14), %r15
testq %r15, %r15
je 0x1af8d
movq 0xf5ba3(%rip), %rax     # 0x110b20
cmpb $0x0, (%rax)
je 0x1af88
incl 0x8(%r15)
jmp 0x1af8d
lock
incl 0x8(%r15)
movq %r13, 0x70(%rsp)
movq 0xa0(%rsp), %rax
cmpq 0x98(%rsp), %rax
je 0x1afd2
xorl %ebx, %ebx
leaq 0x38(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x1aa16
incq %rbx
movq 0xa0(%rsp), %rax
subq 0x98(%rsp), %rax
sarq $0x5, %rax
cmpq %rax, %rbx
jne 0x1afab
leaq 0x20(%rsp), %rdi
callq 0x1b490
movq %r14, 0x18(%rsp)
movq 0x98(%rsp), %r12
movq 0xa0(%rsp), %rbx
cmpq %rbx, %r12
je 0x1b06b
leaq 0x60(%rsp), %r13
movq %r15, %rax
testq %rbp, %rbp
je 0x1b01d
movq 0x28(%rbp), %r14
testq %rax, %rax
je 0x1b020
movq 0xf5b0d(%rip), %rcx     # 0x110b20
cmpb $0x0, (%rcx)
je 0x1b025
incl 0x8(%rax)
jmp 0x1b029
xorl %r14d, %r14d
xorl %r15d, %r15d
jmp 0x1b02c
lock
incl 0x8(%rax)
movq %rax, %r15
movq %rbp, 0x60(%rsp)
movq %rax, 0x68(%rsp)
cmpq $0x0, 0x10(%r12)
je 0x1b132
movq %r12, %rdi
movq %r13, %rsi
callq *0x18(%r12)
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x1b05c
callq 0x1b5fa
addq $0x20, %r12
movq %r15, %rax
movq %r14, %rbp
cmpq %rbx, %r12
jne 0x1affe
leaq 0x20(%rsp), %rdi
callq 0x1b4ea
movq 0x18(%rsp), %r14
testq %r15, %r15
movq 0x70(%rsp), %r13
je 0x1b08c
movq %r15, %rdi
callq 0x1b5fa
leaq 0x98(%rsp), %rdi
callq 0x1b526
movq 0x68(%r14), %r12
movq %r14, %rbp
movq 0x70(%r14), %r14
movq 0x10(%r13), %r15
movq 0x18(%r13), %rbx
leaq 0x20(%rsp), %rdi
callq 0x1b490
addq %r12, %rbx
addq %r14, %r15
cmpq %r15, %rbx
cmovlq %rbx, %r15
leaq 0xe8(%rsp), %rdx
movq %r13, (%rdx)
addq $0x78, %r13
movq %rbp, 0x8(%rdx)
leaq 0x333(%rip), %rax       # 0x1b410
movq %rax, 0x18(%rdx)
leaq 0x338(%rip), %rax       # 0x1b420
movq %rax, 0x10(%rdx)
movq %r13, %rdi
movq %r15, %rsi
callq 0x1c23a
movq 0xf8(%rsp), %rax
testq %rax, %rax
je 0x1b116
leaq 0xe8(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x20(%rsp), %rdi
callq 0x1b4d4
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1731e
leaq 0xb4604(%rip), %rsi     # 0xcf742
leaq 0x120(%rsp), %rdi
movl $0x42, %edx
movl $0x3, %ecx
callq 0x2003c
movq 0x138(%rsp), %rdi
leaq 0xb4374(%rip), %rsi     # 0xcf4d8
movl $0x22, %edx
callq 0x8b8f0
movq 0x138(%rsp), %rdi
leaq 0xb914e(%rip), %rsi     # 0xd42cb
movl $0x2, %edx
callq 0x8b8f0
jmp 0x1b189
leaq 0x120(%rsp), %rdi
callq 0x18a24
jmp 0x1b206
movq %rax, %rdi
callq 0x210e0
movq $0x0, 0x28(%rbx)
movq %r15, %rdi
callq 0x15380
callq 0x21ef0
movq %rax, %rbx
callq 0x21150
jmp 0x1b2d1
jmp 0x1b28c
movq %rax, %rbx
leaq 0xd8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1b2c7
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x210c0
jmp 0x1b2c7
jmp 0x1b2a3
jmp 0x1b213
jmp 0x1b206
jmp 0x1b294
jmp 0x1b24d
jmp 0x1b206
movq %rax, %rbx
jmp 0x1b2d1
jmp 0x1b294
movq %rax, %rbx
jmp 0x1b2c7
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
callq 0x19574
jmp 0x1b31d
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1b31d
callq 0x1b5fa
jmp 0x1b31d
jmp 0x1b294
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
callq 0x19574
jmp 0x1b2d1
jmp 0x1b28c
movq %rax, %rbx
movq 0xf8(%rsp), %rax
testq %rax, %rax
je 0x1b31d
leaq 0xe8(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x1b31d
movq %rax, %rdi
callq 0x18a37
movq %rax, %rbx
jmp 0x1b31d
movq %rax, %rbx
jmp 0x1b303
jmp 0x1b2a3
movq %rax, %rbx
leaq 0xf3bbb(%rip), %rsi     # 0x10ee68
leaq 0x120(%rsp), %rdi
callq 0x948f0
leaq 0x190(%rsp), %rdi
callq 0x6de60
leaq 0x78(%rsp), %rdi
callq 0x1959e
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x1b31d
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x210c0
jmp 0x1b31d
jmp 0x1b2f1
movq %rax, %rbx
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x1b303
callq 0x1b5fa
testq %r15, %r15
je 0x1b310
movq %r15, %rdi
callq 0x1b5fa
leaq 0x98(%rsp), %rdi
callq 0x1b526
leaq 0x20(%rsp), %rdi
callq 0x1b4d4
movq %rbx, %rdi
callq 0xcc750