#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ timeout;
struct timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct hostent {
  int /*<<< orphan*/ h_length;
  scalar_t__ h_addr;
};
typedef int /*<<< orphan*/ serveraddr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_RCVTIMEO;
int /*<<< orphan*/ SO_SNDTIMEO;
int atoi(char *);
int /*<<< orphan*/ bcopy(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr_in *, int);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ usleep(int);
int write(int, char *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int sockfd, portno, n;
  struct sockaddr_in serveraddr;
  struct hostent *server;
  char *hostname;
  char buf[1024];
  int msg = 5;
  struct timeval timeout;
  int i = 0;
  timeout.tv_sec = 5;
  timeout.tv_usec = 0;
  if (argc != 3) {
    fprintf(stderr, "usage: %s <hostname> <port>\n", argv[0]);
    exit(0);
  }
  hostname = argv[1];
  portno = atoi(argv[2]);
  server = gethostbyname(hostname);
  if (server == NULL) {
    fprintf(stderr, "ERROR, no such host as %s\n", hostname);
    exit(0);
  }
  bzero((char *)&serveraddr, sizeof(serveraddr));
  serveraddr.sin_family = AF_INET;
  bcopy((char *)server->h_addr, (char *)&serveraddr.sin_addr.s_addr,
        server->h_length);
  serveraddr.sin_port = htons(portno);
  for (i = 0; i < 5; i++) {
    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if (sockfd < 0)
      error("ERROR opening socket");
    setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout,
               sizeof(timeout));
    setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout,
               sizeof(timeout));
    if (connect(sockfd, &serveraddr, sizeof(serveraddr)) < 0)
      error("ERROR connecting");
    sprintf(buf, "Transmitting Hello World %d", msg);
    n = write(sockfd, buf, strlen(buf));
    if (n < 0)
      error("ERROR writing to socket");
    bzero(buf, 1024);
    n = read(sockfd, buf, 1024);
    if (n < 0)
      error("ERROR reading from socket");
    printf("Echo from server: %s\n", buf);
    close(sockfd);
    fflush(stdout);
    usleep(1000000);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x470,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x5,-0x444(%rbp)
