#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 /*<<< 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[256];
  if (argc != 2) {
    fprintf(stderr, "usage: client hostname\n");
    exit(1);
  }
  memset(&hints, 0, sizeof hints);
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  if ((rv = getaddrinfo(argv[1], "3490", &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    $0x1d0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1224 <main+0x44>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
lea    0xded(%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    0x2daa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x98(%rbp)
mov    0x2d83(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdb4(%rip),%rsi
lea    -0xa0(%rbp),%rdx
lea    -0xa8(%rbp),%rcx
call   10e0 <getaddrinfo@plt>
mov    %eax,-0xb4(%rbp)
cmp    $0x0,%eax
je     12c3 <main+0xe3>
mov    0x2d4b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c4(%rbp)
mov    -0xb4(%rbp),%edi
call   1070 <gai_strerror@plt>
mov    -0x1c4(%rbp),%edi
mov    %rax,%rdx
lea    0xd6d(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    145e <main+0x27e>
mov    -0xa8(%rbp),%rax
mov    %rax,-0xb0(%rbp)
cmpq   $0x0,-0xb0(%rbp)
je     1379 <main+0x199>
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    131f <main+0x13f>
lea    0xd19(%rip),%rdi
call   10b0 <perror@plt>
jmp    1362 <main+0x182>
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    135d <main+0x17d>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
lea    0xcea(%rip),%rdi
call   10b0 <perror@plt>
jmp    1362 <main+0x182>
jmp    1379 <main+0x199>
mov    -0xb0(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0xb0(%rbp)
jmp    12d1 <main+0xf1>
cmpq   $0x0,-0xb0(%rbp)
jne    13aa <main+0x1ca>
mov    0x2c4a(%rip),%rax
mov    (%rax),%edi
lea    0xcb6(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    145e <main+0x27e>
mov    -0xb0(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x1c8(%rbp)
mov    -0xb0(%rbp),%rax
mov    (%rax),%rdi
call   1050 <get_in_addr@plt>
mov    -0x1c8(%rbp),%edi
mov    %eax,%esi
lea    -0x1c0(%rbp),%rdx
mov    $0x100,%ecx
call   1030 <inet_ntop@plt>
lea    -0x1c0(%rbp),%rsi
lea    0xc78(%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    1436 <main+0x256>
lea    0xc5b(%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    0xc3d(%rip),%rdi
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x1a8,%rsp
cmp    $0x2,%edi
jne    1372 <main+0x192>
mov    %rsi,%rbx
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1080 <memset@plt>
mov    0x2dd4(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x24(%rsp)
mov    0x8(%rbx),%rdi
lea    0xde6(%rip),%rsi
lea    0x8(%rsp),%rcx
mov    %rbp,%rdx
call   10e0 <getaddrinfo@plt>
test   %eax,%eax
je     1270 <main+0x90>
mov    0x2d8e(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1070 <gai_strerror@plt>
lea    0xdc3(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%ebp
jmp    1362 <main+0x182>
mov    0x8(%rsp),%rbp
test   %rbp,%rbp
je     12cb <main+0xeb>
lea    0xdad(%rip),%r14
lea    0xdb5(%rip),%r15
mov    0x14(%rbp),%esi
mov    0x8(%rbp),%edi
mov    0x10(%rbp),%edx
call   1100 <socket@plt>
mov    %r14,%rdi
cmp    $0xffffffff,%eax
je     12bd <main+0xdd>
mov    %eax,%ebx
mov    0x0(%rbp),%rsi
mov    0xc(%rbp),%edx
mov    %eax,%edi
call   10d0 <connect@plt>
cmp    $0xffffffff,%eax
jne    12e9 <main+0x109>
mov    %ebx,%edi
call   1090 <close@plt>
mov    %r15,%rdi
call   10b0 <perror@plt>
mov    0x18(%rbp),%rbp
test   %rbp,%rbp
jne    1288 <main+0xa8>
mov    0x2d06(%rip),%rax
mov    (%rax),%edi
lea    0xd72(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x2,%ebp
jmp    1362 <main+0x182>
mov    0x8(%rbp),%r15d
mov    0x0(%rbp),%rdi
call   1050 <get_in_addr@plt>
lea    0xa0(%rsp),%r14
mov    %r15d,%edi
mov    %eax,%esi
mov    %r14,%rdx
mov    $0x100,%ecx
call   1030 <inet_ntop@plt>
lea    0xd51(%rip),%rdi
mov    %r14,%rsi
call   1060 <printf@plt>
mov    0x8(%rsp),%rdi
call   10f0 <freeaddrinfo@plt>
lea    0x30(%rsp),%rsi
xor    %ebp,%ebp
mov    %ebx,%edi
mov    $0x63,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
cmp    $0xffffffff,%eax
je     1393 <main+0x1b3>
cltq
movb   $0x0,0x30(%rsp,%rax,1)
lea    0xd36(%rip),%rdi
lea    0x30(%rsp),%rsi
call   1060 <printf@plt>
mov    %ebx,%edi
call   1090 <close@plt>
mov    %ebp,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c5f(%rip),%rax
mov    (%rax),%edi
lea    0xc7e(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    0xce8(%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 }
@stderr = global i32 0
@.str = [24 x i8] c"usage: client hostname\0A\00"
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [5 x i8] c"3490\00"
@.str.2 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.3 = [15 x i8] c"client: socket\00"
@.str.4 = [16 x i8] c"client: connect\00"
@.str.5 = [27 x i8] c"client: failed to connect\0A\00"
@.str.6 = [26 x i8] c"client: connecting to %s\0A\00"
@.str.7 = [5 x i8] c"recv\00"
@.str.8 = [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 [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 2
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = call i32 @memset(%struct.addrinfo* %9, i32 0, i32 32)
%22 = load i32, i32* @AF_UNSPEC
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, i32 0, i32 1
store i32 %22, i32* %23
%24 = load i32, i32* @SOCK_STREAM
%25 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, i32 0, i32 4
store i32 %24, i32* %25
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @getaddrinfo(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %struct.addrinfo* %9, %struct.addrinfo** %10)
store i32 %29, i32* %12
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %20
%32 = load i32, i32* @stderr
%33 = load i32, i32* %12
%34 = call i8* @gai_strerror(i32 %33)
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %34)
store i32 1, i32* %3
br label %110
36: ; preds = %20
%37 = load %struct.addrinfo*, %struct.addrinfo** %10
store %struct.addrinfo* %37, %struct.addrinfo** %11
br label %38
38: ; preds = %70, %36
%39 = load %struct.addrinfo*, %struct.addrinfo** %11
%40 = icmp ne %struct.addrinfo* %39, null
br i1 %40, label %41, label %74
41: ; preds = %38
%42 = load %struct.addrinfo*, %struct.addrinfo** %11
%43 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %42, i32 0, i32 1
%44 = load i32, i32* %43
%45 = load %struct.addrinfo*, %struct.addrinfo** %11
%46 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %45, i32 0, i32 4
%47 = load i32, i32* %46
%48 = load %struct.addrinfo*, %struct.addrinfo** %11
%49 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %48, i32 0, i32 3
%50 = load i32, i32* %49
%51 = call i32 @socket(i32 %44, i32 %47, i32 %50)
store i32 %51, i32* %6
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %55
53: ; preds = %41
%54 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %70
55: ; preds = %41
%56 = load i32, i32* %6
%57 = load %struct.addrinfo*, %struct.addrinfo** %11
%58 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %57, i32 0, i32 0
%59 = load i64, i64* %58
%60 = load %struct.addrinfo*, %struct.addrinfo** %11
%61 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %60, i32 0, i32 2
%62 = load i32, i32* %61
%63 = call i32 @connect(i32 %56, i64 %59, i32 %62)
%64 = icmp eq i32 %63, -1
br i1 %64, label %65, label %69
65: ; preds = %55
%66 = load i32, i32* %6
%67 = call i32 @close(i32 %66)
%68 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %70
69: ; preds = %55
br label %74
70: ; preds = %65, %53
%71 = load %struct.addrinfo*, %struct.addrinfo** %11
%72 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %71, i32 0, i32 5
%73 = load %struct.addrinfo*, %struct.addrinfo** %72
store %struct.addrinfo* %73, %struct.addrinfo** %11
br label %38
74: ; preds = %69, %38
%75 = load %struct.addrinfo*, %struct.addrinfo** %11
%76 = icmp eq %struct.addrinfo* %75, null
br i1 %76, label %77, label %80
77: ; preds = %74
%78 = load i32, i32* @stderr
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
store i32 2, i32* %3
br label %110
80: ; preds = %74
%81 = load %struct.addrinfo*, %struct.addrinfo** %11
%82 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %81, i32 0, i32 1
%83 = load i32, i32* %82
%84 = load %struct.addrinfo*, %struct.addrinfo** %11
%85 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %84, i32 0, i32 0
%86 = load i64, i64* %85
%87 = inttoptr i64 %86 to %struct.sockaddr*
%88 = call i32 @get_in_addr(%struct.sockaddr* %87)
%89 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%90 = call i32 @inet_ntop(i32 %83, i32 %88, i8* %89, i32 256)
%91 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%92 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %91)
%93 = load %struct.addrinfo*, %struct.addrinfo** %10
%94 = call i32 @freeaddrinfo(%struct.addrinfo* %93)
%95 = load i32, i32* %6
%96 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%97 = call i32 @recv(i32 %95, i8* %96, i32 99, i32 0)
store i32 %97, i32* %7
%98 = icmp eq i32 %97, -1
br i1 %98, label %99, label %102
99: ; preds = %80
%100 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%101 = call i32 @exit(i32 1)
unreachable
102: ; preds = %80
%103 = load i32, i32* %7
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 %104
store i8 0, i8* %105
%106 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%107 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i8* %106)
%108 = load i32, i32* %6
%109 = call i32 @close(i32 %108)
store i32 0, i32* %3
br label %110
110: ; preds = %102, %77, %31
%111 = load i32, i32* %3
ret i32 %111
}

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