// File: WeihuaZhu[P]hpc_prog2/./gtest/gtest-all.cc
// Function: testing::internal::StreamingListener::SocketWriter::MakeConnection()
void StreamingListener::SocketWriter::MakeConnection() {
  GTEST_CHECK_(sockfd_ == -1)
      << "MakeConnection() can't be called when there is already a connection.";

  addrinfo hints;
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = AF_UNSPEC;    // To allow both IPv4 and IPv6 addresses.
  hints.ai_socktype = SOCK_STREAM;
  addrinfo* servinfo = NULL;

  // Use the getaddrinfo() to get a linked list of IP addresses for
  // the given host name.
  const int error_num = getaddrinfo(
      host_name_.c_str(), port_num_.c_str(), &hints, &servinfo);
  if (error_num != 0) {
    GTEST_LOG_(WARNING) << "stream_result_to: getaddrinfo() failed: "
                        << gai_strerror(error_num);
  }

  // Loop through all the results and connect to the first we can.
  for (addrinfo* cur_addr = servinfo; sockfd_ == -1 && cur_addr != NULL;
       cur_addr = cur_addr->ai_next) {
    sockfd_ = socket(
        cur_addr->ai_family, cur_addr->ai_socktype, cur_addr->ai_protocol);
    if (sockfd_ != -1) {
      // Connect the client socket to the server socket.
      if (connect(sockfd_, cur_addr->ai_addr, cur_addr->ai_addrlen) == -1) {
        close(sockfd_);
        sockfd_ = -1;
      }
    }
  }

  freeaddrinfo(servinfo);  // all done with this structure

  if (sockfd_ == -1) {
    GTEST_LOG_(WARNING) << "stream_result_to: failed to connect to "
                        << host_name_ << ":" << port_num_;
  }
}

