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

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
scalar_t__ getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printErrorAndQuit(char *);
int /*<<< orphan*/ printf(char *, ...);
int recv(int, char *, int, int /*<<< orphan*/);
unsigned int send(int, char *, unsigned int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
unsigned int strlen(char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  int sock;
  char *echoServPort;
  struct addrinfo hints;
  struct addrinfo *servinfo;
  char *echoString;
  char echoBuffer[32];
  unsigned int echoStringLen;
  int bytesRcvd, totalBytesRcvd;
  if ((argc < 3) || (argc > 4))
    usage(argv[0]);
  echoString = argv[2];
  if (argc == 4) {
    echoServPort = argv[3];
    printf("using port %s.\n", echoServPort);
  } else
    echoServPort = "7";
  memset(&hints, 0, sizeof hints);
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  if ((getaddrinfo(argv[1], echoServPort, &hints, &servinfo)) != 0)
    printErrorAndQuit("getaddrinfo() failed");
  if ((sock = socket(servinfo->ai_family, servinfo->ai_socktype,
                     servinfo->ai_protocol)) < 0)
    printErrorAndQuit("socket() failed");
  printf("connecting to server ...\n");
  if (connect(sock, servinfo->ai_addr, servinfo->ai_addrlen) < 0)
    printErrorAndQuit("connect() failed");
  freeaddrinfo(servinfo);
  printf("sending data ...\n");
  echoStringLen = strlen(echoString);
  if (send(sock, echoString, echoStringLen, 0) != echoStringLen)
    printErrorAndQuit("send() different number of bytes than expected");
  totalBytesRcvd = 0;
  printf("Received: ");
  while (totalBytesRcvd < echoStringLen) {
    if ((bytesRcvd = recv(sock, echoBuffer, 32 - 1, 0)) <= 0)
      printErrorAndQuit("recv() connection closed prematurely");
    totalBytesRcvd += bytesRcvd;
    echoBuffer[bytesRcvd] = '\0';
    printf("%s", echoBuffer);
  }
  printf("\n");
  close(sock);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jl     11fd <main+0x2d>
cmpl   $0x4,-0x8(%rbp)
jle    1209 <main+0x39>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10a0 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x48(%rbp)
cmpl   $0x4,-0x8(%rbp)
jne    1242 <main+0x72>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    124d <main+0x7d>
lea    0xdc7(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1070 <memset@plt>
mov    0x2d84(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2d68(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x38(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   10d0 <getaddrinfo@plt>
cmp    $0x0,%rax
je     12a4 <main+0xd4>
lea    0xd73(%rip),%rdi
call   1090 <printErrorAndQuit@plt>
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x40(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%edx
call   10f0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    12d6 <main+0x106>
lea    0xd56(%rip),%rdi
call   1090 <printErrorAndQuit@plt>
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x40(%rbp),%rax
mov    (%rax),%edx
call   10c0 <connect@plt>
cmp    $0x0,%rax
jge    130f <main+0x13f>
lea    0xd47(%rip),%rdi
call   1090 <printErrorAndQuit@plt>
mov    -0x40(%rbp),%rdi
call   10e0 <freeaddrinfo@plt>
lea    0xd43(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x74(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x48(%rbp),%rsi
mov    -0x74(%rbp),%edx
xor    %ecx,%ecx
call   1050 <send@plt>
cmp    -0x74(%rbp),%eax
je     1358 <main+0x188>
lea    0xd21(%rip),%rdi
call   1090 <printErrorAndQuit@plt>
movl   $0x0,-0x7c(%rbp)
lea    0xd3d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x7c(%rbp),%eax
cmp    -0x74(%rbp),%eax
jae    13cd <main+0x1fd>
mov    -0x14(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x1f,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x78(%rbp)
cmp    $0x0,%eax
jg     13a4 <main+0x1d4>
lea    0xd0f(%rip),%rdi
call   1090 <printErrorAndQuit@plt>
mov    -0x78(%rbp),%eax
add    -0x7c(%rbp),%eax
mov    %eax,-0x7c(%rbp)
movslq -0x78(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rsi
lea    0xd12(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    136d <main+0x19d>
lea    0xc9e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%rbx
lea    -0x5(%rdi),%eax
cmp    $0xfffffffd,%eax
ja     1217 <main+0x27>
mov    (%rbx),%rdi
call   10c0 <usage@plt>
mov    0x10(%rbx),%r14
jmp    1237 <main+0x47>
mov    0x10(%rbx),%r14
cmp    $0x4,%edi
jne    1237 <main+0x47>
mov    0x18(%rbx),%r15
lea    0xdd5(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    123e <main+0x4e>
lea    0xdd2(%rip),%r15
lea    0x8(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1090 <memset@plt>
mov    0x2d8f(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
mov    0x2d72(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
mov    0x8(%rbx),%rdi
mov    %rsp,%rcx
mov    %r15,%rsi
mov    %rbp,%rdx
call   10f0 <getaddrinfo@plt>
test   %rax,%rax
je     128f <main+0x9f>
lea    0xd88(%rip),%rdi
call   10b0 <printErrorAndQuit@plt>
mov    (%rsp),%rax
mov    0x10(%rax),%edi
mov    0x8(%rax),%edx
mov    0xc(%rax),%esi
call   1110 <socket@plt>
mov    %eax,%r15d
test   %eax,%eax
jns    12b4 <main+0xc4>
lea    0xd78(%rip),%rdi
call   10b0 <printErrorAndQuit@plt>
lea    0xdef(%rip),%rdi
call   1050 <puts@plt>
mov    (%rsp),%rax
mov    (%rax),%edx
mov    0x4(%rax),%esi
mov    %r15d,%edi
call   10e0 <connect@plt>
test   %rax,%rax
jns    12e2 <main+0xf2>
lea    0xd5a(%rip),%rdi
call   10b0 <printErrorAndQuit@plt>
mov    (%rsp),%rdi
call   1100 <freeaddrinfo@plt>
lea    0xdd1(%rip),%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %eax,%r13d
mov    %r15d,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
cmp    %r13d,%eax
je     1322 <main+0x132>
lea    0xd2b(%rip),%rdi
call   10b0 <printErrorAndQuit@plt>
lea    0xd4e(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
test   %r13d,%r13d
jne    134e <main+0x15e>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r15d,%edi
call   10a0 <close@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
lea    0x20(%rsp),%rbx
lea    0xd4d(%rip),%r12
xor    %r14d,%r14d
jmp    137d <main+0x18d>
nop
add    %ebp,%r14d
movslq %ebp,%rax
movb   $0x0,0x20(%rsp,%rax,1)
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
cmp    %r13d,%r14d
jae    1335 <main+0x145>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x1f,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,%ebp
test   %eax,%eax
jg     1360 <main+0x170>
lea    0xce6(%rip),%rdi
call   10b0 <printErrorAndQuit@plt>
jmp    1360 <main+0x170>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i32, i32, i32 }
@.str = [16 x i8] c"using port %s.\0A\00"
@.str.1 = [2 x i8] c"7\00"
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [21 x i8] c"getaddrinfo() failed\00"
@.str.3 = [16 x i8] c"socket() failed\00"
@.str.4 = [26 x i8] c"connecting to server ...\0A\00"
@.str.5 = [17 x i8] c"connect() failed\00"
@.str.6 = [18 x i8] c"sending data ...\0A\00"
@.str.7 = [47 x i8] c"send() different number of bytes than expected\00"
@.str.8 = [11 x i8] c"Received: \00"
@.str.9 = [37 x i8] c"recv() connection closed prematurely\00"
@.str.10 = [3 x i8] c"%s\00"
@.str.11 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca %struct.addrinfo
%9 = alloca %struct.addrinfo*
%10 = alloca i8*
%11 = alloca [32 x i8]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 3
br i1 %16, label %20, label %17
17: ; preds = %2
%18 = load i32, i32* %4
%19 = icmp sgt i32 %18, 4
br i1 %19, label %20, label %25
20: ; preds = %17, %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 @usage(i8* %23)
br label %25
25: ; preds = %20, %17
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
store i8* %28, i8** %10
%29 = load i32, i32* %4
%30 = icmp eq i32 %29, 4
br i1 %30, label %31, label %37
31: ; preds = %25
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 3
%34 = load i8*, i8** %33
store i8* %34, i8** %7
%35 = load i8*, i8** %7
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %35)
br label %38
37: ; preds = %25
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %7
br label %38
38: ; preds = %37, %31
%39 = call i32 @memset(%struct.addrinfo* %8, i32 0, i32 20)
%40 = load i32, i32* @AF_UNSPEC
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 4
store i32 %40, i32* %41
%42 = load i32, i32* @SOCK_STREAM
%43 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 3
store i32 %42, i32* %43
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = load i8*, i8** %45
%47 = load i8*, i8** %7
%48 = call i64 @getaddrinfo(i8* %46, i8* %47, %struct.addrinfo* %8, %struct.addrinfo** %9)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %38
%51 = call i32 @printErrorAndQuit(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %52
52: ; preds = %50, %38
%53 = load %struct.addrinfo*, %struct.addrinfo** %9
%54 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %53, i32 0, i32 4
%55 = load i32, i32* %54
%56 = load %struct.addrinfo*, %struct.addrinfo** %9
%57 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %56, i32 0, i32 3
%58 = load i32, i32* %57
%59 = load %struct.addrinfo*, %struct.addrinfo** %9
%60 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %59, i32 0, i32 2
%61 = load i32, i32* %60
%62 = call i32 @socket(i32 %55, i32 %58, i32 %61)
store i32 %62, i32* %6
%63 = icmp slt i32 %62, 0
br i1 %63, label %64, label %66
64: ; preds = %52
%65 = call i32 @printErrorAndQuit(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %66
66: ; preds = %64, %52
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%68 = load i32, i32* %6
%69 = load %struct.addrinfo*, %struct.addrinfo** %9
%70 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %69, i32 0, i32 1
%71 = load i32, i32* %70
%72 = load %struct.addrinfo*, %struct.addrinfo** %9
%73 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %72, i32 0, i32 0
%74 = load i32, i32* %73
%75 = call i64 @connect(i32 %68, i32 %71, i32 %74)
%76 = icmp slt i64 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %66
%78 = call i32 @printErrorAndQuit(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %79
79: ; preds = %77, %66
%80 = load %struct.addrinfo*, %struct.addrinfo** %9
%81 = call i32 @freeaddrinfo(%struct.addrinfo* %80)
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%83 = load i8*, i8** %10
%84 = call i32 @strlen(i8* %83)
store i32 %84, i32* %12
%85 = load i32, i32* %6
%86 = load i8*, i8** %10
%87 = load i32, i32* %12
%88 = call i32 @send(i32 %85, i8* %86, i32 %87, i32 0)
%89 = load i32, i32* %12
%90 = icmp ne i32 %88, %89
br i1 %90, label %91, label %93
91: ; preds = %79
%92 = call i32 @printErrorAndQuit(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.7, i64 0, i64 0))
br label %93
93: ; preds = %91, %79
store i32 0, i32* %14
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
br label %95
95: ; preds = %106, %93
%96 = load i32, i32* %14
%97 = load i32, i32* %12
%98 = icmp ult i32 %96, %97
br i1 %98, label %99, label %115
99: ; preds = %95
%100 = load i32, i32* %6
%101 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%102 = call i32 @recv(i32 %100, i8* %101, i32 31, i32 0)
store i32 %102, i32* %13
%103 = icmp sle i32 %102, 0
br i1 %103, label %104, label %106
104: ; preds = %99
%105 = call i32 @printErrorAndQuit(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.9, i64 0, i64 0))
br label %106
106: ; preds = %104, %99
%107 = load i32, i32* %13
%108 = load i32, i32* %14
%109 = add nsw i32 %108, %107
store i32 %109, i32* %14
%110 = load i32, i32* %13
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 %111
store i8 0, i8* %112
%113 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* %113)
br label %95
115: ; preds = %95
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%117 = load i32, i32* %6
%118 = call i32 @close(i32 %117)
%119 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32, i32, i32 }
@.str = [16 x i8] c"using port %s.\0A\00"
@.str.1 = [2 x i8] c"7\00"
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [21 x i8] c"getaddrinfo() failed\00"
@.str.3 = [16 x i8] c"socket() failed\00"
@.str.5 = [17 x i8] c"connect() failed\00"
@.str.7 = [47 x i8] c"send() different number of bytes than expected\00"
@.str.8 = [11 x i8] c"Received: \00"
@.str.9 = [37 x i8] c"recv() connection closed prematurely\00"
@.str.10 = [3 x i8] c"%s\00"
@str = [25 x i8] c"connecting to server ...\00"
@str.12 = [17 x i8] c"sending data ...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.addrinfo
%4 = alloca %struct.addrinfo*
%5 = alloca [32 x i8]
%6 = bitcast %struct.addrinfo* %3 to i8*
%7 = bitcast %struct.addrinfo** %4 to i8*
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%9 = add i32 %0, -5
%10 = icmp ult i32 %9, -2
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8*, i8** %1
%13 = tail call i32 @usage(i8* %12)
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
br label %24
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = icmp eq i32 %0, 4
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = getelementptr inbounds i8*, i8** %1, i64 3
%22 = load i8*, i8** %21
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %11, %16, %20
%25 = phi i8* [ %18, %20 ], [ %18, %16 ], [ %15, %11 ]
%26 = phi i8* [ %22, %20 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %16 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %11 ]
%27 = call i32 @memset(%struct.addrinfo* %3, i32 0, i32 20)
%28 = load i32, i32* @AF_UNSPEC
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 4
store i32 %28, i32* %29
%30 = load i32, i32* @SOCK_STREAM
%31 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 3
store i32 %30, i32* %31
%32 = getelementptr inbounds i8*, i8** %1, i64 1
%33 = load i8*, i8** %32
%34 = call i64 @getaddrinfo(i8* %33, i8* %26, %struct.addrinfo* %3, %struct.addrinfo** %4)
%35 = icmp eq i64 %34, 0
br i1 %35, label %38, label %36
36: ; preds = %24
%37 = call i32 @printErrorAndQuit(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %38
38: ; preds = %36, %24
%39 = load %struct.addrinfo*, %struct.addrinfo** %4
%40 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %39, i64 0, i32 4
%41 = load i32, i32* %40
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %39, i64 0, i32 3
%43 = load i32, i32* %42
%44 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %39, i64 0, i32 2
%45 = load i32, i32* %44
%46 = call i32 @socket(i32 %41, i32 %43, i32 %45)
%47 = icmp slt i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %38
%49 = call i32 @printErrorAndQuit(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %50
50: ; preds = %48, %38
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%52 = load %struct.addrinfo*, %struct.addrinfo** %4
%53 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %52, i64 0, i32 1
%54 = load i32, i32* %53
%55 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %52, i64 0, i32 0
%56 = load i32, i32* %55
%57 = call i64 @connect(i32 %46, i32 %54, i32 %56)
%58 = icmp slt i64 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %50
%60 = call i32 @printErrorAndQuit(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %61
61: ; preds = %59, %50
%62 = load %struct.addrinfo*, %struct.addrinfo** %4
%63 = call i32 @freeaddrinfo(%struct.addrinfo* %62)
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.12, i64 0, i64 0))
%65 = call i32 @strlen(i8* %25)
%66 = call i32 @send(i32 %46, i8* %25, i32 %65, i32 0)
%67 = icmp eq i32 %66, %65
br i1 %67, label %70, label %68
68: ; preds = %61
%69 = call i32 @printErrorAndQuit(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.7, i64 0, i64 0))
br label %70
70: ; preds = %68, %61
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%72 = icmp eq i32 %65, 0
br i1 %72, label %85, label %73
73: ; preds = %70, %79
%74 = phi i32 [ %80, %79 ], [ 0, %70 ]
%75 = call i32 @recv(i32 %46, i8* %8, i32 31, i32 0)
%76 = icmp slt i32 %75, 1
br i1 %76, label %77, label %79
77: ; preds = %73
%78 = call i32 @printErrorAndQuit(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.9, i64 0, i64 0))
br label %79
79: ; preds = %77, %73
%80 = add nsw i32 %75, %74
%81 = sext i32 %75 to i64
%82 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 %81
store i8 0, i8* %82
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* %8)
%84 = icmp ult i32 %80, %65
br i1 %84, label %73, label %85
85: ; preds = %79, %70
%86 = call i32 @putchar(i32 10)
%87 = call i32 @close(i32 %46)
%88 = call i32 @exit(i32 0)
unreachable
}