// File: /workspace/github_cpp_makefile_star2_O3/romkatv[P]hcproxy/src/dns.cc
// Function: hcproxy::DnsResolver::Resolve(std::basic_string_view<char, std::char_traits<char>>, std::function<void (std::shared_ptr<addrinfo const>)>)
void DnsResolver::Resolve(std::string_view host_port, Callback cb) {
  const Time now = Clock::now();
  std::unique_lock<std::mutex> lock(mutex_);
  auto it = cache_.find(host_port);
  if (it == cache_.end()) {
    CacheData c;
    c.callbacks.push_back(std::move(cb));
    it = cache_.insert({std::string(host_port), std::move(c)}).first;
    lock.unlock();
    threads_.Schedule(now, [=] { ProcessCacheEntry(it); });
    return;
  }
  CacheData& c = it->second;
  if (!c.callbacks.empty()) {
    c.callbacks.push_back(std::move(cb));
    return;
  }
  std::shared_ptr<const addrinfo> addr =
      c.successfully_resolved_at + opt_.dns_cache_ttl > now ? c.addr : nullptr;
  c.Use(now);
  lock.unlock();
  cb(std::move(addr));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rcx, %r15
movq %rdi, %rbx
leaq 0x50(%rsp), %r13
movq %rsi, (%r13)
movq %rdx, 0x8(%r13)
callq 0x2b360
movq %rax, %r14
movq %rax, 0x48(%rsp)
leaq 0x20(%rbx), %rax
leaq 0x38(%rsp), %r12
movq %rax, (%r12)
movb $0x0, 0x8(%r12)
movq %r12, %rdi
callq 0x1b4ea
movb $0x1, 0x8(%r12)
leaq 0x48(%rbx), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x1b74c
leaq 0x50(%rbx), %rcx
cmpq %rcx, %rax
je 0x1a70c
movq %rax, %rdi
addq $0x40, %rdi
movq 0x40(%rax), %rcx
cmpq 0x48(%rax), %rcx
je 0x1a780
movq %r15, %rsi
callq 0x1b888
jmp 0x1a949
xorps %xmm0, %xmm0
leaq 0x60(%rsp), %rdi
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
movq $0x0, 0x40(%rdi)
movq %r15, %rsi
callq 0x1b888
movq 0x58(%rsp), %rsi
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x1b66a
leaq 0xe0(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq 0x8(%rsp), %rax
cmpq %r13, %rax
je 0x1a7bb
movq %rax, 0xd0(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0xe0(%rsp)
jmp 0x1a7c4
movq 0x8(%rbx), %rcx
addq 0x78(%rax), %rcx
cmpq %rcx, %r14
jge 0x1a904
movq 0x58(%rax), %rbx
movq 0x60(%rax), %r14
testq %r14, %r14
je 0x1a906
movq 0xf6377(%rip), %rax     # 0x110b20
cmpb $0x0, (%rax)
je 0x1a965
incl 0x8(%r14)
jmp 0x1a909
movups (%r13), %xmm0
movups %xmm0, (%rbp)
movq 0x10(%rsp), %rax
leaq 0xd0(%rsp), %rsi
movq %rax, 0x8(%rsi)
movq %r13, 0x8(%rsp)
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
movaps 0x60(%rsp), %xmm0
movups %xmm0, 0x20(%rsi)
movq 0x70(%rsp), %rcx
movq %rcx, 0x30(%rsi)
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq %rax, 0x70(%rsp)
movups 0x78(%rsp), %xmm1
movups %xmm1, 0x38(%rsi)
movups %xmm0, 0x78(%rsp)
movups 0x88(%rsp), %xmm0
movups %xmm0, 0x48(%rsi)
movups 0x98(%rsp), %xmm0
movups %xmm0, 0x58(%rsi)
movq %r12, %rdi
callq 0x1bab4
movq %rax, %r15
leaq 0xf0(%rsp), %r12
movq 0x20(%r12), %rdi
testq %rdi, %rdi
je 0x1a84d
callq 0x1b5fa
movq %r12, %rdi
callq 0x1b526
movq 0xd0(%rsp), %rdi
cmpq %rbp, %rdi
je 0x1a872
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x210c0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x1a889
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x210c0
leaq 0x38(%rsp), %rdi
callq 0x1b490
leaq 0xb0(%rsp), %rdx
movq %rbx, (%rdx)
addq $0x78, %rbx
movq %r15, 0x8(%rdx)
leaq 0xb2b(%rip), %rax       # 0x1b3d8
movq %rax, 0x18(%rdx)
leaq 0xb30(%rip), %rax       # 0x1b3e8
movq %rax, 0x10(%rdx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1c23a
movq 0xc0(%rsp), %rax
testq %rax, %rax
je 0x1a8e6
leaq 0xb0(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x1a8f8
callq 0x1b5fa
leaq 0x60(%rsp), %rdi
callq 0x1b526
jmp 0x1a949
xorl %ebx, %ebx
xorl %r14d, %r14d
leaq 0x48(%rsp), %rsi
callq 0x1aa16
leaq 0x38(%rsp), %rdi
callq 0x1b490
movq %rbx, 0x28(%rsp)
movq %r14, 0x30(%rsp)
cmpq $0x0, 0x10(%r15)
je 0x1a96c
leaq 0x28(%rsp), %rsi
movq %r15, %rdi
callq *0x18(%r15)
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1a949
callq 0x1b5fa
leaq 0x38(%rsp), %rdi
callq 0x1b4d4
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
lock
incl 0x8(%r14)
jmp 0x1a909
callq 0x1731e
jmp 0x1a9a8
movq %rax, %rbx
testq %r14, %r14
je 0x1aa03
movq %r14, %rdi
jmp 0x1a9ea
movq %rax, %rbx
movq 0xc0(%rsp), %rax
testq %rax, %rax
je 0x1a9f4
leaq 0xb0(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x1a9f4
movq %rax, %rdi
callq 0x18a37
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x1b448
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x1a9f4
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x210c0
jmp 0x1a9f4
jmp 0x1a9f1
jmp 0x1aa00
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1aa03
callq 0x1b5fa
jmp 0x1aa03
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x1b4b8
jmp 0x1aa03
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x1b4d4
movq %rbx, %rdi
callq 0xcc750
nop