// Assembly:
subq $0xe8, %rsp
movq %rdi, 0xe0(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x70(%rsp)
cmpl $-0x1, 0x8(%rax)
sete %al
movzbl %al, %edi
andl $0x1, %edi
callq 0x16400
testb $0x1, %al
jne 0x25e54
jmp 0x25e59
jmp 0x25eed
leaq 0x26a9f(%rip), %rdx     # 0x4c8ff
leaq 0xdc(%rsp), %rdi
movq %rdi, 0x60(%rsp)
movl $0x3, %esi
movl $0x133b, %ecx           # imm = 0x133B
callq 0x2fd30
movq 0x60(%rsp), %rdi
callq 0x32a40
movq %rax, 0x68(%rsp)
jmp 0x25e8d
movq 0x68(%rsp), %rdi
leaq 0x27574(%rip), %rsi     # 0x4d40d
callq 0xea00
movq %rax, 0x58(%rsp)
jmp 0x25ea5
movq 0x58(%rsp), %rdi
leaq 0x2757d(%rip), %rsi     # 0x4d42e
callq 0xea00
jmp 0x25eb8
leaq 0xdc(%rsp), %rdi
callq 0x2fea0
jmp 0x25eed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0xdc(%rsp), %rdi
callq 0x2fea0
jmp 0x261c5
leaq 0x98(%rsp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0xe4f0
movq 0x70(%rsp), %rdi
movl $0x0, 0x9c(%rsp)
movl $0x1, 0xa0(%rsp)
movq $0x0, 0x90(%rsp)
addq $0x10, %rdi
callq 0xe370
movq 0x70(%rsp), %rdi
movq %rax, 0x50(%rsp)
addq $0x30, %rdi
callq 0xe370
movq 0x50(%rsp), %rdi
movq %rax, %rsi
leaq 0x98(%rsp), %rdx
leaq 0x90(%rsp), %rcx
callq 0xee00
movl %eax, 0x8c(%rsp)
cmpl $0x0, 0x8c(%rsp)
je 0x26012
leaq 0x26982(%rip), %rdx     # 0x4c8ff
leaq 0x88(%rsp), %rdi
movq %rdi, 0x40(%rsp)
movl $0x1, %esi
movl $0x1349, %ecx           # imm = 0x1349
callq 0x2fd30
movq 0x40(%rsp), %rdi
callq 0x32a40
movq %rax, 0x48(%rsp)
jmp 0x25faa
movq 0x48(%rsp), %rdi
leaq 0x274bd(%rip), %rsi     # 0x4d473
callq 0xea00
movq %rax, 0x38(%rsp)
jmp 0x25fc2
movl 0x8c(%rsp), %edi
callq 0xefb0
movq 0x38(%rsp), %rdi
movq %rax, %rsi
callq 0xea00
jmp 0x25fdd
leaq 0x88(%rsp), %rdi
callq 0x2fea0
jmp 0x26012
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x2fea0
jmp 0x261c5
movq 0x90(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x70(%rsp), %rcx
xorl %eax, %eax
cmpl $-0x1, 0x8(%rcx)
movb %al, 0x37(%rsp)
jne 0x26043
cmpq $0x0, 0x80(%rsp)
setne %al
movb %al, 0x37(%rsp)
movb 0x37(%rsp), %al
testb $0x1, %al
jne 0x26050
jmp 0x260e5
movq 0x80(%rsp), %rax
movl 0x4(%rax), %edi
movq 0x80(%rsp), %rax
movl 0x8(%rax), %esi
movq 0x80(%rsp), %rax
movl 0xc(%rax), %edx
callq 0xe210
movl %eax, %ecx
movq 0x70(%rsp), %rax
movl %ecx, 0x8(%rax)
cmpl $-0x1, 0x8(%rax)
je 0x260ca
movq 0x70(%rsp), %rax
movl 0x8(%rax), %edi
movq 0x80(%rsp), %rax
movq 0x18(%rax), %rsi
movq 0x80(%rsp), %rax
movl 0x10(%rax), %edx
callq 0xe850
cmpl $-0x1, %eax
jne 0x260c8
movq 0x70(%rsp), %rax
movl 0x8(%rax), %edi
callq 0xf640
movq 0x70(%rsp), %rax
movl $0xffffffff, 0x8(%rax)  # imm = 0xFFFFFFFF
jmp 0x260ca
jmp 0x260cc
movq 0x80(%rsp), %rax
movq 0x28(%rax), %rax
movq %rax, 0x80(%rsp)
jmp 0x26022
movq 0x90(%rsp), %rdi
callq 0xee80
movq 0x70(%rsp), %rax
cmpl $-0x1, 0x8(%rax)
jne 0x261bd
leaq 0x267f7(%rip), %rdx     # 0x4c8ff
leaq 0x7c(%rsp), %rdi
movq %rdi, 0x20(%rsp)
movl $0x1, %esi
movl $0x135e, %ecx           # imm = 0x135E
callq 0x2fd30
movq 0x20(%rsp), %rdi
callq 0x32a40
movq %rax, 0x28(%rsp)
jmp 0x26132
movq 0x28(%rsp), %rdi
leaq 0x2735e(%rip), %rsi     # 0x4d49c
callq 0xea00
movq %rax, 0x18(%rsp)
jmp 0x2614a
movq 0x18(%rsp), %rdi
movq 0x70(%rsp), %rsi
addq $0x10, %rsi
callq 0xe900
movq %rax, 0x10(%rsp)
jmp 0x26164
movq 0x10(%rsp), %rdi
leaq 0x2737e(%rip), %rsi     # 0x4d4ee
callq 0xea00
movq %rax, 0x8(%rsp)
jmp 0x2617c
movq 0x8(%rsp), %rdi
movq 0x70(%rsp), %rsi
addq $0x30, %rsi
callq 0xe900
jmp 0x26191
leaq 0x7c(%rsp), %rdi
callq 0x2fea0
jmp 0x261bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0x7c(%rsp), %rdi
callq 0x2fea0
jmp 0x261c5
addq $0xe8, %rsp
retq
movq 0xd0(%rsp), %rdi
callq 0xf410
nopw %cs:(%rax,%rax)