// File: romkatv[P]hcproxy/src/dns.cc
// Function: hcproxy::(anonymous namespace)::ResolveSync(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
std::shared_ptr<const addrinfo> ResolveSync(const std::string& host_port) {
  const char* port = std::strchr(host_port.c_str(), ':');
  if (!port) {
    LOG(WARN) << "Malformed host:port: " << host_port;
    return nullptr;
  }
  std::string host(host_port.c_str(), port);
  ++port;
  addrinfo* res;
  addrinfo hint = {};
  hint.ai_family = AF_INET;
  hint.ai_socktype = SOCK_STREAM;
  hint.ai_flags = AI_NUMERICSERV;
  int ret = getaddrinfo(host.c_str(), port, &hint, &res);
  if (ret != 0) {
    LOG(WARN) << "DNS error for '" << host_port << "': " << gai_strerror(ret);
    return nullptr;
  }
  CHECK(res->ai_addr->sa_family == AF_INET);
  LOG(INFO) << "Resolved " << host_port << " as " << Describe(*res);
  for (addrinfo* tail = res;; tail = tail->ai_next) {
    if (tail->ai_next) continue;
    tail->ai_next = res;
    return std::shared_ptr<const addrinfo>(res, [tail](addrinfo* head) {
      tail->ai_next = nullptr;
      freeaddrinfo(head);
    });
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x178(%rbp)
movq %rdi, %rax
movq %rax, -0x170(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0xb1320
movq %rax, %rdi
movl $0x3a, %esi
callq 0x155c0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x1fe0e
leaq 0xc4c40(%rip), %rsi     # 0xe49a0
leaq -0x38(%rbp), %rdi
movq %rdi, -0x188(%rbp)
movl $0x33, %edx
movl $0x1, %ecx
callq 0x1bb40
movq -0x188(%rbp), %rdi
callq 0x194e0
movq %rax, -0x180(%rbp)
jmp 0x1fd8f
movq -0x180(%rbp), %rdi
leaq 0xc4c0e(%rip), %rsi     # 0xe49ab
callq 0x1f0f0
movq %rax, -0x190(%rbp)
jmp 0x1fdab
movq -0x190(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x22770
movq %rax, -0x198(%rbp)
jmp 0x1fdc4
movq -0x198(%rbp), %rsi
leaq -0x45(%rbp), %rdi
callq 0x194f0
jmp 0x1fdd6
leaq -0x38(%rbp), %rdi
callq 0x1bbb0
movq -0x178(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x21870
jmp 0x202a9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x1bbb0
jmp 0x202b9
movq -0x10(%rbp), %rdi
callq 0xb1320
movq %rax, -0x1b0(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x1a8(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0x36a60
movq -0x1b0(%rbp), %rsi
movq -0x1a8(%rbp), %rdx
movq -0x1a0(%rbp), %rcx
leaq -0x68(%rbp), %rdi
callq 0x227a0
jmp 0x1fe59
leaq -0x69(%rbp), %rdi
callq 0x36a80
movq -0x18(%rbp), %rax
incq %rax
movq %rax, -0x18(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movl $0x2, -0xac(%rbp)
movl $0x1, -0xa8(%rbp)
movl $0x400, -0xb0(%rbp)     # imm = 0x400
leaq -0x68(%rbp), %rdi
callq 0xb1320
movq %rax, %rdi
movq -0x18(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
leaq -0x78(%rbp), %rcx
callq 0x151e0
movl %eax, -0x1b4(%rbp)
jmp 0x1fecb
movl -0x1b4(%rbp), %eax
movl %eax, -0xb4(%rbp)
cmpl $0x0, -0xb4(%rbp)
je 0x2001f
leaq 0xc4ab5(%rip), %rsi     # 0xe49a0
leaq -0xd8(%rbp), %rdi
movl $0x3f, %edx
movl $0x1, %ecx
callq 0x1bb40
jmp 0x1ff03
leaq -0xd8(%rbp), %rdi
callq 0x194e0
movq %rax, -0x1c0(%rbp)
jmp 0x1ff18
movq -0x1c0(%rbp), %rdi
leaq 0xc4a9b(%rip), %rsi     # 0xe49c1
callq 0x1ba10
movq %rax, -0x1c8(%rbp)
jmp 0x1ff34
movq -0x1c8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x22770
movq %rax, -0x1d0(%rbp)
jmp 0x1ff4d
movq -0x1d0(%rbp), %rdi
leaq 0xc4a76(%rip), %rsi     # 0xe49d1
callq 0x22810
movq %rax, -0x1d8(%rbp)
jmp 0x1ff69
movl -0xb4(%rbp), %edi
callq 0x15870
movq -0x1d8(%rbp), %rdi
movq %rax, -0xe0(%rbp)
leaq -0xe0(%rbp), %rsi
callq 0x1db60
movq %rax, -0x1e0(%rbp)
jmp 0x1ff97
movq -0x1e0(%rbp), %rsi
leaq -0xe1(%rbp), %rdi
callq 0x194f0
jmp 0x1ffac
leaq -0xd8(%rbp), %rdi
callq 0x1bbb0
movq -0x178(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x21870
movl $0x1, -0xe8(%rbp)
jmp 0x20293
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x69(%rbp), %rdi
callq 0x36a80
jmp 0x202b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2029e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x1bbb0
jmp 0x2029e
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movzwl (%rax), %eax
movb $0x0, -0x109(%rbp)
cmpl $0x2, %eax
jne 0x2003b
jmp 0x200c5
leaq 0xc495e(%rip), %rsi     # 0xe49a0
leaq -0x108(%rbp), %rdi
movl $0x42, %edx
movl $0x3, %ecx
callq 0x194b0
jmp 0x2005a
movb $0x1, -0x109(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x194e0
movq %rax, -0x1e8(%rbp)
jmp 0x20076
movq -0x1e8(%rbp), %rdi
leaq 0xc4469(%rip), %rsi     # 0xe44ed
callq 0x1dba0
movq %rax, -0x1f0(%rbp)
jmp 0x20092
movq -0x1f0(%rbp), %rdi
leaq 0xc92eb(%rip), %rsi     # 0xe938b
callq 0x19450
movq %rax, -0x1f8(%rbp)
jmp 0x200ae
movq -0x1f8(%rbp), %rsi
leaq -0x10a(%rbp), %rdi
callq 0x194f0
jmp 0x200c3
jmp 0x200c5
testb $0x1, -0x109(%rbp)
jne 0x200d0
jmp 0x200fa
leaq -0x108(%rbp), %rdi
callq 0x19500
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
testb $0x1, -0x109(%rbp)
jne 0x201f5
jmp 0x20201
leaq 0xc489f(%rip), %rsi     # 0xe49a0
leaq -0x130(%rbp), %rdi
movl $0x43, %edx
xorl %ecx, %ecx
callq 0x1c360
jmp 0x20116
leaq -0x130(%rbp), %rdi
callq 0x194e0
movq %rax, -0x200(%rbp)
jmp 0x2012b
movq -0x200(%rbp), %rdi
leaq 0xc489c(%rip), %rsi     # 0xe49d5
callq 0x22840
movq %rax, -0x208(%rbp)
jmp 0x20147
movq -0x208(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x22770
movq %rax, -0x210(%rbp)
jmp 0x20160
movq -0x210(%rbp), %rdi
leaq 0xc4871(%rip), %rsi     # 0xe49df
callq 0x19480
movq %rax, -0x218(%rbp)
jmp 0x2017c
movq -0x78(%rbp), %rsi
leaq -0x150(%rbp), %rdi
callq 0x20410
jmp 0x2018e
movq -0x218(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x22770
movq %rax, -0x220(%rbp)
jmp 0x201aa
movq -0x220(%rbp), %rsi
leaq -0x151(%rbp), %rdi
callq 0x194f0
jmp 0x201bf
leaq -0x150(%rbp), %rdi
callq 0xaf8e0
leaq -0x130(%rbp), %rdi
callq 0x1c390
movq -0x78(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x160(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x2023a
jmp 0x2027c
leaq -0x108(%rbp), %rdi
callq 0x19500
jmp 0x2029e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2022c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x150(%rbp), %rdi
callq 0xaf8e0
leaq -0x130(%rbp), %rdi
callq 0x1c390
jmp 0x2029e
movq -0x178(%rbp), %rdi
movq -0x78(%rbp), %rcx
movq -0x160(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x78(%rbp), %rsi
movq -0x160(%rbp), %rax
movq %rax, -0x168(%rbp)
movq -0x168(%rbp), %rdx
callq 0x20520
jmp 0x20270
movl $0x1, -0xe8(%rbp)
jmp 0x20293
movq -0x160(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x160(%rbp)
jmp 0x201e2
leaq -0x68(%rbp), %rdi
callq 0xaf8e0
jmp 0x202a9
leaq -0x68(%rbp), %rdi
callq 0xaf8e0
jmp 0x202b9
movq -0x170(%rbp), %rax
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0xe1080
nopw %cs:(%rax,%rax)