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

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int connect(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
int /*<<< orphan*/ memset(struct addrinfo *, char, int);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usleep(int);
scalar_t__ write(int, char *, int);
int getTimeFromServer(char *host, int port, char *buffer, int bufferLen) {
  int sfd, sysRet, timeOut, retval;
  char stringPort[8];
  struct addrinfo hints, *aiList, *aiPtr = NULL;
  if (strcmp(host, "") == 0) {
    printf("Need hostname or IP address\n");
    return (-1);
  }
  sprintf(stringPort, "%d", port);
  memset(&hints, '\0', sizeof(hints));
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  sysRet = getaddrinfo(host, stringPort, &hints, &aiList);
  if (sysRet != 0) {
    printf("error getting network address for %s (%s)\n", host,
           gai_strerror(sysRet));
    exit(-1);
  }
  aiPtr = aiList;
  while (aiPtr != 0) {
    sfd = socket(aiPtr->ai_family, aiPtr->ai_socktype, aiPtr->ai_protocol);
    if (sfd >= 0) {
      timeOut = 100;
      sysRet = 1;
      while ((timeOut != 0) && (sysRet != 0)) {
        sysRet = connect(sfd, aiPtr->ai_addr, aiPtr->ai_addrlen);
        usleep(1000);
        timeOut--;
      }
      if (sysRet == 0)
        break;
      else
        close(sfd);
    }
    aiPtr = aiPtr->ai_next;
  }
  freeaddrinfo(aiList);
  if (aiPtr == NULL) {
    printf("could not connect to %s\n", host);
    retval = -1;
  } else
    retval = 0;
  if (retval == 0) {
    if (write(sfd, buffer, bufferLen) < 0) {
      printf("error sending request to timer serveer\n");
      retval = -1;
    } else
      retval = read(sfd, buffer, 512);
  }
  close(sfd);
  return (retval);
}


x86 assembly (clang, -O0):
<getTimeFromServer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movq   $0x0,-0x70(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1235 <getTimeFromServer+0x55>
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    142c <getTimeFromServer+0x24c>
lea    -0x3c(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xdda(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
mov    0x2d89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2d6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x3c(%rbp),%rsi
lea    -0x60(%rbp),%rdx
lea    -0x68(%rbp),%rcx
call   10d0 <getaddrinfo@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     12c1 <getTimeFromServer+0xe1>
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x2c(%rbp),%edi
call   1050 <gai_strerror@plt>
mov    -0x78(%rbp),%rsi
mov    %rax,%rdx
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10b0 <exit@plt>
mov    -0x68(%rbp),%rax
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
je     138f <getTimeFromServer+0x1af>
mov    -0x70(%rbp),%rax
mov    0x18(%rax),%edi
mov    -0x70(%rbp),%rax
mov    0x14(%rax),%esi
mov    -0x70(%rbp),%rax
mov    0x10(%rax),%edx
call   1100 <socket@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jl     137f <getTimeFromServer+0x19f>
movl   $0x64,-0x30(%rbp)
movl   $0x1,-0x2c(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x30(%rbp)
mov    %al,-0x79(%rbp)
je     1322 <getTimeFromServer+0x142>
cmpl   $0x0,-0x2c(%rbp)
setne  %al
mov    %al,-0x79(%rbp)
mov    -0x79(%rbp),%al
test   $0x1,%al
jne    1332 <getTimeFromServer+0x152>
jmp    1363 <getTimeFromServer+0x183>
mov    -0x28(%rbp),%edi
mov    -0x70(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x70(%rbp),%rax
mov    0x8(%rax),%edx
call   10c0 <connect@plt>
mov    %eax,-0x2c(%rbp)
mov    $0x3e8,%edi
call   10e0 <usleep@plt>
mov    -0x30(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x30(%rbp)
jmp    1309 <getTimeFromServer+0x129>
cmpl   $0x0,-0x2c(%rbp)
jne    1372 <getTimeFromServer+0x192>
jmp    138f <getTimeFromServer+0x1af>
mov    -0x28(%rbp),%edi
call   1070 <close@plt>
jmp    137f <getTimeFromServer+0x19f>
mov    -0x70(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x70(%rbp)
jmp    12c9 <getTimeFromServer+0xe9>
mov    -0x68(%rbp),%rdi
call   10f0 <freeaddrinfo@plt>
cmpq   $0x0,-0x70(%rbp)
jne    13c1 <getTimeFromServer+0x1e1>
mov    -0x10(%rbp),%rsi
lea    0xc9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x34(%rbp)
jmp    13c8 <getTimeFromServer+0x1e8>
movl   $0x0,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    141e <getTimeFromServer+0x23e>
mov    -0x28(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <write@plt>
cmp    $0x0,%rax
jge    1405 <getTimeFromServer+0x225>
lea    0xc72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x34(%rbp)
jmp    1419 <getTimeFromServer+0x239>
mov    -0x28(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    $0x200,%edx
call   1080 <read@plt>
mov    %eax,-0x34(%rbp)
jmp    141e <getTimeFromServer+0x23e>
mov    -0x28(%rbp),%edi
call   1070 <close@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getTimeFromServer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%r12
lea    0xe1d(%rip),%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     12f5 <getTimeFromServer+0x105>
lea    0xddb(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %ebp,%edx
call   10b0 <sprintf@plt>
lea    0x18(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
mov    0x2d99(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x30(%rsp)
mov    0x2d7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x2c(%rsp)
mov    %rsp,%rcx
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   10e0 <getaddrinfo@plt>
test   %eax,%eax
jne    1383 <getTimeFromServer+0x193>
mov    (%rsp),%rbp
test   %rbp,%rbp
je     130e <getTimeFromServer+0x11e>
mov    %r15d,0xc(%rsp)
jmp    1299 <getTimeFromServer+0xa9>
nop
mov    0x0(%rbp),%rbp
test   %rbp,%rbp
je     1308 <getTimeFromServer+0x118>
mov    0x18(%rbp),%edi
mov    0x10(%rbp),%edx
mov    0x14(%rbp),%esi
call   1110 <socket@plt>
mov    %eax,%r13d
test   %eax,%eax
js     1290 <getTimeFromServer+0xa0>
mov    $0xffffff9d,%r15d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x8(%rbp),%edx
mov    0xc(%rbp),%esi
mov    %r13d,%edi
call   10d0 <connect@plt>
mov    %eax,%ebx
mov    $0x3e8,%edi
call   10f0 <usleep@plt>
test   %r15d,%r15d
je     12e7 <getTimeFromServer+0xf7>
add    $0x1,%r15d
test   %ebx,%ebx
jne    12c0 <getTimeFromServer+0xd0>
test   %ebx,%ebx
je     1344 <getTimeFromServer+0x154>
mov    %r13d,%edi
call   1080 <close@plt>
jmp    1290 <getTimeFromServer+0xa0>
lea    0xd72(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebx
jmp    1333 <getTimeFromServer+0x143>
mov    (%rsp),%rdi
jmp    1310 <getTimeFromServer+0x120>
xor    %edi,%edi
call   1100 <freeaddrinfo@plt>
lea    0xd12(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%ebx
mov    %r13d,%edi
call   1080 <close@plt>
mov    %ebx,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rsp),%rdi
call   1100 <freeaddrinfo@plt>
mov    %r13d,%edi
mov    %r14,%rsi
mov    0xc(%rsp),%edx
call   1040 <write@plt>
test   %rax,%rax
js     1375 <getTimeFromServer+0x185>
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x200,%edx
call   1090 <read@plt>
mov    %eax,%ebx
jmp    132b <getTimeFromServer+0x13b>
lea    0xccb(%rip),%rdi
call   1030 <puts@plt>
jmp    1326 <getTimeFromServer+0x136>
mov    %eax,%edi
call   1060 <gai_strerror@plt>
lea    0xc72(%rip),%rdi
mov    %r12,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.addrinfo = type { %struct.addrinfo*, i32, i32, i32, i32, i32 }
@.str = [1 x i8] zeroinitializer
@.str.1 = [29 x i8] c"Need hostname or IP address\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@.str.3 = [43 x i8] c"error getting network address for %s (%s)\0A\00"
@.str.4 = [25 x i8] c"could not connect to %s\0A\00"
@.str.5 = [40 x i8] c"error sending request to timer serveer\0A\00"
define i32 @getTimeFromServer(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca [8 x i8]
%15 = alloca %struct.addrinfo
%16 = alloca %struct.addrinfo*
%17 = alloca %struct.addrinfo*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store %struct.addrinfo* null, %struct.addrinfo** %17
%18 = load i8*, i8** %6
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %5
br label %123
23: ; preds = %4
%24 = getelementptr inbounds [8 x i8], [8 x i8]* %14, i64 0, i64 0
%25 = load i32, i32* %7
%26 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = call i32 @memset(%struct.addrinfo* %15, i8 signext 0, i32 32)
%28 = load i32, i32* @AF_UNSPEC
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %15, i32 0, i32 5
store i32 %28, i32* %29
%30 = load i32, i32* @SOCK_STREAM
%31 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %15, i32 0, i32 4
store i32 %30, i32* %31
%32 = load i8*, i8** %6
%33 = getelementptr inbounds [8 x i8], [8 x i8]* %14, i64 0, i64 0
%34 = call i32 @getaddrinfo(i8* %32, i8* %33, %struct.addrinfo* %15, %struct.addrinfo** %16)
store i32 %34, i32* %11
%35 = load i32, i32* %11
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %43
37: ; preds = %23
%38 = load i8*, i8** %6
%39 = load i32, i32* %11
%40 = call i8* @gai_strerror(i32 %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8* %38, i8* %40)
%42 = call i32 @exit(i32 -1)
unreachable
43: ; preds = %23
%44 = load %struct.addrinfo*, %struct.addrinfo** %16
store %struct.addrinfo* %44, %struct.addrinfo** %17
br label %45
45: ; preds = %90, %43
%46 = load %struct.addrinfo*, %struct.addrinfo** %17
%47 = icmp ne %struct.addrinfo* %46, null
br i1 %47, label %48, label %94
48: ; preds = %45
%49 = load %struct.addrinfo*, %struct.addrinfo** %17
%50 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %49, i32 0, i32 5
%51 = load i32, i32* %50
%52 = load %struct.addrinfo*, %struct.addrinfo** %17
%53 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %52, i32 0, i32 4
%54 = load i32, i32* %53
%55 = load %struct.addrinfo*, %struct.addrinfo** %17
%56 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %55, i32 0, i32 3
%57 = load i32, i32* %56
%58 = call i32 @socket(i32 %51, i32 %54, i32 %57)
store i32 %58, i32* %10
%59 = load i32, i32* %10
%60 = icmp sge i32 %59, 0
br i1 %60, label %61, label %90
61: ; preds = %48
store i32 100, i32* %12
store i32 1, i32* %11
br label %62
62: ; preds = %70, %61
%63 = load i32, i32* %12
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %68
65: ; preds = %62
%66 = load i32, i32* %11
%67 = icmp ne i32 %66, 0
br label %68
68: ; preds = %65, %62
%69 = phi i1 [ false, %62 ], [ %67, %65 ]
br i1 %69, label %70, label %82
70: ; preds = %68
%71 = load i32, i32* %10
%72 = load %struct.addrinfo*, %struct.addrinfo** %17
%73 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %72, i32 0, i32 2
%74 = load i32, i32* %73
%75 = load %struct.addrinfo*, %struct.addrinfo** %17
%76 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %75, i32 0, i32 1
%77 = load i32, i32* %76
%78 = call i32 @connect(i32 %71, i32 %74, i32 %77)
store i32 %78, i32* %11
%79 = call i32 @usleep(i32 1000)
%80 = load i32, i32* %12
%81 = add nsw i32 %80, -1
store i32 %81, i32* %12
br label %62
82: ; preds = %68
%83 = load i32, i32* %11
%84 = icmp eq i32 %83, 0
br i1 %84, label %85, label %86
85: ; preds = %82
br label %94
86: ; preds = %82
%87 = load i32, i32* %10
%88 = call i32 @close(i32 %87)
br label %89
89: ; preds = %86
br label %90
90: ; preds = %89, %48
%91 = load %struct.addrinfo*, %struct.addrinfo** %17
%92 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %91, i32 0, i32 0
%93 = load %struct.addrinfo*, %struct.addrinfo** %92
store %struct.addrinfo* %93, %struct.addrinfo** %17
br label %45
94: ; preds = %85, %45
%95 = load %struct.addrinfo*, %struct.addrinfo** %16
%96 = call i32 @freeaddrinfo(%struct.addrinfo* %95)
%97 = load %struct.addrinfo*, %struct.addrinfo** %17
%98 = icmp eq %struct.addrinfo* %97, null
br i1 %98, label %99, label %102
99: ; preds = %94
%100 = load i8*, i8** %6
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %100)
store i32 -1, i32* %13
br label %103
102: ; preds = %94
store i32 0, i32* %13
br label %103
103: ; preds = %102, %99
%104 = load i32, i32* %13
%105 = icmp eq i32 %104, 0
br i1 %105, label %106, label %119
106: ; preds = %103
%107 = load i32, i32* %10
%108 = load i8*, i8** %8
%109 = load i32, i32* %9
%110 = call i64 @write(i32 %107, i8* %108, i32 %109)
%111 = icmp slt i64 %110, 0
br i1 %111, label %112, label %114
112: ; preds = %106
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %13
br label %118
114: ; preds = %106
%115 = load i32, i32* %10
%116 = load i8*, i8** %8
%117 = call i32 @read(i32 %115, i8* %116, i32 512)
store i32 %117, i32* %13
br label %118
118: ; preds = %114, %112
br label %119
119: ; preds = %118, %103
%120 = load i32, i32* %10
%121 = call i32 @close(i32 %120)
%122 = load i32, i32* %13
store i32 %122, i32* %5
br label %123
123: ; preds = %119, %21
%124 = load i32, i32* %5
ret i32 %124
}

LLVM IR (-O2):
%struct.addrinfo = type { %struct.addrinfo*, i32, i32, i32, i32, i32 }
@.str = [1 x i8] zeroinitializer
@.str.2 = [3 x i8] c"%d\00"
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@.str.3 = [43 x i8] c"error getting network address for %s (%s)\0A\00"
@.str.4 = [25 x i8] c"could not connect to %s\0A\00"
@str = [39 x i8] c"error sending request to timer serveer\00"
@str.6 = [28 x i8] c"Need hostname or IP address\00"
define i32 @getTimeFromServer(i8* %0, i32 %1, i8* nocapture %2, i32 %3) {
%5 = alloca [8 x i8]
%6 = alloca %struct.addrinfo
%7 = alloca %struct.addrinfo*
%8 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%9 = bitcast %struct.addrinfo* %6 to i8*
%10 = bitcast %struct.addrinfo** %7 to i8*
%11 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %4
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.6, i64 0, i64 0))
br label %82
15: ; preds = %4
%16 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %1)
%17 = call i32 @memset(%struct.addrinfo* %6, i8 signext 0, i32 32)
%18 = load i32, i32* @AF_UNSPEC
%19 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i64 0, i32 5
store i32 %18, i32* %19
%20 = load i32, i32* @SOCK_STREAM
%21 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i64 0, i32 4
store i32 %20, i32* %21
%22 = call i32 @getaddrinfo(i8* %0, i8* %8, %struct.addrinfo* %6, %struct.addrinfo** %7)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %15
%25 = load %struct.addrinfo*, %struct.addrinfo** %7
%26 = icmp eq %struct.addrinfo* %25, null
br i1 %26, label %64, label %31
27: ; preds = %15
%28 = call i8* @gai_strerror(i32 %22)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8* %0, i8* %28)
%30 = call i32 @exit(i32 -1)
unreachable
31: ; preds = %24, %58
%32 = phi %struct.addrinfo* [ %60, %58 ], [ %25, %24 ]
%33 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %32, i64 0, i32 5
%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 sgt i32 %39, -1
br i1 %40, label %41, label %58
41: ; preds = %31
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %32, i64 0, i32 2
%43 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %32, i64 0, i32 1
br label %44
44: ; preds = %41, %44
%45 = phi i32 [ 100, %41 ], [ %50, %44 ]
%46 = load i32, i32* %42
%47 = load i32, i32* %43
%48 = call i32 @connect(i32 %39, i32 %46, i32 %47)
%49 = call i32 @usleep(i32 1000)
%50 = add nsw i32 %45, -1
%51 = icmp ne i32 %50, 0
%52 = icmp ne i32 %48, 0
%53 = select i1 %51, i1 %52, i1 false
br i1 %53, label %44, label %54
54: ; preds = %44
%55 = icmp eq i32 %48, 0
br i1 %55, label %69, label %56
56: ; preds = %54
%57 = call i32 @close(i32 %39)
br label %58
58: ; preds = %56, %31
%59 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %32, i64 0, i32 0
%60 = load %struct.addrinfo*, %struct.addrinfo** %59
%61 = icmp eq %struct.addrinfo* %60, null
br i1 %61, label %62, label %31
62: ; preds = %58
%63 = load %struct.addrinfo*, %struct.addrinfo** %7
br label %64
64: ; preds = %62, %24
%65 = phi %struct.addrinfo* [ null, %24 ], [ %63, %62 ]
%66 = phi i32 [ undef, %24 ], [ %39, %62 ]
%67 = call i32 @freeaddrinfo(%struct.addrinfo* %65)
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %78
69: ; preds = %54
%70 = load %struct.addrinfo*, %struct.addrinfo** %7
%71 = call i32 @freeaddrinfo(%struct.addrinfo* %70)
%72 = call i64 @write(i32 %39, i8* %2, i32 %3)
%73 = icmp slt i64 %72, 0
br i1 %73, label %74, label %76
74: ; preds = %69
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
br label %78
76: ; preds = %69
%77 = call i32 @read(i32 %39, i8* %2, i32 512)
br label %78
78: ; preds = %64, %74, %76
%79 = phi i32 [ %39, %74 ], [ %39, %76 ], [ %66, %64 ]
%80 = phi i32 [ -1, %74 ], [ %77, %76 ], [ -1, %64 ]
%81 = call i32 @close(i32 %79)
br label %82
82: ; preds = %78, %13
%83 = phi i32 [ -1, %13 ], [ %80, %78 ]
ret i32 %83
}