movl   $0x0,-0x45c(%rbp)
movl   $0x5,-0x458(%rbp)
movq   $0x0,-0x450(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     129f <main+0x6f>
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd6d(%rip),%rsi
call   10b0 <fprintf@plt>
xor    %edi,%edi
call   1120 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1100 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x38(%rbp),%rdi
call   10a0 <gethostbyname@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12f3 <main+0xc3>
mov    0x2ce6(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xd36(%rip),%rsi
call   10b0 <fprintf@plt>
xor    %edi,%edi
call   1120 <exit@plt>
lea    -0x28(%rbp),%rdi
mov    $0xc,%esi
call   10f0 <bzero@plt>
mov    0x2cd0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x28(%rbp),%rsi
add    $0x4,%rsi
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
call   10d0 <bcopy@plt>
mov    -0x18(%rbp),%edi
call   1060 <htons@plt>
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x45c(%rbp)
cmpl   $0x5,-0x45c(%rbp)
jge    14df <main+0x2af>
mov    0x2c87(%rip),%rax
mov    (%rax),%edi
mov    0x2c5e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    137c <main+0x14c>
lea    0xcc1(%rip),%rdi
call   10e0 <error@plt>
mov    -0x14(%rbp),%edi
mov    0x2c5a(%rip),%rax
mov    (%rax),%esi
mov    0x2c39(%rip),%rax
mov    (%rax),%edx
lea    -0x458(%rbp),%rcx
mov    $0x10,%r8d
call   1030 <setsockopt@plt>
mov    -0x14(%rbp),%edi
mov    0x2c33(%rip),%rax
mov    (%rax),%esi
mov    0x2c3a(%rip),%rax
mov    (%rax),%edx
lea    -0x458(%rbp),%rcx
mov    $0x10,%r8d
call   1030 <setsockopt@plt>
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   1130 <connect@plt>
cmp    $0x0,%rax
jge    13f1 <main+0x1c1>
lea    0xc61(%rip),%rdi
call   10e0 <error@plt>
lea    -0x440(%rbp),%rdi
mov    -0x444(%rbp),%edx
lea    0xc59(%rip),%rsi
call   1110 <sprintf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x46c(%rbp)
lea    -0x440(%rbp),%rax
mov    %rax,-0x468(%rbp)
lea    -0x440(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x46c(%rbp),%edi
mov    -0x468(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    145a <main+0x22a>
lea    0xc25(%rip),%rdi
call   10e0 <error@plt>
lea    -0x440(%rbp),%rdi
mov    $0x400,%esi
call   10f0 <bzero@plt>
mov    -0x14(%rbp),%edi
lea    -0x440(%rbp),%rsi
mov    $0x400,%edx
call   1090 <read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1498 <main+0x268>
lea    0xbff(%rip),%rdi
call   10e0 <error@plt>
lea    -0x440(%rbp),%rsi
lea    0xc06(%rip),%rdi
call   1070 <printf@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
mov    0x2af6(%rip),%rax
mov    (%rax),%edi
call   10c0 <fflush@plt>
mov    $0xf4240,%edi
call   1140 <usleep@plt>
mov    -0x45c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x45c(%rbp)
jmp    133d <main+0x10d>
xor    %eax,%eax
add    $0x470,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
movl   $0x5,0x10(%rsp)
movq   $0x0,0x18(%rsp)
cmp    $0x3,%edi
jne    1421 <main+0x1f1>
mov    0x8(%rsi),%rbp
mov    0x10(%rsi),%rdi
call   1100 <atoi@plt>
mov    %eax,%r14d
mov    %rbp,%rdi
call   10a0 <gethostbyname@plt>
test   %rax,%rax
je     1436 <main+0x206>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0xc,%esi
call   10f0 <bzero@plt>
mov    0x2d45(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    0x8(%rbx),%rsi
lea    0x4(%rsp),%rdi
mov    (%rbx),%edx
call   10d0 <memmove@plt>
mov    %r14d,%edi
call   1060 <htons@plt>
mov    %eax,(%rsp)
mov    $0x5,%r15d
mov    0x2d1f(%rip),%r13
lea    0x10(%rsp),%rbx
lea    0x20(%rsp),%rbp
lea    0xdda(%rip),%r14
jmp    1315 <main+0xe5>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rbp,%rsi
call   1070 <printf@plt>
mov    %r12d,%edi
call   1080 <close@plt>
mov    0x2cb6(%rip),%rax
mov    (%rax),%edi
call   10c0 <fflush@plt>
mov    $0xf4240,%edi
call   1140 <usleep@plt>
add    $0xffffffff,%r15d
je     140d <main+0x1dd>
mov    0x2cbc(%rip),%rax
mov    (%rax),%edi
mov    0x2c93(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,%r12d
test   %eax,%eax
jns    1341 <main+0x111>
lea    0xcfc(%rip),%rdi
call   10e0 <error@plt>
mov    0x0(%r13),%esi
mov    0x2c7c(%rip),%rax
mov    (%rax),%edx
mov    %r12d,%edi
mov    %rbx,%rcx
mov    $0x10,%r8d
call   1030 <setsockopt@plt>
mov    0x0(%r13),%esi
mov    0x2c86(%rip),%rax
mov    (%rax),%edx
mov    %r12d,%edi
mov    %rbx,%rcx
mov    $0x10,%r8d
call   1030 <setsockopt@plt>
mov    %r12d,%edi
mov    %rsp,%rsi
mov    $0xc,%edx
call   1130 <connect@plt>
test   %rax,%rax
jns    139e <main+0x16e>
lea    0xcb4(%rip),%rdi
call   10e0 <error@plt>
mov    %rbp,%rdi
lea    0xcb6(%rip),%rsi
mov    $0x5,%edx
call   1110 <sprintf@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <write@plt>
test   %eax,%eax
jns    13d7 <main+0x1a7>
lea    0xca8(%rip),%rdi
call   10e0 <error@plt>
mov    %rbp,%rdi
mov    $0x400,%esi
call   10f0 <bzero@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    $0x400,%edx
call   1090 <read@plt>
test   %eax,%eax
jns    12e0 <main+0xb0>
lea    0xc8f(%rip),%rdi
call   10e0 <error@plt>
jmp    12e0 <main+0xb0>
xor    %eax,%eax
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b98(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xbcc(%rip),%rsi
jmp    1449 <main+0x219>
mov    0x2b83(%rip),%rax
mov    (%rax),%edi
lea    0xbd7(%rip),%rsi
mov    %rbp,%rdx
call   10b0 <fprintf@plt>
xor    %edi,%edi
call   1120 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32, i64 }
%struct.timeval = type { i32, i64 }
@stderr = global i32 0
@.str = [29 x i8] c"usage: %s <hostname> <port>\0A\00"
@.str.1 = [27 x i8] c"ERROR, no such host as %s\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [21 x i8] c"ERROR opening socket\00"
@SOL_SOCKET = global i32 0
@SO_RCVTIMEO = global i32 0
@SO_SNDTIMEO = global i32 0
@.str.3 = [17 x i8] c"ERROR connecting\00"
@.str.4 = [28 x i8] c"Transmitting Hello World %d\00"
@.str.5 = [24 x i8] c"ERROR writing to socket\00"
@.str.6 = [26 x i8] c"ERROR reading from socket\00"
@.str.7 = [22 x i8] c"Echo from server: %s\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.sockaddr_in
%10 = alloca %struct.hostent*
%11 = alloca i8*
%12 = alloca [1024 x i8]
%13 = alloca i32
%14 = alloca %struct.timeval
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 5, i32* %13
store i32 0, i32* %15
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
store i32 5, i32* %16
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
store i64 0, i64* %17
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 3
br i1 %19, label %20, label %27
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = call i32 @exit(i32 0)
unreachable
27: ; preds = %2
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
store i8* %30, i8** %11
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = call i32 @atoi(i8* %33)
store i32 %34, i32* %7
%35 = load i8*, i8** %11
%36 = call %struct.hostent* @gethostbyname(i8* %35)
store %struct.hostent* %36, %struct.hostent** %10
%37 = load %struct.hostent*, %struct.hostent** %10
%38 = icmp eq %struct.hostent* %37, null
br i1 %38, label %39, label %44
39: ; preds = %27
%40 = load i32, i32* @stderr
%41 = load i8*, i8** %11
%42 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %41)
%43 = call i32 @exit(i32 0)
unreachable
44: ; preds = %27
%45 = bitcast %struct.sockaddr_in* %9 to i8*
%46 = call i32 @bzero(i8* %45, i32 12)
%47 = load i32, i32* @AF_INET
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %47, i32* %48
%49 = load %struct.hostent*, %struct.hostent** %10
%50 = getelementptr inbounds %struct.hostent, %struct.hostent* %49, i32 0, i32 1
%51 = load i64, i64* %50
%52 = inttoptr i64 %51 to i8*
%53 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
%54 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %53, i32 0, i32 0
%55 = bitcast i32* %54 to i8*
%56 = load %struct.hostent*, %struct.hostent** %10
%57 = getelementptr inbounds %struct.hostent, %struct.hostent* %56, i32 0, i32 0
%58 = load i32, i32* %57
%59 = call i32 @bcopy(i8* %52, i8* %55, i32 %58)
%60 = load i32, i32* %7
%61 = call i32 @htons(i32 %60)
%62 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
store i32 %61, i32* %62
store i32 0, i32* %15
br label %63
63: ; preds = %121, %44
%64 = load i32, i32* %15
%65 = icmp slt i32 %64, 5
br i1 %65, label %66, label %124
66: ; preds = %63
%67 = load i32, i32* @AF_INET
%68 = load i32, i32* @SOCK_STREAM
%69 = call i32 @socket(i32 %67, i32 %68, i32 0)
store i32 %69, i32* %6
%70 = load i32, i32* %6
%71 = icmp slt i32 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %66
%73 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %74
74: ; preds = %72, %66
%75 = load i32, i32* %6
%76 = load i32, i32* @SOL_SOCKET
%77 = load i32, i32* @SO_RCVTIMEO
%78 = bitcast %struct.timeval* %14 to i8*
%79 = call i32 @setsockopt(i32 %75, i32 %76, i32 %77, i8* %78, i32 16)
%80 = load i32, i32* %6
%81 = load i32, i32* @SOL_SOCKET
%82 = load i32, i32* @SO_SNDTIMEO
%83 = bitcast %struct.timeval* %14 to i8*
%84 = call i32 @setsockopt(i32 %80, i32 %81, i32 %82, i8* %83, i32 16)
%85 = load i32, i32* %6
%86 = call i64 @connect(i32 %85, %struct.sockaddr_in* %9, i32 12)
%87 = icmp slt i64 %86, 0
br i1 %87, label %88, label %90
88: ; preds = %74
%89 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %90
90: ; preds = %88, %74
%91 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%92 = load i32, i32* %13
%93 = call i32 @sprintf(i8* %91, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %92)
%94 = load i32, i32* %6
%95 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%96 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%97 = call i32 @strlen(i8* %96)
%98 = call i32 @write(i32 %94, i8* %95, i32 %97)
store i32 %98, i32* %8
%99 = load i32, i32* %8
%100 = icmp slt i32 %99, 0
br i1 %100, label %101, label %103
101: ; preds = %90
%102 = call i32 @error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
br label %103
103: ; preds = %101, %90
%104 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%105 = call i32 @bzero(i8* %104, i32 1024)
%106 = load i32, i32* %6
%107 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%108 = call i32 @read(i32 %106, i8* %107, i32 1024)
store i32 %108, i32* %8
%109 = load i32, i32* %8
%110 = icmp slt i32 %109, 0
br i1 %110, label %111, label %113
111: ; preds = %103
%112 = call i32 @error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
br label %113
113: ; preds = %111, %103
%114 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%115 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %114)
%116 = load i32, i32* %6
%117 = call i32 @close(i32 %116)
%118 = load i32, i32* @stdout
%119 = call i32 @fflush(i32 %118)
%120 = call i32 @usleep(i32 1000000)
br label %121
121: ; preds = %113
%122 = load i32, i32* %15
%123 = add nsw i32 %122, 1
store i32 %123, i32* %15
br label %63
124: ; preds = %63
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.timeval = type { i32, i64 }
%struct.hostent = type { i32, i64 }
@stderr = global i32 0
@.str = [29 x i8] c"usage: %s <hostname> <port>\0A\00"
@.str.1 = [27 x i8] c"ERROR, no such host as %s\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [21 x i8] c"ERROR opening socket\00"
@SOL_SOCKET = global i32 0
@SO_RCVTIMEO = global i32 0
@SO_SNDTIMEO = global i32 0
@.str.3 = [17 x i8] c"ERROR connecting\00"
@.str.4 = [28 x i8] c"Transmitting Hello World %d\00"
@.str.5 = [24 x i8] c"ERROR writing to socket\00"
@.str.6 = [26 x i8] c"ERROR reading from socket\00"
@.str.7 = [22 x i8] c"Echo from server: %s\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca [1024 x i8]
%5 = alloca %struct.timeval
%6 = bitcast %struct.sockaddr_in* %3 to i8*
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%8 = bitcast %struct.timeval* %5 to i8*
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
store i32 5, i32* %9
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
store i64 0, i64* %10
%11 = icmp eq i32 %0, 3
br i1 %11, label %17, label %12
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %1
%15 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = tail call i32 @exit(i32 0)
unreachable
17: ; preds = %2
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = tail call i32 @atoi(i8* %21)
%23 = tail call %struct.hostent* @gethostbyname(i8* %19)
%24 = icmp eq %struct.hostent* %23, null
br i1 %24, label %25, label %29
25: ; preds = %17
%26 = load i32, i32* @stderr
%27 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%28 = tail call i32 @exit(i32 0)
unreachable
29: ; preds = %17
%30 = call i32 @bzero(i8* %6, i32 12)
%31 = load i32, i32* @AF_INET
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %31, i32* %32
%33 = getelementptr inbounds %struct.hostent, %struct.hostent* %23, i64 0, i32 1
%34 = load i64, i64* %33
%35 = inttoptr i64 %34 to i8*
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
%37 = bitcast i32* %36 to i8*
%38 = getelementptr inbounds %struct.hostent, %struct.hostent* %23, i64 0, i32 0
%39 = load i32, i32* %38
%40 = tail call i32 @htons(i32 %22)
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %40, i32* %41
br label %42
42: ; preds = %29, %74
%43 = phi i32 [ 0, %29 ], [ %80, %74 ]
%44 = load i32, i32* @AF_INET
%45 = load i32, i32* @SOCK_STREAM
%46 = call i32 @socket(i32 %44, i32 %45, i32 0)
%47 = icmp slt i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %42
%49 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %50
50: ; preds = %48, %42
%51 = load i32, i32* @SOL_SOCKET
%52 = load i32, i32* @SO_RCVTIMEO
%53 = call i32 @setsockopt(i32 %46, i32 %51, i32 %52, i8* %8, i32 16)
%54 = load i32, i32* @SOL_SOCKET
%55 = load i32, i32* @SO_SNDTIMEO
%56 = call i32 @setsockopt(i32 %46, i32 %54, i32 %55, i8* %8, i32 16)
%57 = call i64 @connect(i32 %46, %struct.sockaddr_in* %3, i32 12)
%58 = icmp slt i64 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %50
%60 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %61
61: ; preds = %59, %50
%62 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 5)
%63 = call i32 @strlen(i8* %7)
%64 = call i32 @write(i32 %46, i8* %7, i32 %63)
%65 = icmp slt i32 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %61
%67 = call i32 @error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
br label %68
68: ; preds = %66, %61
%69 = call i32 @bzero(i8* %7, i32 1024)
%70 = call i32 @read(i32 %46, i8* %7, i32 1024)
%71 = icmp slt i32 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %68
%73 = call i32 @error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
br label %74
74: ; preds = %72, %68
%75 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %7)
%76 = call i32 @close(i32 %46)
%77 = load i32, i32* @stdout
%78 = call i32 @fflush(i32 %77)
%79 = call i32 @usleep(i32 1000000)
%80 = add nuw nsw i32 %43, 1
%81 = icmp eq i32 %80, 5
br i1 %81, label %82, label %42
82: ; preds = %74
ret i32 0
}