#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct sockaddr_storage {
  int dummy;
};
struct sockaddr_in6 {
  scalar_t__ ai_family;
  void *sin6_port;
  int /*<<< orphan*/ sin6_addr;
  void *sin_port;
  int /*<<< orphan*/ sin_addr;
  scalar_t__ ai_addr;
  scalar_t__ sin6_family;
  scalar_t__ sin_family;
  scalar_t__ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
};
struct sockaddr_in {
  scalar_t__ ai_family;
  void *sin6_port;
  int /*<<< orphan*/ sin6_addr;
  void *sin_port;
  int /*<<< orphan*/ sin_addr;
  scalar_t__ ai_addr;
  scalar_t__ sin6_family;
  scalar_t__ sin_family;
  scalar_t__ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
};
struct sockaddr {
  int dummy;
};
struct in6_addr {
  int dummy;
};
struct addrinfo {
  scalar_t__ ai_family;
  void *sin6_port;
  int /*<<< orphan*/ sin6_addr;
  void *sin_port;
  int /*<<< orphan*/ sin_addr;
  scalar_t__ ai_addr;
  scalar_t__ sin6_family;
  scalar_t__ sin_family;
  scalar_t__ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ hints;
typedef int /*<<< orphan*/ buff;
typedef int /*<<< orphan*/ adr6;
typedef int /*<<< orphan*/ adr;

/* Variables and functions */
scalar_t__ AF_INET;
scalar_t__ AF_INET6;
scalar_t__ AF_UNSPEC;
int /*<<< orphan*/ EXIT_FAILURE;
int INET6_ADDRSTRLEN;
int INET_ADDRSTRLEN;
int NI_MAXHOST;
int /*<<< orphan*/ NI_NUMERICHOST;
int /*<<< orphan*/ SOCK_STREAM;
int atoi(char *);
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ freeaddrinfo(struct sockaddr_in6 *);
char *gai_strerror(int);
int getaddrinfo(char *, int /*<<< orphan*/ *, struct sockaddr_in6 *,
                struct sockaddr_in6 **);
int getnameinfo(struct sockaddr *, int, char *, int, int /*<<< orphan*/ *,
                int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ getsockname(int, struct sockaddr *, int *);
void *htons(int);
char *inet_ntop(scalar_t__, int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ memset(struct sockaddr_in6 *, int /*<<< orphan*/, int);
int ntohs(void *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ recv(int, char *, int, int /*<<< orphan*/);
int socket(scalar_t__, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc < 3) {
    fprintf(stderr, "Bad arguments!\nusage: %s <ADDR> <PORT>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  int sock;
  int port = atoi(argv[2]);
  char buff[1024];
  char buff4[INET_ADDRSTRLEN];
  char buff6[INET6_ADDRSTRLEN];
  struct in6_addr adres;
  struct sockaddr *adrp;
  struct sockaddr_in adr;
  struct sockaddr_in6 adr6;
  int sock_storage_size = sizeof(struct sockaddr_storage);
  struct sockaddr_storage sock_storage;
  memset(&adr, 0, sizeof(adr));
  memset(&adr6, 0, sizeof(adr6));
  struct addrinfo hints;
  struct addrinfo *result;
  int retval;
  int ip_version;
  char address[NI_MAXHOST];
  socklen_t sockaddr_size;
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_protocol = 0;
  if ((retval = getaddrinfo(argv[1], NULL, &hints, &result)) != 0) {
    fprintf(stderr, "getaddrinfo(): %s\n", gai_strerror(retval));
    exit(EXIT_FAILURE);
  }
  sock = socket(result->ai_family, SOCK_STREAM, 0);
  if (result->ai_family == AF_INET) {
    ip_version = 4;
    sockaddr_size = sizeof(struct sockaddr_in);
    adr.sin_family = AF_INET;
    adr.sin_port = htons(port);
    adr.sin_addr = ((struct sockaddr_in *)result->ai_addr)->sin_addr;
    adrp = (struct sockaddr *)&adr;
  } else {
    ip_version = 6;
    sockaddr_size = sizeof(struct sockaddr_in6);
    adr6.sin6_family = AF_INET6;
    adr6.sin6_port = htons(port);
    adr6.sin6_addr = ((struct sockaddr_in6 *)result->ai_addr)->sin6_addr;
    adrp = (struct sockaddr *)&adr6;
  }
  if (connect(sock, adrp, sockaddr_size) < 0) {
    fprintf(stderr, "Bad connected.\n");
    exit(EXIT_FAILURE);
  }
  printf("Connected.\n");
  retval = getnameinfo((struct sockaddr *)result->ai_addr, sockaddr_size,
                       address, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
  if (retval != 0) {
    fprintf(stderr, "getnameinfo(): %s\n", gai_strerror(retval));
    exit(EXIT_FAILURE);
  }
  printf("[IPv%d]  %s\n", ip_version, address);
  getsockname(sock, (struct sockaddr *)&sock_storage, &sock_storage_size);
  if (ip_version == 4) {
    fprintf(stderr, "[sock %s] %d\n",
            inet_ntop(AF_INET,
                      &(((struct sockaddr_in *)&sock_storage)->sin_addr), buff4,
                      INET_ADDRSTRLEN),
            ntohs(((struct sockaddr_in *)&sock_storage)->sin_port));
  } else {
    fprintf(stderr, "[sock %s] %d\n",
            inet_ntop(AF_INET6,
                      &(((struct sockaddr_in6 *)&sock_storage)->sin6_addr),
                      buff6, INET6_ADDRSTRLEN),
            ntohs(((struct sockaddr_in6 *)&sock_storage)->sin6_port));
  }
  recv(sock, buff, sizeof(buff), 0);
  printf("Message from server: %s\n", buff);
  close(sock);
  if (result != NULL) {
    freeaddrinfo(result);
  }
  printf("Connection closed\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x5b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    125f <main+0x4f>
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdb6(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2d48(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    0x2d32(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x428(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x580(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x430(%rbp)
mov    0x2d3d(%rip),%rax
mov    (%rax),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x578(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x438(%rbp)
movl   $0x4,-0x4ec(%rbp)
lea    -0x498(%rbp),%rdi
xor    %esi,%esi
mov    %esi,-0x570(%rbp)
mov    $0x50,%edx
mov    %edx,-0x56c(%rbp)
call   1080 <memset@plt>
mov    -0x570(%rbp),%esi
mov    -0x56c(%rbp),%edx
lea    -0x4e8(%rbp),%rdi
call   1080 <memset@plt>
mov    0x2c81(%rip),%rax
mov    (%rax),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x568(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x558(%rbp)
lea    -0x540(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1080 <memset@plt>
mov    0x2c83(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x540(%rbp)
mov    0x2c52(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4f8(%rbp)
movq   $0x0,-0x500(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x540(%rbp),%rdx
lea    -0x548(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%esi
call   1110 <getaddrinfo@plt>
mov    %eax,-0x54c(%rbp)
cmp    $0x0,%eax
je     13e6 <main+0x1d6>
mov    0x2c12(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x584(%rbp)
mov    -0x54c(%rbp),%edi
call   1070 <gai_strerror@plt>
mov    -0x584(%rbp),%edi
mov    %rax,%rdx
lea    0xc57(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2bc1(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x548(%rbp),%rax
mov    (%rax),%rdi
mov    0x2bc1(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,-0x14(%rbp)
mov    -0x548(%rbp),%rax
mov    (%rax),%rax
mov    0x2bcc(%rip),%rcx
cmp    (%rcx),%rax
jne    1478 <main+0x268>
movl   $0x4,-0x550(%rbp)
movl   $0x50,-0x55c(%rbp)
mov    0x2ba8(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x460(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <htons@plt>
mov    %rax,-0x480(%rbp)
mov    -0x548(%rbp),%rax
mov    0x28(%rax),%rax
mov    0x20(%rax),%eax
mov    %eax,-0x478(%rbp)
lea    -0x498(%rbp),%rax
mov    %rax,-0x448(%rbp)
jmp    14ce <main+0x2be>
movl   $0x6,-0x550(%rbp)
movl   $0x50,-0x55c(%rbp)
mov    0x2b3d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x4b8(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <htons@plt>
mov    %rax,-0x4e0(%rbp)
mov    -0x548(%rbp),%rax
mov    0x28(%rax),%rax
mov    0x10(%rax),%eax
mov    %eax,-0x4d8(%rbp)
lea    -0x4e8(%rbp),%rax
mov    %rax,-0x448(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x448(%rbp),%rsi
mov    -0x55c(%rbp),%edx
call   1100 <connect@plt>
cmp    $0x0,%rax
jge    1512 <main+0x302>
mov    0x2acc(%rip),%rax
mov    (%rax),%edi
lea    0xb3e(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2a95(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
lea    0xb32(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x568(%rbp),%rdx
mov    -0x548(%rbp),%rax
mov    0x28(%rax),%rdi
mov    -0x55c(%rbp),%esi
mov    0x2a59(%rip),%rax
mov    (%rax),%ecx
mov    0x2a68(%rip),%rax
mov    (%rax),%eax
xor    %r8d,%r8d
xor    %r9d,%r9d
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   10a0 <getnameinfo@plt>
add    $0x10,%rsp
mov    %eax,-0x54c(%rbp)
cmpl   $0x0,-0x54c(%rbp)
je     15b2 <main+0x3a2>
mov    0x2a46(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x588(%rbp)
mov    -0x54c(%rbp),%edi
call   1070 <gai_strerror@plt>
mov    -0x588(%rbp),%edi
mov    %rax,%rdx
lea    0xaba(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x29f5(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x568(%rbp),%rdx
mov    -0x550(%rbp),%esi
lea    0xaa4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x4f0(%rbp),%rsi
lea    -0x4ec(%rbp),%rdx
call   10d0 <getsockname@plt>
cmpl   $0x4,-0x550(%rbp)
jne    165e <main+0x44e>
mov    -0x580(%rbp),%rdx
mov    0x29c2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x594(%rbp)
mov    0x29d3(%rip),%rax
mov    (%rax),%rdi
lea    -0x4f0(%rbp),%rsi
add    $0x20,%rsi
mov    0x2986(%rip),%rax
mov    (%rax),%ecx
call   1030 <inet_ntop@plt>
mov    %rax,-0x590(%rbp)
mov    -0x4d8(%rbp),%rdi
call   10c0 <ntohs@plt>
mov    -0x594(%rbp),%edi
mov    -0x590(%rbp),%rdx
mov    %eax,%ecx
lea    0xa25(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
jmp    16c7 <main+0x4b7>
mov    -0x578(%rbp),%rdx
mov    0x2954(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5a4(%rbp)
mov    0x2955(%rip),%rax
mov    (%rax),%rdi
lea    -0x4f0(%rbp),%rsi
add    $0x10,%rsi
mov    0x2958(%rip),%rax
mov    (%rax),%ecx
call   1030 <inet_ntop@plt>
mov    %rax,-0x5a0(%rbp)
mov    -0x4e8(%rbp),%rdi
call   10c0 <ntohs@plt>
mov    -0x5a4(%rbp),%edi
mov    -0x5a0(%rbp),%rdx
mov    %eax,%ecx
lea    0x9b7(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x14(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
lea    -0x420(%rbp),%rsi
lea    0x99a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
cmpq   $0x0,-0x548(%rbp)
je     1714 <main+0x504>
mov    -0x548(%rbp),%rdi
call   1120 <freeaddrinfo@plt>
lea    0x983(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x428(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x538,%rsp
cmp    $0x2,%edi
jle    153b <main+0x31b>
mov    0x10(%rsi),%rdi
mov    %rsi,-0x40(%rbp)
call   10f0 <atoi@plt>
mov    %eax,-0x34(%rbp)
mov    %rsp,-0x60(%rbp)
mov    0x2d50(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    0x2d72(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
movl   $0x4,-0x44(%rbp)
lea    -0x158(%rbp),%r13
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1090 <memset@plt>
lea    -0xb8(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1090 <memset@plt>
mov    0x2cd8(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    -0x108(%rbp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1090 <memset@plt>
mov    0x2ce8(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x108(%rbp)
mov    0x2cb7(%rip),%r14
mov    (%r14),%eax
mov    %eax,-0xc0(%rbp)
movq   $0x0,-0xc8(%rbp)
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x30(%rbp),%rcx
xor    %esi,%esi
mov    %r12,%rdx
call   1120 <getaddrinfo@plt>
test   %eax,%eax
jne    1550 <main+0x330>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
mov    (%r14),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,%r14d
mov    -0x30(%rbp),%rax
mov    (%rax),%rcx
mov    0x2c8b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
cmp    %rax,%rcx
mov    %rcx,-0x40(%rbp)
jne    1394 <main+0x174>
mov    %rcx,-0x120(%rbp)
mov    -0x34(%rbp),%edi
call   1060 <htons@plt>
mov    %rax,-0x140(%rbp)
mov    -0x30(%rbp),%rax
mov    0x28(%rax),%rax
mov    0x20(%rax),%eax
mov    %eax,-0x138(%rbp)
mov    $0x4,%r12d
jmp    13d2 <main+0x1b2>
mov    0x2c35(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x88(%rbp)
mov    -0x34(%rbp),%edi
call   1060 <htons@plt>
mov    %rax,-0xb0(%rbp)
mov    -0x30(%rbp),%rax
mov    0x28(%rax),%rax
mov    0x10(%rax),%eax
mov    %eax,-0xa8(%rbp)
mov    $0x6,%r12d
lea    -0xb8(%rbp),%r13
mov    %r14d,%edi
mov    %r13,%rsi
mov    $0x50,%edx
call   1110 <connect@plt>
test   %rax,%rax
js     1569 <main+0x349>
mov    %r15,%r13
lea    0xc9d(%rip),%rdi
call   1050 <puts@plt>
mov    -0x30(%rbp),%rax
mov    0x28(%rax),%rdi
mov    0x2b8f(%rip),%rax
mov    (%rax),%ecx
mov    0x2b9e(%rip),%rax
mov    (%rax),%eax
sub    $0x8,%rsp
mov    $0x50,%esi
mov    %rbx,%rdx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   %rax
call   10b0 <getnameinfo@plt>
add    $0x10,%rsp
test   %eax,%eax
jne    1582 <main+0x362>
lea    0xc1f(%rip),%rdi
mov    %r12d,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
lea    -0x68(%rbp),%r12
lea    -0x44(%rbp),%rdx
mov    %r14d,%edi
mov    %r12,%rsi
call   10e0 <getsockname@plt>
mov    %r14d,%r15d
xor    %r14d,%r14d
mov    -0x50(%rbp),%rax
cmp    %rax,-0x40(%rbp)
sete   %r14b
mov    0x2b48(%rip),%rax
mov    %r13,%rdx
cmove  -0x58(%rbp),%rdx
mov    0x2b49(%rip),%rcx
cmove  0x2b51(%rip),%rcx
mov    (%rax),%r13d
mov    0x2b4f(%rip),%rax
cmove  0x2b07(%rip),%rax
shl    $0x4,%r14
mov    (%rcx),%rdi
lea    (%r14,%r12,1),%rsi
add    $0x10,%rsi
mov    (%rax),%ecx
call   1030 <inet_ntop@plt>
mov    %rax,%rbx
mov    0x8(%r14,%r12,1),%rdi
call   10d0 <ntohs@plt>
lea    0xba0(%rip),%rsi
mov    %r13d,%edi
mov    %rbx,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   10c0 <fprintf@plt>
lea    -0x560(%rbp),%rbx
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
lea    0xb7f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15d,%edi
call   10a0 <close@plt>
mov    -0x30(%rbp),%rdi
test   %rdi,%rdi
je     151a <main+0x2fa>
call   1130 <freeaddrinfo@plt>
lea    0xb7c(%rip),%rdi
call   1050 <puts@plt>
mov    -0x60(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2a7e(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xab2(%rip),%rsi
jmp    159e <main+0x37e>
mov    0x2a69(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1080 <gai_strerror@plt>
lea    0xac1(%rip),%rsi
jmp    1599 <main+0x379>
mov    0x2a50(%rip),%rax
mov    (%rax),%edi
lea    0xac2(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    15a5 <main+0x385>
mov    0x2a37(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1080 <gai_strerror@plt>
lea    0xab2(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    0x29f4(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.in6_addr = type { i32 }
%struct.sockaddr = type { i32 }
%struct.sockaddr_in = type { i64, i8*, i32, i8*, i32, i64, i64, i64, i64, i32 }
%struct.sockaddr_in6 = type { i64, i8*, i32, i8*, i32, i64, i64, i64, i64, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.addrinfo = type { i64, i8*, i32, i8*, i32, i64, i64, i64, i64, i32 }
@stderr = global i32 0
@.str = [40 x i8] c"Bad arguments!\0Ausage: %s <ADDR> <PORT>\0A\00"
@EXIT_FAILURE = global i32 0
@INET_ADDRSTRLEN = global i32 0
@INET6_ADDRSTRLEN = global i32 0
@NI_MAXHOST = global i32 0
@AF_UNSPEC = global i64 0
@SOCK_STREAM = global i32 0
@.str.1 = [19 x i8] c"getaddrinfo(): %s\0A\00"
@AF_INET = global i64 0
@AF_INET6 = global i64 0
@.str.2 = [16 x i8] c"Bad connected.\0A\00"
@.str.3 = [12 x i8] c"Connected.\0A\00"
@NI_NUMERICHOST = global i32 0
@.str.4 = [19 x i8] c"getnameinfo(): %s\0A\00"
@.str.5 = [13 x i8] c"[IPv%d] %s\0A\00"
@.str.6 = [14 x i8] c"[sock %s] %d\0A\00"
@.str.7 = [25 x i8] c"Message from server: %s\0A\00"
@.str.8 = [19 x i8] c"Connection closed\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [1024 x i8]
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca %struct.in6_addr
%13 = alloca %struct.sockaddr*
%14 = alloca %struct.sockaddr_in
%15 = alloca %struct.sockaddr_in6
%16 = alloca i32
%17 = alloca %struct.sockaddr_storage
%18 = alloca %struct.addrinfo
%19 = alloca %struct.addrinfo*
%20 = alloca i32
%21 = alloca i32
%22 = alloca i64
%23 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%24 = load i32, i32* %4
%25 = icmp slt i32 %24, 3
br i1 %25, label %26, label %34
26: ; preds = %2
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %30)
%32 = load i32, i32* @EXIT_FAILURE
%33 = call i32 @exit(i32 %32)
unreachable
34: ; preds = %2
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32 @atoi(i8* %37)
store i32 %38, i32* %7
%39 = load i32, i32* @INET_ADDRSTRLEN
%40 = zext i32 %39 to i64
%41 = call i8* @llvm.stacksave()
store i8* %41, i8** %9
%42 = alloca i8, i64 %40
store i64 %40, i64* %10
%43 = load i32, i32* @INET6_ADDRSTRLEN
%44 = zext i32 %43 to i64
%45 = alloca i8, i64 %44
store i64 %44, i64* %11
store i32 4, i32* %16
%46 = bitcast %struct.sockaddr_in* %14 to %struct.sockaddr_in6*
%47 = call i32 @memset(%struct.sockaddr_in6* %46, i32 0, i32 80)
%48 = call i32 @memset(%struct.sockaddr_in6* %15, i32 0, i32 80)
%49 = load i32, i32* @NI_MAXHOST
%50 = zext i32 %49 to i64
%51 = alloca i8, i64 %50
store i64 %50, i64* %22
%52 = bitcast %struct.addrinfo* %18 to %struct.sockaddr_in6*
%53 = call i32 @memset(%struct.sockaddr_in6* %52, i32 0, i32 80)
%54 = load i64, i64* @AF_UNSPEC
%55 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %18, i32 0, i32 0
store i64 %54, i64* %55
%56 = load i32, i32* @SOCK_STREAM
%57 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %18, i32 0, i32 9
store i32 %56, i32* %57
%58 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %18, i32 0, i32 8
store i64 0, i64* %58
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 1
%61 = load i8*, i8** %60
%62 = bitcast %struct.addrinfo* %18 to %struct.sockaddr_in6*
%63 = bitcast %struct.addrinfo** %19 to %struct.sockaddr_in6**
%64 = call i32 @getaddrinfo(i8* %61, i32* null, %struct.sockaddr_in6* %62, %struct.sockaddr_in6** %63)
store i32 %64, i32* %20
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %73
66: ; preds = %34
%67 = load i32, i32* @stderr
%68 = load i32, i32* %20
%69 = call i8* @gai_strerror(i32 %68)
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %69)
%71 = load i32, i32* @EXIT_FAILURE
%72 = call i32 @exit(i32 %71)
unreachable
73: ; preds = %34
%74 = load %struct.addrinfo*, %struct.addrinfo** %19
%75 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %74, i32 0, i32 0
%76 = load i64, i64* %75
%77 = load i32, i32* @SOCK_STREAM
%78 = call i32 @socket(i64 %76, i32 %77, i32 0)
store i32 %78, i32* %6
%79 = load %struct.addrinfo*, %struct.addrinfo** %19
%80 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %79, i32 0, i32 0
%81 = load i64, i64* %80
%82 = load i64, i64* @AF_INET
%83 = icmp eq i64 %81, %82
br i1 %83, label %84, label %98
84: ; preds = %73
store i32 4, i32* %21
store i32 80, i32* %23
%85 = load i64, i64* @AF_INET
%86 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 7
store i64 %85, i64* %86
%87 = load i32, i32* %7
%88 = call i8* @htons(i32 %87)
%89 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 3
store i8* %88, i8** %89
%90 = load %struct.addrinfo*, %struct.addrinfo** %19
%91 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %90, i32 0, i32 5
%92 = load i64, i64* %91
%93 = inttoptr i64 %92 to %struct.sockaddr_in*
%94 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %93, i32 0, i32 4
%95 = load i32, i32* %94
%96 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 4
store i32 %95, i32* %96
%97 = bitcast %struct.sockaddr_in* %14 to %struct.sockaddr*
store %struct.sockaddr* %97, %struct.sockaddr** %13
br label %112
98: ; preds = %73
store i32 6, i32* %21
store i32 80, i32* %23
%99 = load i64, i64* @AF_INET6
%100 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %15, i32 0, i32 6
store i64 %99, i64* %100
%101 = load i32, i32* %7
%102 = call i8* @htons(i32 %101)
%103 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %15, i32 0, i32 1
store i8* %102, i8** %103
%104 = load %struct.addrinfo*, %struct.addrinfo** %19
%105 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %104, i32 0, i32 5
%106 = load i64, i64* %105
%107 = inttoptr i64 %106 to %struct.sockaddr_in6*
%108 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %107, i32 0, i32 2
%109 = load i32, i32* %108
%110 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %15, i32 0, i32 2
store i32 %109, i32* %110
%111 = bitcast %struct.sockaddr_in6* %15 to %struct.sockaddr*
store %struct.sockaddr* %111, %struct.sockaddr** %13
br label %112
112: ; preds = %98, %84
%113 = load i32, i32* %6
%114 = load %struct.sockaddr*, %struct.sockaddr** %13
%115 = load i32, i32* %23
%116 = call i64 @connect(i32 %113, %struct.sockaddr* %114, i32 %115)
%117 = icmp slt i64 %116, 0
br i1 %117, label %118, label %123
118: ; preds = %112
%119 = load i32, i32* @stderr
%120 = call i32 (i32, i8*, ...) @fprintf(i32 %119, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%121 = load i32, i32* @EXIT_FAILURE
%122 = call i32 @exit(i32 %121)
unreachable
123: ; preds = %112
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%125 = load %struct.addrinfo*, %struct.addrinfo** %19
%126 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %125, i32 0, i32 5
%127 = load i64, i64* %126
%128 = inttoptr i64 %127 to %struct.sockaddr*
%129 = load i32, i32* %23
%130 = load i32, i32* @NI_MAXHOST
%131 = load i32, i32* @NI_NUMERICHOST
%132 = call i32 @getnameinfo(%struct.sockaddr* %128, i32 %129, i8* %51, i32 %130, i32* null, i32 0, i32 %131)
store i32 %132, i32* %20
%133 = load i32, i32* %20
%134 = icmp ne i32 %133, 0
br i1 %134, label %135, label %142
135: ; preds = %123
%136 = load i32, i32* @stderr
%137 = load i32, i32* %20
%138 = call i8* @gai_strerror(i32 %137)
%139 = call i32 (i32, i8*, ...) @fprintf(i32 %136, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %138)
%140 = load i32, i32* @EXIT_FAILURE
%141 = call i32 @exit(i32 %140)
unreachable
142: ; preds = %123
%143 = load i32, i32* %21
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %143, i8* %51)
%145 = load i32, i32* %6
%146 = bitcast %struct.sockaddr_storage* %17 to %struct.sockaddr*
%147 = call i32 @getsockname(i32 %145, %struct.sockaddr* %146, i32* %16)
%148 = load i32, i32* %21
%149 = icmp eq i32 %148, 4
br i1 %149, label %150, label %162
150: ; preds = %142
%151 = load i32, i32* @stderr
%152 = load i64, i64* @AF_INET
%153 = bitcast %struct.sockaddr_storage* %17 to %struct.sockaddr_in*
%154 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %153, i32 0, i32 4
%155 = load i32, i32* @INET_ADDRSTRLEN
%156 = call i8* @inet_ntop(i64 %152, i32* %154, i8* %42, i32 %155)
%157 = bitcast %struct.sockaddr_storage* %17 to %struct.sockaddr_in*
%158 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %157, i32 0, i32 3
%159 = load i8*, i8** %158
%160 = call i32 @ntohs(i8* %159)
%161 = call i32 (i32, i8*, ...) @fprintf(i32 %151, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %156, i32 %160)
br label %174
162: ; preds = %142
%163 = load i32, i32* @stderr
%164 = load i64, i64* @AF_INET6
%165 = bitcast %struct.sockaddr_storage* %17 to %struct.sockaddr_in6*
%166 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %165, i32 0, i32 2
%167 = load i32, i32* @INET6_ADDRSTRLEN
%168 = call i8* @inet_ntop(i64 %164, i32* %166, i8* %45, i32 %167)
%169 = bitcast %struct.sockaddr_storage* %17 to %struct.sockaddr_in6*
%170 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %169, i32 0, i32 1
%171 = load i8*, i8** %170
%172 = call i32 @ntohs(i8* %171)
%173 = call i32 (i32, i8*, ...) @fprintf(i32 %163, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %168, i32 %172)
br label %174
174: ; preds = %162, %150
%175 = load i32, i32* %6
%176 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%177 = call i32 @recv(i32 %175, i8* %176, i32 1024, i32 0)
%178 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%179 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %178)
%180 = load i32, i32* %6
%181 = call i32 @close(i32 %180)
%182 = load %struct.addrinfo*, %struct.addrinfo** %19
%183 = icmp ne %struct.addrinfo* %182, null
br i1 %183, label %184, label %188
184: ; preds = %174
%185 = load %struct.addrinfo*, %struct.addrinfo** %19
%186 = bitcast %struct.addrinfo* %185 to %struct.sockaddr_in6*
%187 = call i32 @freeaddrinfo(%struct.sockaddr_in6* %186)
br label %188
188: ; preds = %184, %174
%189 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %3
%190 = load i8*, i8** %9
%191 = load i32, i32* %3
ret i32 %191
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i64, i8*, i32, i8*, i32, i64, i64, i64, i64, i32 }
%struct.sockaddr_in6 = type { i64, i8*, i32, i8*, i32, i64, i64, i64, i64, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.addrinfo = type { i64, i8*, i32, i8*, i32, i64, i64, i64, i64, i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [40 x i8] c"Bad arguments!\0Ausage: %s <ADDR> <PORT>\0A\00"
@EXIT_FAILURE = global i32 0
@INET_ADDRSTRLEN = global i32 0
@INET6_ADDRSTRLEN = global i32 0
@NI_MAXHOST = global i32 0
@AF_UNSPEC = global i64 0
@SOCK_STREAM = global i32 0
@.str.1 = [19 x i8] c"getaddrinfo(): %s\0A\00"
@AF_INET = global i64 0
@AF_INET6 = global i64 0
@.str.2 = [16 x i8] c"Bad connected.\0A\00"
@NI_NUMERICHOST = global i32 0
@.str.4 = [19 x i8] c"getnameinfo(): %s\0A\00"
@.str.5 = [13 x i8] c"[IPv%d] %s\0A\00"
@.str.6 = [14 x i8] c"[sock %s] %d\0A\00"
@.str.7 = [25 x i8] c"Message from server: %s\0A\00"
@str = [11 x i8] c"Connected.\00"
@str.9 = [18 x i8] c"Connection closed\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca %struct.sockaddr_in
%5 = alloca %struct.sockaddr_in6
%6 = alloca i32
%7 = alloca %struct.sockaddr_storage
%8 = alloca %struct.addrinfo
%9 = alloca %struct.addrinfo*
%10 = icmp slt i32 %0, 3
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %1
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32 @atoi(i8* %19)
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%22 = load i32, i32* @INET_ADDRSTRLEN
%23 = zext i32 %22 to i64
%24 = tail call i8* @llvm.stacksave()
%25 = alloca i8, i64 %23
%26 = load i32, i32* @INET6_ADDRSTRLEN
%27 = zext i32 %26 to i64
%28 = alloca i8, i64 %27
%29 = bitcast %struct.sockaddr_in* %4 to i8*
%30 = bitcast %struct.sockaddr_in6* %5 to i8*
%31 = bitcast i32* %6 to i8*
store i32 4, i32* %6
%32 = bitcast %struct.sockaddr_storage* %7 to i8*
%33 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr_in6*
%34 = call i32 @memset(%struct.sockaddr_in6* %33, i32 0, i32 80)
%35 = call i32 @memset(%struct.sockaddr_in6* %5, i32 0, i32 80)
%36 = bitcast %struct.addrinfo* %8 to i8*
%37 = bitcast %struct.addrinfo** %9 to i8*
%38 = load i32, i32* @NI_MAXHOST
%39 = zext i32 %38 to i64
%40 = alloca i8, i64 %39
%41 = bitcast %struct.addrinfo* %8 to %struct.sockaddr_in6*
%42 = call i32 @memset(%struct.sockaddr_in6* %41, i32 0, i32 80)
%43 = load i64, i64* @AF_UNSPEC
%44 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i64 0, i32 0
store i64 %43, i64* %44
%45 = load i32, i32* @SOCK_STREAM
%46 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i64 0, i32 9
store i32 %45, i32* %46
%47 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i64 0, i32 8
store i64 0, i64* %47
%48 = getelementptr inbounds i8*, i8** %1, i64 1
%49 = load i8*, i8** %48
%50 = bitcast %struct.addrinfo** %9 to %struct.sockaddr_in6**
%51 = call i32 @getaddrinfo(i8* %49, i32* null, %struct.sockaddr_in6* %41, %struct.sockaddr_in6** %50)
%52 = icmp eq i32 %51, 0
br i1 %52, label %59, label %53
53: ; preds = %17
%54 = load i32, i32* @stderr
%55 = call i8* @gai_strerror(i32 %51)
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %55)
%57 = load i32, i32* @EXIT_FAILURE
%58 = call i32 @exit(i32 %57)
unreachable
59: ; preds = %17
%60 = load %struct.addrinfo*, %struct.addrinfo** %9
%61 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %60, i64 0, i32 0
%62 = load i64, i64* %61
%63 = load i32, i32* @SOCK_STREAM
%64 = call i32 @socket(i64 %62, i32 %63, i32 0)
%65 = load %struct.addrinfo*, %struct.addrinfo** %9
%66 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %65, i64 0, i32 0
%67 = load i64, i64* %66
%68 = load i64, i64* @AF_INET
%69 = icmp eq i64 %67, %68
br i1 %69, label %70, label %82
70: ; preds = %59
%71 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 7
store i64 %67, i64* %71
%72 = call i8* @htons(i32 %20)
%73 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 3
store i8* %72, i8** %73
%74 = load %struct.addrinfo*, %struct.addrinfo** %9
%75 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %74, i64 0, i32 5
%76 = load i64, i64* %75
%77 = inttoptr i64 %76 to %struct.sockaddr_in*
%78 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %77, i64 0, i32 4
%79 = load i32, i32* %78
%80 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 4
store i32 %79, i32* %80
%81 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
br label %95
82: ; preds = %59
%83 = load i64, i64* @AF_INET6
%84 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %5, i64 0, i32 6
store i64 %83, i64* %84
%85 = call i8* @htons(i32 %20)
%86 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %5, i64 0, i32 1
store i8* %85, i8** %86
%87 = load %struct.addrinfo*, %struct.addrinfo** %9
%88 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %87, i64 0, i32 5
%89 = load i64, i64* %88
%90 = inttoptr i64 %89 to %struct.sockaddr_in6*
%91 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %90, i64 0, i32 2
%92 = load i32, i32* %91
%93 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %5, i64 0, i32 2
store i32 %92, i32* %93
%94 = bitcast %struct.sockaddr_in6* %5 to %struct.sockaddr*
br label %95
95: ; preds = %82, %70
%96 = phi %struct.sockaddr* [ %81, %70 ], [ %94, %82 ]
%97 = phi i32 [ 4, %70 ], [ 6, %82 ]
%98 = call i64 @connect(i32 %64, %struct.sockaddr* %96, i32 80)
%99 = icmp slt i64 %98, 0
br i1 %99, label %100, label %105
100: ; preds = %95
%101 = load i32, i32* @stderr
%102 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%103 = load i32, i32* @EXIT_FAILURE
%104 = call i32 @exit(i32 %103)
unreachable
105: ; preds = %95
%106 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%107 = load %struct.addrinfo*, %struct.addrinfo** %9
%108 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %107, i64 0, i32 5
%109 = load i64, i64* %108
%110 = inttoptr i64 %109 to %struct.sockaddr*
%111 = load i32, i32* @NI_MAXHOST
%112 = load i32, i32* @NI_NUMERICHOST
%113 = call i32 @getnameinfo(%struct.sockaddr* %110, i32 80, i8* %40, i32 %111, i32* null, i32 0, i32 %112)
%114 = icmp eq i32 %113, 0
br i1 %114, label %121, label %115
115: ; preds = %105
%116 = load i32, i32* @stderr
%117 = call i8* @gai_strerror(i32 %113)
%118 = call i32 (i32, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %117)
%119 = load i32, i32* @EXIT_FAILURE
%120 = call i32 @exit(i32 %119)
unreachable
121: ; preds = %105
%122 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %97, i8* %40)
%123 = bitcast %struct.sockaddr_storage* %7 to %struct.sockaddr*
%124 = call i32 @getsockname(i32 %64, %struct.sockaddr* %123, i32* %6)
%125 = load i32, i32* @stderr
%126 = select i1 %69, i64 8, i64 4
%127 = select i1 %69, i8* %25, i8* %28
%128 = select i1 %69, i64 6, i64 2
%129 = load i64, i64* @AF_INET
%130 = load i64, i64* @AF_INET6
%131 = select i1 %69, i64 %129, i64 %130
%132 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %7, i64 %126, i32 0
%133 = load i32, i32* @INET_ADDRSTRLEN
%134 = load i32, i32* @INET6_ADDRSTRLEN
%135 = select i1 %69, i32 %133, i32 %134
%136 = call i8* @inet_ntop(i64 %131, i32* %132, i8* %127, i32 %135)
%137 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %7, i64 %128
%138 = bitcast %struct.sockaddr_storage* %137 to i8**
%139 = load i8*, i8** %138
%140 = call i32 @ntohs(i8* %139)
%141 = call i32 (i32, i8*, ...) @fprintf(i32 %125, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %136, i32 %140)
%142 = call i32 @recv(i32 %64, i8* %21, i32 1024, i32 0)
%143 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %21)
%144 = call i32 @close(i32 %64)
%145 = load %struct.addrinfo*, %struct.addrinfo** %9
%146 = icmp eq %struct.addrinfo* %145, null
br i1 %146, label %150, label %147
147: ; preds = %121
%148 = bitcast %struct.addrinfo* %145 to %struct.sockaddr_in6*
%149 = call i32 @freeaddrinfo(%struct.sockaddr_in6* %148)
br label %150
150: ; preds = %147, %121
%151 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.9, i64 0, i64 0))
ret i32 0
}