#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 {
  int dummy;
};
struct addrinfo {
  scalar_t__ ai_addr;
  int /*<<< orphan*/ ai_family;
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  struct addrinfo *ai_next;
};

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int INET6_ADDRSTRLEN;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int connect(int, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int /*<<< orphan*/ get_in_addr(struct sockaddr *);
int getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
int /*<<< orphan*/ inet_ntop(int /*<<< orphan*/, int /*<<< orphan*/, char *,
                             int);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int recv(int, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int sockfd, numbytes;
  char buf[100];
  struct addrinfo hints, *servinfo, *p;
  int rv;
  char s[INET6_ADDRSTRLEN];
  if (argc != 3) {
    fprintf(stderr, "usage: client hostname port\n");
    exit(1);
  }
  memset(&hints, 0, sizeof hints);
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  if ((rv = getaddrinfo(argv[1], argv[2], &hints, &servinfo)) != 0) {
    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
    return 1;
  }
  for (p = servinfo; p != NULL; p = p->ai_next) {
    if ((sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) {
      perror("client: socket");
      continue;
    }
    if (connect(sockfd, p->ai_addr, p->ai_addrlen) == -1) {
      close(sockfd);
      perror("client: connect");
      continue;
    }
    break;
  }
  if (p == NULL) {
    fprintf(stderr, "client: failed to connect\n");
    return 2;
  }
  inet_ntop(p->ai_family, get_in_addr((struct sockaddr *)p->ai_addr), s,
            sizeof s);
  printf("client: connecting to %s\n", s);
  freeaddrinfo(servinfo);
  if ((numbytes = recv(sockfd, buf, 100 - 1, 0)) == -1) {
    perror("recv");
    exit(1);
  }
  buf[numbytes] = '\0';
  printf("client: received '%s'\n", buf);
  close(sockfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2de8(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0xe0(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0xc0(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xd8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xc8(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1260 <main+0x80>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
lea    0xdb1(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1080 <memset@plt>
mov    0x2d66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x98(%rbp)
mov    0x2d3f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    -0xa0(%rbp),%rdx
lea    -0xa8(%rbp),%rcx
call   10e0 <getaddrinfo@plt>
mov    %eax,-0xb4(%rbp)
cmp    $0x0,%eax
je     130a <main+0x12a>
mov    0x2d06(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xe4(%rbp)
mov    -0xb4(%rbp),%edi
call   1070 <gai_strerror@plt>
mov    -0xe4(%rbp),%edi
mov    %rax,%rdx
lea    0xd30(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0xcc(%rbp)
jmp    14bd <main+0x2dd>
mov    -0xa8(%rbp),%rax
mov    %rax,-0xb0(%rbp)
cmpq   $0x0,-0xb0(%rbp)
je     13c0 <main+0x1e0>
mov    -0xb0(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0xb0(%rbp),%rax
mov    0x14(%rax),%esi
mov    -0xb0(%rbp),%rax
mov    0x10(%rax),%edx
call   1100 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    1366 <main+0x186>
lea    0xcd2(%rip),%rdi
call   10b0 <perror@plt>
jmp    13a9 <main+0x1c9>
mov    -0x14(%rbp),%edi
mov    -0xb0(%rbp),%rax
mov    (%rax),%rsi
mov    -0xb0(%rbp),%rax
mov    0xc(%rax),%edx
call   10d0 <connect@plt>
cmp    $0xffffffff,%eax
jne    13a4 <main+0x1c4>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
lea    0xca3(%rip),%rdi
call   10b0 <perror@plt>
jmp    13a9 <main+0x1c9>
jmp    13c0 <main+0x1e0>
mov    -0xb0(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0xb0(%rbp)
jmp    1318 <main+0x138>
cmpq   $0x0,-0xb0(%rbp)
jne    13fb <main+0x21b>
mov    0x2bfb(%rip),%rax
mov    (%rax),%edi
lea    0xc6f(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0xcc(%rbp)
jmp    14bd <main+0x2dd>
mov    -0xb0(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0xe8(%rbp)
mov    -0xb0(%rbp),%rax
mov    (%rax),%rdi
call   1050 <get_in_addr@plt>
mov    -0xe8(%rbp),%edi
mov    -0xd8(%rbp),%rdx
mov    %eax,%esi
mov    -0xe0(%rbp),%rax
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    -0xd8(%rbp),%rsi
lea    0xc23(%rip),%rdi
call   1060 <printf@plt>
mov    -0xa8(%rbp),%rdi
call   10f0 <freeaddrinfo@plt>
mov    -0x14(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    $0x63,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    148b <main+0x2ab>
lea    0xc06(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x80(%rbp,%rax,1)
lea    -0x80(%rbp),%rsi
lea    0xbe8(%rip),%rdi
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xcc(%rbp)
mov    -0xc0(%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    $0x98,%rsp
mov    %rsp,%r13
mov    0x2dea(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%r12
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
cmp    $0x3,%edi
jne    139b <main+0x1bb>
mov    %rsi,%rbx
lea    -0x58(%rbp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1080 <memset@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2d84(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%rsi
lea    -0x38(%rbp),%rcx
mov    %r15,%rdx
call   10e0 <getaddrinfo@plt>
test   %eax,%eax
je     128e <main+0xae>
mov    0x2d68(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1070 <gai_strerror@plt>
lea    0xda5(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%ebx
jmp    1387 <main+0x1a7>
mov    %r13,-0x30(%rbp)
mov    -0x38(%rbp),%r13
test   %r13,%r13
je     12ef <main+0x10f>
lea    0xd8c(%rip),%rbx
mov    0x14(%r13),%esi
mov    0x8(%r13),%edi
mov    0x10(%r13),%edx
call   1100 <socket@plt>
mov    %rbx,%rdi
cmp    $0xffffffff,%eax
je     12e1 <main+0x101>
mov    %eax,%r15d
mov    0x0(%r13),%rsi
mov    0xc(%r13),%edx
mov    %eax,%edi
call   10d0 <connect@plt>
cmp    $0xffffffff,%eax
jne    130d <main+0x12d>
mov    %r15d,%edi
call   1090 <close@plt>
lea    0xd5c(%rip),%rdi
call   10b0 <perror@plt>
mov    0x18(%r13),%r13
test   %r13,%r13
jne    12a2 <main+0xc2>
mov    0x2cda(%rip),%rax
mov    (%rax),%edi
lea    0xd4e(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x2,%ebx
jmp    1383 <main+0x1a3>
mov    0x8(%r13),%ebx
mov    0x0(%r13),%rdi
call   1050 <get_in_addr@plt>
mov    %ebx,%edi
mov    %eax,%esi
mov    %r12,%rdx
mov    %r14d,%ecx
call   1030 <inet_ntop@plt>
lea    0xd38(%rip),%rdi
mov    %r12,%rsi
call   1060 <printf@plt>
mov    -0x38(%rbp),%rdi
call   10f0 <freeaddrinfo@plt>
lea    -0xc0(%rbp),%rsi
xor    %ebx,%ebx
mov    %r15d,%edi
mov    $0x63,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
cmp    $0xffffffff,%eax
je     13bc <main+0x1dc>
cltq
movb   $0x0,-0xc0(%rbp,%rax,1)
lea    0xd18(%rip),%rdi
lea    -0xc0(%rbp),%rsi
call   1060 <printf@plt>
mov    %r15d,%edi
call   1090 <close@plt>
mov    -0x30(%rbp),%r13
mov    %r13,%rsp
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c2e(%rip),%rax
mov    (%rax),%edi
lea    0xc55(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    0xcbf(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.addrinfo = type { i64, i32, i32, i32, i32, %struct.addrinfo* }
%struct.sockaddr = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@stderr = global i32 0
@.str = [29 x i8] c"usage: client hostname port\0A\00"
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.2 = [15 x i8] c"client: socket\00"
@.str.3 = [16 x i8] c"client: connect\00"
@.str.4 = [27 x i8] c"client: failed to connect\0A\00"
@.str.5 = [26 x i8] c"client: connecting to %s\0A\00"
@.str.6 = [5 x i8] c"recv\00"
@.str.7 = [23 x i8] c"client: received '%s'\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 [100 x i8]
%9 = alloca %struct.addrinfo
%10 = alloca %struct.addrinfo*
%11 = alloca %struct.addrinfo*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* @INET6_ADDRSTRLEN
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %13
%19 = alloca i8, i64 %17
store i64 %17, i64* %14
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 3
br i1 %21, label %22, label %26
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = call i32 @memset(%struct.addrinfo* %9, i32 0, i32 32)
%28 = load i32, i32* @AF_UNSPEC
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, i32 0, i32 1
store i32 %28, i32* %29
%30 = load i32, i32* @SOCK_STREAM
%31 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, i32 0, i32 4
store i32 %30, i32* %31
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32 @getaddrinfo(i8* %34, i8* %37, %struct.addrinfo* %9, %struct.addrinfo** %10)
store i32 %38, i32* %12
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %45
40: ; preds = %26
%41 = load i32, i32* @stderr
%42 = load i32, i32* %12
%43 = call i8* @gai_strerror(i32 %42)
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %43)
store i32 1, i32* %3
store i32 1, i32* %15
br label %118
45: ; preds = %26
%46 = load %struct.addrinfo*, %struct.addrinfo** %10
store %struct.addrinfo* %46, %struct.addrinfo** %11
br label %47
47: ; preds = %79, %45
%48 = load %struct.addrinfo*, %struct.addrinfo** %11
%49 = icmp ne %struct.addrinfo* %48, null
br i1 %49, label %50, label %83
50: ; preds = %47
%51 = load %struct.addrinfo*, %struct.addrinfo** %11
%52 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %51, i32 0, i32 1
%53 = load i32, i32* %52
%54 = load %struct.addrinfo*, %struct.addrinfo** %11
%55 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %54, i32 0, i32 4
%56 = load i32, i32* %55
%57 = load %struct.addrinfo*, %struct.addrinfo** %11
%58 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %57, i32 0, i32 3
%59 = load i32, i32* %58
%60 = call i32 @socket(i32 %53, i32 %56, i32 %59)
store i32 %60, i32* %6
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %64
62: ; preds = %50
%63 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %79
64: ; preds = %50
%65 = load i32, i32* %6
%66 = load %struct.addrinfo*, %struct.addrinfo** %11
%67 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %66, i32 0, i32 0
%68 = load i64, i64* %67
%69 = load %struct.addrinfo*, %struct.addrinfo** %11
%70 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %69, i32 0, i32 2
%71 = load i32, i32* %70
%72 = call i32 @connect(i32 %65, i64 %68, i32 %71)
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %78
74: ; preds = %64
%75 = load i32, i32* %6
%76 = call i32 @close(i32 %75)
%77 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %79
78: ; preds = %64
br label %83
79: ; preds = %74, %62
%80 = load %struct.addrinfo*, %struct.addrinfo** %11
%81 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %80, i32 0, i32 5
%82 = load %struct.addrinfo*, %struct.addrinfo** %81
store %struct.addrinfo* %82, %struct.addrinfo** %11
br label %47
83: ; preds = %78, %47
%84 = load %struct.addrinfo*, %struct.addrinfo** %11
%85 = icmp eq %struct.addrinfo* %84, null
br i1 %85, label %86, label %89
86: ; preds = %83
%87 = load i32, i32* @stderr
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
store i32 2, i32* %3
store i32 1, i32* %15
br label %118
89: ; preds = %83
%90 = load %struct.addrinfo*, %struct.addrinfo** %11
%91 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %90, i32 0, i32 1
%92 = load i32, i32* %91
%93 = load %struct.addrinfo*, %struct.addrinfo** %11
%94 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %93, i32 0, i32 0
%95 = load i64, i64* %94
%96 = inttoptr i64 %95 to %struct.sockaddr*
%97 = call i32 @get_in_addr(%struct.sockaddr* %96)
%98 = trunc i64 %17 to i32
%99 = call i32 @inet_ntop(i32 %92, i32 %97, i8* %19, i32 %98)
%100 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %19)
%101 = load %struct.addrinfo*, %struct.addrinfo** %10
%102 = call i32 @freeaddrinfo(%struct.addrinfo* %101)
%103 = load i32, i32* %6
%104 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%105 = call i32 @recv(i32 %103, i8* %104, i32 99, i32 0)
store i32 %105, i32* %7
%106 = icmp eq i32 %105, -1
br i1 %106, label %107, label %110
107: ; preds = %89
%108 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%109 = call i32 @exit(i32 1)
unreachable
110: ; preds = %89
%111 = load i32, i32* %7
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 %112
store i8 0, i8* %113
%114 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%115 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* %114)
%116 = load i32, i32* %6
%117 = call i32 @close(i32 %116)
store i32 0, i32* %3
store i32 1, i32* %15
br label %118
118: ; preds = %110, %86, %40
%119 = load i8*, i8** %13
%120 = load i32, i32* %3
ret i32 %120
}

LLVM IR (-O2):
%struct.addrinfo = type { i64, i32, i32, i32, i32, %struct.addrinfo* }
%struct.sockaddr = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@stderr = global i32 0
@.str = [29 x i8] c"usage: client hostname port\0A\00"
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.2 = [15 x i8] c"client: socket\00"
@.str.3 = [16 x i8] c"client: connect\00"
@.str.4 = [27 x i8] c"client: failed to connect\0A\00"
@.str.5 = [26 x i8] c"client: connecting to %s\0A\00"
@.str.6 = [5 x i8] c"recv\00"
@.str.7 = [23 x i8] c"client: received '%s'\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = alloca %struct.addrinfo
%5 = alloca %struct.addrinfo*
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = bitcast %struct.addrinfo* %4 to i8*
%8 = bitcast %struct.addrinfo** %5 to i8*
%9 = load i32, i32* @INET6_ADDRSTRLEN
%10 = zext i32 %9 to i64
%11 = tail call i8* @llvm.stacksave()
%12 = alloca i8, i64 %10
%13 = icmp eq i32 %0, 3
br i1 %13, label %18, label %14
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = call i32 @memset(%struct.addrinfo* %4, i32 0, i32 32)
%20 = load i32, i32* @AF_UNSPEC
%21 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 1
store i32 %20, i32* %21
%22 = load i32, i32* @SOCK_STREAM
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 4
store i32 %22, i32* %23
%24 = getelementptr inbounds i8*, i8** %1, i64 1
%25 = load i8*, i8** %24
%26 = getelementptr inbounds i8*, i8** %1, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @getaddrinfo(i8* %25, i8* %27, %struct.addrinfo* %4, %struct.addrinfo** %5)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %18
%31 = load %struct.addrinfo*, %struct.addrinfo** %5
%32 = icmp eq %struct.addrinfo* %31, null
br i1 %32, label %62, label %37
33: ; preds = %18
%34 = load i32, i32* @stderr
%35 = call i8* @gai_strerror(i32 %28)
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %35)
br label %86
37: ; preds = %30, %56
%38 = phi %struct.addrinfo* [ %60, %56 ], [ %31, %30 ]
%39 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %38, i64 0, i32 1
%40 = load i32, i32* %39
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %38, i64 0, i32 4
%42 = load i32, i32* %41
%43 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %38, i64 0, i32 3
%44 = load i32, i32* %43
%45 = call i32 @socket(i32 %40, i32 %42, i32 %44)
%46 = icmp eq i32 %45, -1
br i1 %46, label %56, label %47
47: ; preds = %37
%48 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %38, i64 0, i32 0
%49 = load i64, i64* %48
%50 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %38, i64 0, i32 2
%51 = load i32, i32* %50
%52 = call i32 @connect(i32 %45, i64 %49, i32 %51)
%53 = icmp eq i32 %52, -1
br i1 %53, label %54, label %65
54: ; preds = %47
%55 = call i32 @close(i32 %45)
br label %56
56: ; preds = %37, %54
%57 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), %54 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), %37 ]
%58 = call i32 @perror(i8* %57)
%59 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %38, i64 0, i32 5
%60 = load %struct.addrinfo*, %struct.addrinfo** %59
%61 = icmp eq %struct.addrinfo* %60, null
br i1 %61, label %62, label %37
62: ; preds = %56, %30
%63 = load i32, i32* @stderr
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
br label %86
65: ; preds = %47
%66 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %38, i64 0, i32 1
%67 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %38, i64 0, i32 0
%68 = load i32, i32* %66
%69 = load i64, i64* %67
%70 = inttoptr i64 %69 to %struct.sockaddr*
%71 = call i32 @get_in_addr(%struct.sockaddr* %70)
%72 = call i32 @inet_ntop(i32 %68, i32 %71, i8* %12, i32 %9)
%73 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %12)
%74 = load %struct.addrinfo*, %struct.addrinfo** %5
%75 = call i32 @freeaddrinfo(%struct.addrinfo* %74)
%76 = call i32 @recv(i32 %45, i8* %6, i32 99, i32 0)
%77 = icmp eq i32 %76, -1
br i1 %77, label %78, label %81
78: ; preds = %65
%79 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%80 = call i32 @exit(i32 1)
unreachable
81: ; preds = %65
%82 = sext i32 %76 to i64
%83 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %82
store i8 0, i8* %83
%84 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* %6)
%85 = call i32 @close(i32 %45)
br label %86
86: ; preds = %81, %62, %33
%87 = phi i32 [ 1, %33 ], [ 2, %62 ], [ 0, %81 ]
ret i32 %87
}