// File: romkatv[P]hcproxy/src/connector.cc
// Function: hcproxy::(anonymous namespace)::ConnectAsync(addrinfo const&)
int ConnectAsync(const addrinfo& addr) {
  int fd = socket(addr.ai_family, SOCK_STREAM | SOCK_NONBLOCK, 0);
  if (fd < 0) {
    LOG(ERROR) << "socket() failed: " << Errno();
    CHECK(errno == EMFILE || errno == ENFILE || errno == ENOBUFS || errno == ENOMEM) << Errno();
    return -1;
  }
  LOG(INFO) << "[" << fd << "] connecting to " << IpPort(addr);
  int one = 1;
  CHECK(setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)) == 0) << Errno();
  if (connect(fd, addr.ai_addr, addr.ai_addrlen) != 0 && errno != EINPROGRESS) {
    LOG(WARN) << "[" << fd << "] connect() failed: " << Errno();
    CHECK(close(fd) == 0) << Errno();
    return -1;
  }
  return fd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edi
movl $0x801, %esi            # imm = 0x801
xorl %edx, %edx
callq 0x155d0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jge 0x1e2bc
leaq 0xc6573(%rip), %rsi     # 0xe4699
leaq -0x38(%rbp), %rdi
movq %rdi, -0x128(%rbp)
movl $0x27, %edx
movl $0x2, %ecx
callq 0x1d9a0
movq -0x128(%rbp), %rdi
callq 0x194e0
movq %rax, %rdi
leaq 0xc6554(%rip), %rsi     # 0xe46aa
callq 0x1c430
movq %rax, -0x120(%rbp)
jmp 0x1e164
callq 0x1c0c0
jmp 0x1e16b
movq -0x120(%rbp), %rdi
callq 0x1c050
movq %rax, -0x130(%rbp)
jmp 0x1e180
movq -0x130(%rbp), %rsi
leaq -0x47(%rbp), %rdi
callq 0x194f0
jmp 0x1e192
leaq -0x38(%rbp), %rdi
callq 0x1d9d0
callq 0x15640
movl (%rax), %eax
movb $0x0, -0x69(%rbp)
cmpl $0x18, %eax
je 0x1e1c9
callq 0x15640
cmpl $0x17, (%rax)
je 0x1e1c9
callq 0x15640
cmpl $0x69, (%rax)
je 0x1e1c9
callq 0x15640
cmpl $0xc, (%rax)
jne 0x1e1ce
jmp 0x1e263
leaq 0xc64c4(%rip), %rsi     # 0xe4699
leaq -0x68(%rbp), %rdi
movq %rdi, -0x140(%rbp)
movl $0x28, %edx
movl $0x3, %ecx
callq 0x194b0
movq -0x140(%rbp), %rdi
movb $0x1, -0x69(%rbp)
callq 0x194e0
movq %rax, %rdi
leaq 0xc6250(%rip), %rsi     # 0xe4459
callq 0x1da10
movq %rax, -0x138(%rbp)
jmp 0x1e217
movq -0x138(%rbp), %rdi
leaq 0xcb166(%rip), %rsi     # 0xe938b
callq 0x19450
movq %rax, -0x148(%rbp)
jmp 0x1e233
callq 0x1c0c0
jmp 0x1e23a
movq -0x148(%rbp), %rdi
callq 0x1c050
movq %rax, -0x150(%rbp)
jmp 0x1e24f
movq -0x150(%rbp), %rsi
leaq -0x6c(%rbp), %rdi
callq 0x194f0
jmp 0x1e261
jmp 0x1e263
testb $0x1, -0x69(%rbp)
jne 0x1e26b
jmp 0x1e2a2
leaq -0x68(%rbp), %rdi
callq 0x19500
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x1d9d0
jmp 0x1e6cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
testb $0x1, -0x69(%rbp)
jne 0x1e2ae
jmp 0x1e2b7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1e6c1
leaq -0x68(%rbp), %rdi
callq 0x19500
jmp 0x1e6cd
leaq 0xc63d6(%rip), %rsi     # 0xe4699
leaq -0x90(%rbp), %rdi
movq %rdi, -0x160(%rbp)
movl $0x2b, %edx
xorl %ecx, %ecx
callq 0x1c360
movq -0x160(%rbp), %rdi
callq 0x194e0
movq %rax, %rdi
leaq 0xc5eed(%rip), %rsi     # 0xe41e0
callq 0x1bb10
movq %rax, -0x158(%rbp)
jmp 0x1e301
movq -0x158(%rbp), %rdi
leaq -0x14(%rbp), %rsi
callq 0x1bad0
movq %rax, -0x168(%rbp)
jmp 0x1e31a
movq -0x168(%rbp), %rdi
leaq 0xc6394(%rip), %rsi     # 0xe46bc
callq 0x19650
movq %rax, -0x170(%rbp)
jmp 0x1e336
movq -0x10(%rbp), %rsi
leaq -0x98(%rbp), %rdi
callq 0x24f60
jmp 0x1e348
movq -0x170(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x1d880
movq %rax, -0x178(%rbp)
jmp 0x1e364
movq -0x178(%rbp), %rsi
leaq -0x99(%rbp), %rdi
callq 0x194f0
jmp 0x1e379
leaq -0x90(%rbp), %rdi
callq 0x1c390
movl $0x1, -0xa0(%rbp)
movl -0x14(%rbp), %edi
movl $0x6, %esi
movl $0x1, %edx
leaq -0xa0(%rbp), %rcx
movl $0x4, %r8d
callq 0x152e0
movb $0x0, -0xc1(%rbp)
cmpl $0x0, %eax
jne 0x1e3bf
jmp 0x1e45d
leaq 0xc62d3(%rip), %rsi     # 0xe4699
leaq -0xc0(%rbp), %rdi
movq %rdi, -0x188(%rbp)
movl $0x2d, %edx
movl $0x3, %ecx
callq 0x194b0
movq -0x188(%rbp), %rdi
movb $0x1, -0xc1(%rbp)
callq 0x194e0
movq %rax, %rdi
leaq 0xc62cd(%rip), %rsi     # 0xe46cd
callq 0x1f090
movq %rax, -0x180(%rbp)
jmp 0x1e40e
movq -0x180(%rbp), %rdi
leaq 0xcaf6f(%rip), %rsi     # 0xe938b
callq 0x19450
movq %rax, -0x190(%rbp)
jmp 0x1e42a
callq 0x1c0c0
jmp 0x1e431
movq -0x190(%rbp), %rdi
callq 0x1c050
movq %rax, -0x198(%rbp)
jmp 0x1e446
movq -0x198(%rbp), %rsi
leaq -0xc4(%rbp), %rdi
callq 0x194f0
jmp 0x1e45b
jmp 0x1e45d
testb $0x1, -0xc1(%rbp)
jne 0x1e468
jmp 0x1e4af
leaq -0xc0(%rbp), %rdi
callq 0x19500
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x1c390
jmp 0x1e6cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
testb $0x1, -0xc1(%rbp)
jne 0x1e665
jmp 0x1e671
movl -0x14(%rbp), %edi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x10(%rbp), %rax
movl 0x10(%rax), %edx
callq 0x15540
cmpl $0x0, %eax
je 0x1e6bb
callq 0x15640
cmpl $0x73, (%rax)
je 0x1e6bb
leaq 0xc61b5(%rip), %rsi     # 0xe4699
leaq -0xe8(%rbp), %rdi
movq %rdi, -0x1a8(%rbp)
movl $0x2f, %edx
movl $0x1, %ecx
callq 0x1bb40
movq -0x1a8(%rbp), %rdi
callq 0x194e0
movq %rax, %rdi
leaq 0xc5cc9(%rip), %rsi     # 0xe41e0
callq 0x1bb10
movq %rax, -0x1a0(%rbp)
jmp 0x1e525
movq -0x1a0(%rbp), %rdi
leaq -0x14(%rbp), %rsi
callq 0x1bad0
movq %rax, -0x1b0(%rbp)
jmp 0x1e53e
movq -0x1b0(%rbp), %rdi
leaq 0xc61c2(%rip), %rsi     # 0xe470e
callq 0x1c400
movq %rax, -0x1b8(%rbp)
jmp 0x1e55a
callq 0x1c0c0
jmp 0x1e561
movq -0x1b8(%rbp), %rdi
callq 0x1c050
movq %rax, -0x1c0(%rbp)
jmp 0x1e576
movq -0x1c0(%rbp), %rsi
leaq -0xeb(%rbp), %rdi
callq 0x194f0
jmp 0x1e58b
leaq -0xe8(%rbp), %rdi
callq 0x1bbb0
movl -0x14(%rbp), %edi
callq 0x15140
movb $0x0, -0x111(%rbp)
cmpl $0x0, %eax
jne 0x1e5b0
jmp 0x1e64e
leaq 0xc60e2(%rip), %rsi     # 0xe4699
leaq -0x110(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
movl $0x30, %edx
movl $0x3, %ecx
callq 0x194b0
movq -0x1d0(%rbp), %rdi
movb $0x1, -0x111(%rbp)
callq 0x194e0
movq %rax, %rdi
leaq 0xc6132(%rip), %rsi     # 0xe4723
callq 0x195f0
movq %rax, -0x1c8(%rbp)
jmp 0x1e5ff
movq -0x1c8(%rbp), %rdi
leaq 0xcad7e(%rip), %rsi     # 0xe938b
callq 0x19450
movq %rax, -0x1d8(%rbp)
jmp 0x1e61b
callq 0x1c0c0
jmp 0x1e622
movq -0x1d8(%rbp), %rdi
callq 0x1c050
movq %rax, -0x1e0(%rbp)
jmp 0x1e637
movq -0x1e0(%rbp), %rsi
leaq -0x114(%rbp), %rdi
callq 0x194f0
jmp 0x1e64c
jmp 0x1e64e
testb $0x1, -0x111(%rbp)
jne 0x1e659
jmp 0x1e6a4
leaq -0x110(%rbp), %rdi
callq 0x19500
leaq -0xc0(%rbp), %rdi
callq 0x19500
jmp 0x1e6cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x1bbb0
jmp 0x1e6cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
testb $0x1, -0x111(%rbp)
jne 0x1e6ad
jmp 0x1e6b9
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1e6c1
leaq -0x110(%rbp), %rdi
callq 0x19500
jmp 0x1e6cd
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0xe1080
nopw %cs:(%rax,%rax)