// File: /workspace/github_cpp_makefile_star2_O1/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 $0x2a8, %rsp            # imm = 0x2A8
movq %rsi, %r14
movq %rdi, %r13
callq 0x2b520
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 0x1b5f0
movb $0x1, 0x8(%r12)
movq 0x40(%r14), %rax
cmpq 0x48(%r14), %rax
jne 0x1ab84
movq 0x18(%r13), %rax
addq 0x68(%r14), %rax
cmpq %rax, %r15
jge 0x1acb8
movq 0x10(%r13), %rax
addq 0x70(%r14), %rax
cmpq %rax, %r15
jl 0x1afc3
leaq 0x20(%rsp), %rdi
callq 0x1b596
movq 0x20(%r14), %r12
movq %r12, %rdi
movl $0x3a, %esi
callq 0x155c0
testq %rax, %rax
je 0x1accc
movq %rax, %r15
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x40(%rsp), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x1b770
incq %r15
xorps %xmm0, %xmm0
leaq 0x70(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x20(%rdx)
movaps %xmm0, 0x10(%rdx)
movabsq $0x100000002, %rax      # imm = 0x100000002
movq %rax, 0x4(%rdx)
movl $0x400, (%rdx)          # imm = 0x400
movq 0x40(%rsp), %rdi
leaq 0x30(%rsp), %rcx
movq %r15, %rsi
callq 0x151e0
movl %eax, %ebp
testl %eax, %eax
je 0x1ad31
leaq 0xb4b30(%rip), %rsi     # 0xcf752
leaq 0x130(%rsp), %rdi
movl $0x3f, %edx
movl $0x1, %ecx
callq 0x2019c
movq 0x148(%rsp), %rdi
leaq 0xb4b2b(%rip), %rsi     # 0xcf773
movl $0xf, %edx
callq 0x8bab0
movq 0x148(%rsp), %rdi
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
callq 0x8bab0
movq 0x148(%rsp), %rdi
leaq 0xb4b0d(%rip), %rsi     # 0xcf783
movl $0x3, %edx
callq 0x8bab0
movl %ebp, %edi
callq 0x15860
leaq 0xb0(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x130(%rsp), %rdi
callq 0x19e52
leaq 0x130(%rsp), %rdi
callq 0x1965e
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
jmp 0x1aeeb
addq $0x48, %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x1be6a
jmp 0x1b207
leaq 0xb4a7f(%rip), %rsi     # 0xcf752
leaq 0x130(%rsp), %rdi
movl $0x33, %edx
movl $0x1, %ecx
callq 0x2019c
movq 0x148(%rsp), %rdi
leaq 0xb4a64(%rip), %rsi     # 0xcf75d
movl $0x15, %edx
callq 0x8bab0
movq 0x148(%rsp), %rdi
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
callq 0x8bab0
leaq 0x130(%rsp), %rdi
callq 0x1965e
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
jmp 0x1af07
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rax
cmpw $0x2, (%rax)
jne 0x1b228
leaq 0xb4a07(%rip), %rsi     # 0xcf752
leaq 0xb0(%rsp), %rdi
movl $0x43, %edx
xorl %ecx, %ecx
callq 0x2019c
movq 0xc8(%rsp), %rdi
leaq 0xb4a19(%rip), %rsi     # 0xcf787
movl $0x9, %edx
callq 0x8bab0
movq 0xc8(%rsp), %rdi
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
callq 0x8bab0
movq 0xc8(%rsp), %rdi
leaq 0xb49f5(%rip), %rsi     # 0xcf791
movl $0x4, %edx
callq 0x8bab0
movq %r14, 0x18(%rsp)
movq %r13, %r14
movq 0x30(%rsp), %rbx
leaq 0x130(%rsp), %rdi
callq 0x94200
leaq 0x128(%rsp), %r15
leaq 0x130(%rsp), %r12
leaq 0xb49e9(%rip), %r13     # 0xcf7c0
movq %rbx, %rbp
cmpq %rbx, %rbp
je 0x1adef
movl $0x2, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x8bab0
movq %r15, %rdi
movq %rbp, %rsi
callq 0x1bf2e
movq %r12, %rdi
movq %r15, %rsi
callq 0x1bfa9
movq 0x28(%rbp), %rbp
testq %rbp, %rbp
jne 0x1adda
leaq 0x138(%rsp), %rsi
leaq 0xd0(%rsp), %rdi
callq 0x91bf0
leaq 0xf403e(%rip), %rsi     # 0x10ee68
leaq 0x130(%rsp), %rdi
callq 0x94ab0
leaq 0x1a0(%rsp), %rdi
callq 0x6e020
movq 0xc8(%rsp), %rdi
movq 0xd0(%rsp), %rsi
movq 0xd8(%rsp), %rdx
callq 0x8bab0
movq %r14, %r13
leaq 0xe0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
movq 0x18(%rsp), %r14
je 0x1ae8a
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x21280
leaq 0xb0(%rsp), %rdi
callq 0x19688
movq 0x30(%rsp), %r15
movq %r15, %rax
movq %rax, %rbx
movq 0x28(%rax), %rax
testq %rax, %rax
jne 0x1ae9f
movq %r15, 0x28(%rbx)
movq %r15, (%rsp)
movq $0x0, 0x8(%rsp)
movl $0x20, %edi
callq 0x22210
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x8(%rax)
leaq 0xef72d(%rip), %rcx     # 0x10a608
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 0x1af07
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x21280
callq 0x2b520
movq %rax, %r15
movq %rax, 0x38(%rsp)
leaq 0x20(%rsp), %rdi
callq 0x1b5f0
movq %r15, 0x70(%r14)
movq (%rsp), %rax
testq %rax, %rax
je 0x1afb4
movq %rax, 0x58(%r14)
leaq 0x60(%r14), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1b808
movq %r15, 0x78(%r14)
movq 0x80(%r14), %rax
testq %rax, %rax
je 0x1afb4
leaq 0x58(%r14), %r15
movl $0x1, %ebx
leaq 0x118(%rsp), %r12
decq %rax
movq %rax, 0x80(%r14)
movq %r12, %rdi
movq %r15, %rsi
callq 0x1b420
movq 0x120(%rsp), %rdi
testq %rdi, %rdi
je 0x1af89
callq 0x1b700
movq (%r15), %rax
cmpq (%rsp), %rax
jne 0x1afa5
movq 0x80(%r14), %rax
cqto
idivq %rbx
movq %rdx, 0x80(%r14)
movq 0x80(%r14), %rax
incq %rbx
testq %rax, %rax
jne 0x1af62
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1afc3
callq 0x1b700
movq 0x40(%r14), %rax
movq 0x48(%r14), %rcx
cmpq %rcx, %rax
je 0x1b180
leaq 0x40(%r14), %r12
xorl %edx, %edx
leaq 0x40(%rsp), %r15
movq %rdx, 0x10(%r15)
xorps %xmm0, %xmm0
movaps %xmm0, (%r15)
movq %rax, 0x70(%rsp)
movq %rcx, 0x78(%rsp)
movq 0x50(%r14), %rax
movq %rax, 0x80(%rsp)
movq %rdx, 0x10(%r12)
movups %xmm0, (%r12)
leaq 0x130(%rsp), %rdi
movq %rdx, 0x10(%rdi)
movaps %xmm0, (%rdi)
movups 0x48(%r14), %xmm0
movq (%r15), %rax
movq %rax, 0x40(%r14)
movq 0x8(%r15), %rax
movq %rax, 0x48(%r14)
movq 0x10(%r15), %rax
movq %rax, 0x50(%r14)
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
movq 0x10(%rdi), %rsi
movq %rdx, (%rdi)
movups %xmm0, 0x8(%rdi)
movq %rax, (%r15)
movq %rcx, 0x8(%r15)
movq %rsi, 0x10(%r15)
callq 0x1b62c
movq %r15, %rdi
callq 0x1b62c
movq 0x58(%r14), %rbp
movq 0x60(%r14), %r15
testq %r15, %r15
je 0x1b083
movq 0xf5aad(%rip), %rax     # 0x110b20
cmpb $0x0, (%rax)
je 0x1b07e
incl 0x8(%r15)
jmp 0x1b083
lock
incl 0x8(%r15)
movq %r13, 0xa8(%rsp)
movq 0x78(%rsp), %rax
cmpq 0x70(%rsp), %rax
je 0x1b0bf
xorl %ebx, %ebx
leaq 0x38(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x1aad8
incq %rbx
movq 0x78(%rsp), %rax
subq 0x70(%rsp), %rax
sarq $0x5, %rax
cmpq %rax, %rbx
jne 0x1b09e
leaq 0x20(%rsp), %rdi
callq 0x1b596
movq %r14, 0x18(%rsp)
movq 0x70(%rsp), %r12
movq 0x78(%rsp), %rbx
cmpq %rbx, %r12
je 0x1b152
leaq 0x60(%rsp), %r13
movq %r15, %rax
testq %rbp, %rbp
je 0x1b104
movq 0x28(%rbp), %r14
testq %rax, %rax
je 0x1b110
movq 0xf5a26(%rip), %rcx     # 0x110b20
cmpb $0x0, (%rcx)
je 0x1b10c
incl 0x8(%rax)
jmp 0x1b110
xorl %r14d, %r14d
xorl %r15d, %r15d
jmp 0x1b113
lock
incl 0x8(%rax)
movq %rax, %r15
movq %rbp, 0x60(%rsp)
movq %rax, 0x68(%rsp)
cmpq $0x0, 0x10(%r12)
je 0x1b223
movq %r12, %rdi
movq %r13, %rsi
callq *0x18(%r12)
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x1b143
callq 0x1b700
addq $0x20, %r12
movq %r15, %rax
movq %r14, %rbp
cmpq %rbx, %r12
jne 0x1b0e5
leaq 0x20(%rsp), %rdi
callq 0x1b5f0
movq 0x18(%rsp), %r14
testq %r15, %r15
movq 0xa8(%rsp), %r13
je 0x1b176
movq %r15, %rdi
callq 0x1b700
leaq 0x70(%rsp), %rdi
callq 0x1b62c
movq 0x68(%r14), %r12
movq %r14, %rbp
movq 0x70(%r14), %r14
movq 0x10(%r13), %r15
movq 0x18(%r13), %rbx
leaq 0x20(%rsp), %rdi
callq 0x1b596
addq %r12, %rbx
addq %r14, %r15
cmpq %r15, %rbx
cmovlq %rbx, %r15
xorps %xmm0, %xmm0
leaq 0xf0(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x10(%rdx)
movq %r13, (%rdx)
addq $0x78, %r13
movq %rbp, 0x8(%rdx)
leaq 0x348(%rip), %rax       # 0x1b516
movq %rax, 0x18(%rdx)
leaq 0x34d(%rip), %rax       # 0x1b526
movq %rax, 0x10(%rdx)
movq %r13, %rdi
movq %r15, %rsi
callq 0x1c344
movq 0x100(%rsp), %rax
testq %rax, %rax
je 0x1b207
leaq 0xf0(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x20(%rsp), %rdi
callq 0x1b5da
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x17320
leaq 0xb4523(%rip), %rsi     # 0xcf752
leaq 0x130(%rsp), %rdi
movl $0x42, %edx
movl $0x3, %ecx
callq 0x2019c
movq 0x148(%rsp), %rdi
leaq 0xb429b(%rip), %rsi     # 0xcf4f0
movl $0x22, %edx
callq 0x8bab0
movq 0x148(%rsp), %rdi
leaq 0xb909d(%rip), %rsi     # 0xd430b
movl $0x2, %edx
callq 0x8bab0
jmp 0x1b27a
leaq 0x130(%rsp), %rdi
callq 0x18aaa
jmp 0x1b2f7
movq %rax, %rdi
callq 0x212a0
movq $0x0, 0x28(%rbx)
movq %r15, %rdi
callq 0x15380
callq 0x220b0
movq %rax, %rbx
callq 0x21310
jmp 0x1b3c5
jmp 0x1b37d
movq %rax, %rbx
leaq 0xe0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1b3b8
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x21280
jmp 0x1b3b8
jmp 0x1b394
jmp 0x1b304
jmp 0x1b2f7
jmp 0x1b385
jmp 0x1b33e
jmp 0x1b2f7
movq %rax, %rbx
jmp 0x1b3c5
jmp 0x1b385
movq %rax, %rbx
jmp 0x1b3b8
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
callq 0x1965e
jmp 0x1b40e
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x1b40e
callq 0x1b700
jmp 0x1b40e
jmp 0x1b385
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
callq 0x1965e
jmp 0x1b3c5
jmp 0x1b37d
movq %rax, %rbx
movq 0x100(%rsp), %rax
testq %rax, %rax
je 0x1b40e
leaq 0xf0(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x1b40e
movq %rax, %rdi
callq 0x18abd
movq %rax, %rbx
jmp 0x1b40e
movq %rax, %rbx
jmp 0x1b3f7
jmp 0x1b394
movq %rax, %rbx
leaq 0xf3aca(%rip), %rsi     # 0x10ee68
leaq 0x130(%rsp), %rdi
callq 0x94ab0
leaq 0x1a0(%rsp), %rdi
callq 0x6e020
leaq 0xb0(%rsp), %rdi
callq 0x19688
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x1b40e
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x21280
jmp 0x1b40e
jmp 0x1b3e5
movq %rax, %rbx
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x1b3f7
callq 0x1b700
testq %r15, %r15
je 0x1b404
movq %r15, %rdi
callq 0x1b700
leaq 0x70(%rsp), %rdi
callq 0x1b62c
leaq 0x20(%rsp), %rdi
callq 0x1b5da
movq %rbx, %rdi
callq 0xcc900