// File: /workspace/github_cpp_makefile_star2_O1/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 0x2b520
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 0x1b5f0
movb $0x1, 0x8(%r12)
leaq 0x48(%rbx), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x1b84e
leaq 0x50(%rbx), %rcx
cmpq %rcx, %rax
je 0x1a7c0
movq %rax, %rdi
addq $0x40, %rdi
movq 0x40(%rax), %rcx
cmpq 0x48(%rax), %rcx
je 0x1a834
movq %r15, %rsi
callq 0x1b990
jmp 0x1aa07
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 0x1b990
movq 0x58(%rsp), %rsi
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x1b770
leaq 0xe0(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq 0x8(%rsp), %rax
cmpq %r13, %rax
je 0x1a86f
movq %rax, 0xd0(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0xe0(%rsp)
jmp 0x1a878
movq 0x8(%rbx), %rcx
addq 0x78(%rax), %rcx
cmpq %rcx, %r14
jge 0x1a9c2
movq 0x58(%rax), %rbx
movq 0x60(%rax), %r14
testq %r14, %r14
je 0x1a9c7
movq 0xf62c3(%rip), %rax     # 0x110b20
cmpb $0x0, (%rax)
je 0x1aa23
incl 0x8(%r14)
jmp 0x1a9c7
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)
movq 0x60(%rsp), %rcx
movq %rcx, 0x20(%rsi)
movups 0x68(%rsp), %xmm0
movups %xmm0, 0x28(%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 0x1bbc6
movq %rax, %r15
leaq 0xf0(%rsp), %r12
movq 0x20(%r12), %rdi
testq %rdi, %rdi
je 0x1a901
callq 0x1b700
movq %r12, %rdi
callq 0x1b62c
movq 0xd0(%rsp), %rdi
cmpq %rbp, %rdi
je 0x1a926
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x21280
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x1a93d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21280
leaq 0x38(%rsp), %rdi
callq 0x1b596
xorps %xmm0, %xmm0
leaq 0xb0(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x10(%rdx)
movq %rbx, (%rdx)
addq $0x78, %rbx
movq %r15, 0x8(%rdx)
leaq 0xb73(%rip), %rax       # 0x1b4de
movq %rax, 0x18(%rdx)
leaq 0xb78(%rip), %rax       # 0x1b4ee
movq %rax, 0x10(%rdx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1c344
movq 0xc0(%rsp), %rax
testq %rax, %rax
je 0x1a9a4
leaq 0xb0(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x1a9b6
callq 0x1b700
leaq 0x60(%rsp), %rdi
callq 0x1b62c
jmp 0x1aa07
xorl %ebx, %ebx
xorl %r14d, %r14d
leaq 0x48(%rsp), %rsi
callq 0x1aad8
leaq 0x38(%rsp), %rdi
callq 0x1b596
movq %rbx, 0x28(%rsp)
movq %r14, 0x30(%rsp)
cmpq $0x0, 0x10(%r15)
je 0x1aa2a
leaq 0x28(%rsp), %rsi
movq %r15, %rdi
callq *0x18(%r15)
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1aa07
callq 0x1b700
leaq 0x38(%rsp), %rdi
callq 0x1b5da
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
lock
incl 0x8(%r14)
jmp 0x1a9c7
callq 0x17320
jmp 0x1aa5a
movq %rax, %rbx
jmp 0x1aaa4
movq %rax, %rbx
movq 0xc0(%rsp), %rax
testq %rax, %rax
je 0x1aab6
leaq 0xb0(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x1aab6
movq %rax, %rdi
callq 0x18abd
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x1b54e
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x1aab6
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21280
jmp 0x1aab6
jmp 0x1aab3
jmp 0x1aac2
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1aaa1
callq 0x1b700
xorl %r14d, %r14d
testq %r14, %r14
je 0x1aac5
movq %r14, %rdi
callq 0x1b700
jmp 0x1aac5
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x1b5be
jmp 0x1aac5
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x1b5da
movq %rbx, %rdi
callq 0xcc900
nop