#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);
char *malloc(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];
  char *PORT = malloc(2000);
  PORT = argv[2];
  memset(&hints, 0, sizeof hints);
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  if ((rv = getaddrinfo(argv[1], PORT, &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    0x2dd8(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0xe8(%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,-0xe0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xc8(%rbp)
mov    $0x7d0,%edi
call   10b0 <malloc@plt>
mov    %rax,-0xd0(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0xd0(%rbp)
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1080 <memset@plt>
mov    0x2d61(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x98(%rbp)
mov    0x2d3a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0xd0(%rbp),%rsi
lea    -0xa0(%rbp),%rdx
lea    -0xa8(%rbp),%rcx
call   10f0 <getaddrinfo@plt>
mov    %eax,-0xb4(%rbp)
cmp    $0x0,%eax
je     130e <main+0x11e>
mov    0x2d02(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xec(%rbp)
mov    -0xb4(%rbp),%edi
call   1070 <gai_strerror@plt>
mov    -0xec(%rbp),%edi
mov    %rax,%rdx
lea    0xd0f(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0xd4(%rbp)
jmp    14c1 <main+0x2d1>
mov    -0xa8(%rbp),%rax
mov    %rax,-0xb0(%rbp)
cmpq   $0x0,-0xb0(%rbp)
je     13c4 <main+0x1d4>
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   1110 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    136a <main+0x17a>
lea    0xcb1(%rip),%rdi
call   10c0 <perror@plt>
jmp    13ad <main+0x1bd>
mov    -0x14(%rbp),%edi
mov    -0xb0(%rbp),%rax
mov    (%rax),%rsi
mov    -0xb0(%rbp),%rax
mov    0xc(%rax),%edx
call   10e0 <connect@plt>
cmp    $0xffffffff,%eax
jne    13a8 <main+0x1b8>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
lea    0xc82(%rip),%rdi
call   10c0 <perror@plt>
jmp    13ad <main+0x1bd>
jmp    13c4 <main+0x1d4>
mov    -0xb0(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0xb0(%rbp)
jmp    131c <main+0x12c>
cmpq   $0x0,-0xb0(%rbp)
jne    13ff <main+0x20f>
mov    0x2bf7(%rip),%rax
mov    (%rax),%edi
lea    0xc4e(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0xd4(%rbp)
jmp    14c1 <main+0x2d1>
mov    -0xb0(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0xf0(%rbp)
mov    -0xb0(%rbp),%rax
mov    (%rax),%rdi
call   1050 <get_in_addr@plt>
mov    -0xf0(%rbp),%edi
mov    -0xe0(%rbp),%rdx
mov    %eax,%esi
mov    -0xe8(%rbp),%rax
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    -0xe0(%rbp),%rsi
lea    0xc02(%rip),%rdi
call   1060 <printf@plt>
mov    -0xa8(%rbp),%rdi
call   1100 <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    148f <main+0x29f>
lea    0xbe5(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x80(%rbp,%rax,1)
lea    -0x80(%rbp),%rsi
lea    0xbc7(%rip),%rdi
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xd4(%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    %rsi,%rbx
mov    %rsp,-0x30(%rbp)
mov    0x2de6(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%r12
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    0x10(%rsi),%r15
lea    -0x58(%rbp),%r13
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1080 <memset@plt>
mov    0x2dac(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2d88(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x8(%rbx),%rdi
lea    -0x38(%rbp),%rcx
mov    %r15,%rsi
mov    %r13,%rdx
call   10e0 <getaddrinfo@plt>
test   %eax,%eax
je     1289 <main+0xa9>
mov    0x2d6d(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1070 <gai_strerror@plt>
lea    0xd8d(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%ebx
jmp    1375 <main+0x195>
mov    -0x38(%rbp),%rbx
test   %rbx,%rbx
je     12e1 <main+0x101>
lea    0xd78(%rip),%r13
mov    0x14(%rbx),%esi
mov    0x8(%rbx),%edi
mov    0x10(%rbx),%edx
call   1100 <socket@plt>
mov    %r13,%rdi
cmp    $0xffffffff,%eax
je     12d3 <main+0xf3>
mov    %eax,%r15d
mov    (%rbx),%rsi
mov    0xc(%rbx),%edx
mov    %eax,%edi
call   10d0 <connect@plt>
cmp    $0xffffffff,%eax
jne    12ff <main+0x11f>
mov    %r15d,%edi
call   1090 <close@plt>
lea    0xd4d(%rip),%rdi
call   10b0 <perror@plt>
mov    0x18(%rbx),%rbx
test   %rbx,%rbx
jne    1299 <main+0xb9>
mov    0x2ce8(%rip),%rax
mov    (%rax),%edi
lea    0xd3f(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x2,%ebx
jmp    1375 <main+0x195>
mov    0x8(%rbx),%r13d
mov    (%rbx),%rdi
call   1050 <get_in_addr@plt>
mov    %r13d,%edi
mov    %eax,%esi
mov    %r12,%rdx
mov    %r14d,%ecx
call   1030 <inet_ntop@plt>
lea    0xd29(%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     138d <main+0x1ad>
cltq
movb   $0x0,-0xc0(%rbp,%rax,1)
lea    0xd09(%rip),%rdi
lea    -0xc0(%rbp),%rsi
call   1060 <printf@plt>
mov    %r15d,%edi
call   1090 <close@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcd1(%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
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@stderr = global i32 0
@.str = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.1 = [15 x i8] c"client: socket\00"
@.str.2 = [16 x i8] c"client: connect\00"
@.str.3 = [27 x i8] c"client: failed to connect\0A\00"
@.str.4 = [26 x i8] c"client: connecting to %s\0A\00"
@.str.5 = [5 x i8] c"recv\00"
@.str.6 = [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 i8*
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* @INET6_ADDRSTRLEN
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %13
%20 = alloca i8, i64 %18
store i64 %18, i64* %14
%21 = call i8* @malloc(i32 2000)
store i8* %21, i8** %15
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
store i8* %24, i8** %15
%25 = call i32 @memset(%struct.addrinfo* %9, i32 0, i32 32)
%26 = load i32, i32* @AF_UNSPEC
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, i32 0, i32 1
store i32 %26, i32* %27
%28 = load i32, i32* @SOCK_STREAM
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, i32 0, i32 4
store i32 %28, i32* %29
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = load i8*, i8** %15
%34 = call i32 @getaddrinfo(i8* %32, i8* %33, %struct.addrinfo* %9, %struct.addrinfo** %10)
store i32 %34, i32* %12
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %2
%37 = load i32, i32* @stderr
%38 = load i32, i32* %12
%39 = call i8* @gai_strerror(i32 %38)
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %39)
store i32 1, i32* %3
store i32 1, i32* %16
br label %114
41: ; preds = %2
%42 = load %struct.addrinfo*, %struct.addrinfo** %10
store %struct.addrinfo* %42, %struct.addrinfo** %11
br label %43
43: ; preds = %75, %41
%44 = load %struct.addrinfo*, %struct.addrinfo** %11
%45 = icmp ne %struct.addrinfo* %44, null
br i1 %45, label %46, label %79
46: ; preds = %43
%47 = load %struct.addrinfo*, %struct.addrinfo** %11
%48 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %47, i32 0, i32 1
%49 = load i32, i32* %48
%50 = load %struct.addrinfo*, %struct.addrinfo** %11
%51 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %50, i32 0, i32 4
%52 = load i32, i32* %51
%53 = load %struct.addrinfo*, %struct.addrinfo** %11
%54 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %53, i32 0, i32 3
%55 = load i32, i32* %54
%56 = call i32 @socket(i32 %49, i32 %52, i32 %55)
store i32 %56, i32* %6
%57 = icmp eq i32 %56, -1
br i1 %57, label %58, label %60
58: ; preds = %46
%59 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %75
60: ; preds = %46
%61 = load i32, i32* %6
%62 = load %struct.addrinfo*, %struct.addrinfo** %11
%63 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %62, i32 0, i32 0
%64 = load i64, i64* %63
%65 = load %struct.addrinfo*, %struct.addrinfo** %11
%66 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %65, i32 0, i32 2
%67 = load i32, i32* %66
%68 = call i32 @connect(i32 %61, i64 %64, i32 %67)
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %74
70: ; preds = %60
%71 = load i32, i32* %6
%72 = call i32 @close(i32 %71)
%73 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %75
74: ; preds = %60
br label %79
75: ; preds = %70, %58
%76 = load %struct.addrinfo*, %struct.addrinfo** %11
%77 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %76, i32 0, i32 5
%78 = load %struct.addrinfo*, %struct.addrinfo** %77
store %struct.addrinfo* %78, %struct.addrinfo** %11
br label %43
79: ; preds = %74, %43
%80 = load %struct.addrinfo*, %struct.addrinfo** %11
%81 = icmp eq %struct.addrinfo* %80, null
br i1 %81, label %82, label %85
82: ; preds = %79
%83 = load i32, i32* @stderr
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
store i32 2, i32* %3
store i32 1, i32* %16
br label %114
85: ; preds = %79
%86 = load %struct.addrinfo*, %struct.addrinfo** %11
%87 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %86, i32 0, i32 1
%88 = load i32, i32* %87
%89 = load %struct.addrinfo*, %struct.addrinfo** %11
%90 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %89, i32 0, i32 0
%91 = load i64, i64* %90
%92 = inttoptr i64 %91 to %struct.sockaddr*
%93 = call i32 @get_in_addr(%struct.sockaddr* %92)
%94 = trunc i64 %18 to i32
%95 = call i32 @inet_ntop(i32 %88, i32 %93, i8* %20, i32 %94)
%96 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %20)
%97 = load %struct.addrinfo*, %struct.addrinfo** %10
%98 = call i32 @freeaddrinfo(%struct.addrinfo* %97)
%99 = load i32, i32* %6
%100 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%101 = call i32 @recv(i32 %99, i8* %100, i32 99, i32 0)
store i32 %101, i32* %7
%102 = icmp eq i32 %101, -1
br i1 %102, label %103, label %106
103: ; preds = %85
%104 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%105 = call i32 @exit(i32 1)
unreachable
106: ; preds = %85
%107 = load i32, i32* %7
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 %108
store i8 0, i8* %109
%110 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%111 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %110)
%112 = load i32, i32* %6
%113 = call i32 @close(i32 %112)
store i32 0, i32* %3
store i32 1, i32* %16
br label %114
114: ; preds = %106, %82, %36
%115 = load i8*, i8** %13
%116 = load i32, i32* %3
ret i32 %116
}

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