#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 != 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;
  }
  printf("ZKP Client: connecting to %s\n", s);
  inet_ntop(p->ai_family, get_in_addr((struct sockaddr *)p->ai_addr), s,
            sizeof s);
  printf("ZKP Client: Connected to %s\n", s);
  freeaddrinfo(servinfo);
  if ((numbytes = recv(sockfd, buf, 100 - 1, 0)) == -1) {
    perror("recv");
    exit(1);
  }
  buf[numbytes] = '\0';
  printf("ZKP 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   $0x2,-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
lea    0xd78(%rip),%rsi
lea    -0xa0(%rbp),%rdx
lea    -0xa8(%rbp),%rcx
call   10e0 <getaddrinfo@plt>
mov    %eax,-0xb4(%rbp)
cmp    $0x0,%eax
je     1309 <main+0x129>
mov    0x2d07(%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    0xd31(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0xcc(%rbp)
jmp    14cf <main+0x2ef>
mov    -0xa8(%rbp),%rax
mov    %rax,-0xb0(%rbp)
cmpq   $0x0,-0xb0(%rbp)
je     13bf <main+0x1df>
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    1365 <main+0x185>
lea    0xcd3(%rip),%rdi
call   10b0 <perror@plt>
jmp    13a8 <main+0x1c8>
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    13a3 <main+0x1c3>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
lea    0xca4(%rip),%rdi
call   10b0 <perror@plt>
jmp    13a8 <main+0x1c8>
jmp    13bf <main+0x1df>
mov    -0xb0(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0xb0(%rbp)
jmp    1317 <main+0x137>
cmpq   $0x0,-0xb0(%rbp)
jne    13fa <main+0x21a>
mov    0x2bfc(%rip),%rax
mov    (%rax),%edi
lea    0xc70(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0xcc(%rbp)
jmp    14cf <main+0x2ef>
mov    -0xd8(%rbp),%rsi
lea    0xc60(%rip),%rdi
call   1060 <printf@plt>
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    0xc2f(%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    149d <main+0x2bd>
lea    0xc15(%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    0xbf7(%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    $0x2,%edi
jne    13b0 <main+0x1d0>
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
lea    0xdc4(%rip),%rsi
lea    -0x38(%rbp),%rcx
mov    %r15,%rdx
call   10e0 <getaddrinfo@plt>
test   %eax,%eax
je     1291 <main+0xb1>
mov    0x2d65(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1070 <gai_strerror@plt>
lea    0xda2(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%ebx
jmp    139c <main+0x1bc>
mov    %r13,-0x30(%rbp)
mov    -0x38(%rbp),%r13
test   %r13,%r13
je     12f2 <main+0x112>
lea    0xd89(%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     12e4 <main+0x104>
mov    %eax,%r15d
mov    0x0(%r13),%rsi
mov    0xc(%r13),%edx
mov    %eax,%edi
call   10d0 <connect@plt>
cmp    $0xffffffff,%eax
jne    1313 <main+0x133>
mov    %r15d,%edi
call   1090 <close@plt>
lea    0xd59(%rip),%rdi
call   10b0 <perror@plt>
mov    0x18(%r13),%r13
test   %r13,%r13
jne    12a5 <main+0xc5>
mov    0x2cd7(%rip),%rax
mov    (%rax),%edi
lea    0xd4b(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x2,%ebx
jmp    1398 <main+0x1b8>
lea    0xd4e(%rip),%rdi
mov    %r12,%rsi
call   1060 <printf@plt>
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    0xd41(%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     13d1 <main+0x1f1>
cltq
movb   $0x0,-0xc0(%rbp,%rax,1)
lea    0xd24(%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    0x2c19(%rip),%rax
mov    (%rax),%edi
lea    0xc40(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    0xccb(%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 = [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 = [30 x i8] c"ZKP Client: connecting to %s\0A\00"
@.str.7 = [29 x i8] c"ZKP Client: Connected to %s\0A\00"
@.str.8 = [5 x i8] c"recv\00"
@.str.9 = [27 x i8] c"ZKP 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, 2
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 ([24 x i8], [24 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 = call i32 @getaddrinfo(i8* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %struct.addrinfo* %9, %struct.addrinfo** %10)
store i32 %35, i32* %12
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %42
37: ; preds = %26
%38 = load i32, i32* @stderr
%39 = load i32, i32* %12
%40 = call i8* @gai_strerror(i32 %39)
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %40)
store i32 1, i32* %3
store i32 1, i32* %15
br label %116
42: ; preds = %26
%43 = load %struct.addrinfo*, %struct.addrinfo** %10
store %struct.addrinfo* %43, %struct.addrinfo** %11
br label %44
44: ; preds = %76, %42
%45 = load %struct.addrinfo*, %struct.addrinfo** %11
%46 = icmp ne %struct.addrinfo* %45, null
br i1 %46, label %47, label %80
47: ; preds = %44
%48 = load %struct.addrinfo*, %struct.addrinfo** %11
%49 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %48, i32 0, i32 1
%50 = load i32, i32* %49
%51 = load %struct.addrinfo*, %struct.addrinfo** %11
%52 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %51, i32 0, i32 4
%53 = load i32, i32* %52
%54 = load %struct.addrinfo*, %struct.addrinfo** %11
%55 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %54, i32 0, i32 3
%56 = load i32, i32* %55
%57 = call i32 @socket(i32 %50, i32 %53, i32 %56)
store i32 %57, i32* %6
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %61
59: ; preds = %47
%60 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %76
61: ; preds = %47
%62 = load i32, i32* %6
%63 = load %struct.addrinfo*, %struct.addrinfo** %11
%64 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %63, i32 0, i32 0
%65 = load i64, i64* %64
%66 = load %struct.addrinfo*, %struct.addrinfo** %11
%67 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %66, i32 0, i32 2
%68 = load i32, i32* %67
%69 = call i32 @connect(i32 %62, i64 %65, i32 %68)
%70 = icmp eq i32 %69, -1
br i1 %70, label %71, label %75
71: ; preds = %61
%72 = load i32, i32* %6
%73 = call i32 @close(i32 %72)
%74 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %76
75: ; preds = %61
br label %80
76: ; preds = %71, %59
%77 = load %struct.addrinfo*, %struct.addrinfo** %11
%78 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %77, i32 0, i32 5
%79 = load %struct.addrinfo*, %struct.addrinfo** %78
store %struct.addrinfo* %79, %struct.addrinfo** %11
br label %44
80: ; preds = %75, %44
%81 = load %struct.addrinfo*, %struct.addrinfo** %11
%82 = icmp eq %struct.addrinfo* %81, null
br i1 %82, label %83, label %86
83: ; preds = %80
%84 = load i32, i32* @stderr
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
store i32 2, i32* %3
store i32 1, i32* %15
br label %116
86: ; preds = %80
%87 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i8* %19)
%88 = load %struct.addrinfo*, %struct.addrinfo** %11
%89 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %88, i32 0, i32 1
%90 = load i32, i32* %89
%91 = load %struct.addrinfo*, %struct.addrinfo** %11
%92 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %91, i32 0, i32 0
%93 = load i64, i64* %92
%94 = inttoptr i64 %93 to %struct.sockaddr*
%95 = call i32 @get_in_addr(%struct.sockaddr* %94)
%96 = trunc i64 %17 to i32
%97 = call i32 @inet_ntop(i32 %90, i32 %95, i8* %19, i32 %96)
%98 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i8* %19)
%99 = load %struct.addrinfo*, %struct.addrinfo** %10
%100 = call i32 @freeaddrinfo(%struct.addrinfo* %99)
%101 = load i32, i32* %6
%102 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%103 = call i32 @recv(i32 %101, i8* %102, i32 99, i32 0)
store i32 %103, i32* %7
%104 = icmp eq i32 %103, -1
br i1 %104, label %105, label %108
105: ; preds = %86
%106 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%107 = call i32 @exit(i32 1)
unreachable
108: ; preds = %86
%109 = load i32, i32* %7
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 %110
store i8 0, i8* %111
%112 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%113 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0), i8* %112)
%114 = load i32, i32* %6
%115 = call i32 @close(i32 %114)
store i32 0, i32* %3
store i32 1, i32* %15
br label %116
116: ; preds = %108, %83, %37
%117 = load i8*, i8** %13
%118 = load i32, i32* %3
ret i32 %118
}

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