#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 */
struct timeval {
  int tv_sec;
  int tv_usec;
};
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct hostent {
  int /*<<< orphan*/ h_length;
  scalar_t__ h_addr;
};
typedef int /*<<< orphan*/ serveraddr;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int atoi(char *);
int /*<<< orphan*/ bcopy(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ htons(int);
char *inet_ntoa(TYPE_1__);
int /*<<< orphan*/ print_time();
int /*<<< orphan*/ printf(char *, ...);
int recvfrom(int, char *, int /*<<< orphan*/, int /*<<< orphan*/,
             struct sockaddr_in *, int *);
int sendto(int, char *, int /*<<< orphan*/, int /*<<< orphan*/,
           struct sockaddr_in *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strlen(char *);
int main(int argc, char **argv) {
  int sockfd, portno, n;
  int serverlen;
  struct sockaddr_in serveraddr;
  struct hostent *server;
  char *hostname;
  char buf[1024];
  if (argc != 4) {
    fprintf(stderr, "usage: %s <hostname> <port>\n", argv[0]);
    exit(0);
  }
  int numMessages = atoi(argv[3]);
  hostname = argv[1];
  portno = atoi(argv[2]);
  sockfd = socket(AF_INET, SOCK_DGRAM, 0);
  if (sockfd < 0)
    error("ERROR opening socket");
  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);
  char *s = inet_ntoa(serveraddr.sin_addr);
  printf("Server IP address : %s\n", s);
  int cc = 0;
  FILE *fp;
  fp = fopen("/home/vignesh/client.txt", "a");
  for (cc = 0; cc < numMessages; cc++) {
    bzero(buf, 1024);
    sprintf(buf, "Ping SEQ %.4d", cc);
    struct timeval sendTimeStamp, JAS_Timestamp;
    gettimeofday(&sendTimeStamp, NULL);
    long sendTS = sendTimeStamp.tv_sec * 1000000 + sendTimeStamp.tv_usec;
    serverlen = sizeof(serveraddr);
    n = sendto(sockfd, buf, strlen(buf), 0, &serveraddr, serverlen);
    printf("Send Time : \n");
    print_time();
    gettimeofday(&JAS_Timestamp, NULL);
    fprintf(fp,
            "Send secs = %d, Send usecs = %d, JAS secs = %d, JAS usecs = %d\n",
            sendTimeStamp.tv_sec, sendTimeStamp.tv_usec, JAS_Timestamp.tv_sec,
            JAS_Timestamp.tv_usec);
    if (n < 0) {
      error("ERROR in sendto");
    }
    n = recvfrom(sockfd, buf, strlen(buf), 0, &serveraddr, &serverlen);
    struct timeval receiveTimestamp;
    gettimeofday(&receiveTimestamp, NULL);
    long recvTS = receiveTimestamp.tv_sec * 1000000 + receiveTimestamp.tv_usec;
    printf("%ld\n", recvTS - sendTS);
    if (n < 0) {
      fclose(fp);
      error("ERROR in recvfrom");
    }
    printf("Echo from server: %s\n", buf);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     1279 <main+0x49>
mov    0x2d76(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd95(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
xor    %edi,%edi
call   1140 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1120 <atoi@plt>
mov    %eax,-0x444(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1120 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
mov    0x2d28(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    12da <main+0xaa>
lea    0xd48(%rip),%rdi
call   10e0 <error@plt>
mov    -0x40(%rbp),%rdi
call   10a0 <gethostbyname@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1315 <main+0xe5>
mov    0x2cd7(%rip),%rax
movslq (%rax),%rdi
mov    -0x40(%rbp),%rdx
lea    0xd2b(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
xor    %edi,%edi
call   1140 <exit@plt>
lea    -0x30(%rbp),%rdi
mov    $0xc,%esi
call   1110 <bzero@plt>
mov    0x2cbe(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rax
mov    (%rax),%edx
call   10d0 <bcopy@plt>
mov    -0x18(%rbp),%edi
call   1060 <htons@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%edi
call   1030 <inet_ntoa@plt>
mov    %rax,-0x450(%rbp)
mov    -0x450(%rbp),%rsi
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x454(%rbp)
lea    0xcdf(%rip),%rdi
lea    0xcf1(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x460(%rbp)
movl   $0x0,-0x454(%rbp)
mov    -0x454(%rbp),%eax
cmp    -0x444(%rbp),%eax
jge    1591 <main+0x361>
lea    -0x440(%rbp),%rdi
mov    $0x400,%esi
call   1110 <bzero@plt>
lea    -0x440(%rbp),%rdi
mov    -0x454(%rbp),%edx
lea    0xca6(%rip),%rsi
call   1130 <sprintf@plt>
lea    -0x468(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
imul   $0xf4240,-0x468(%rbp),%eax
add    -0x464(%rbp),%eax
cltq
mov    %rax,-0x478(%rbp)
movl   $0xc,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x494(%rbp)
lea    -0x440(%rbp),%rax
mov    %rax,-0x490(%rbp)
lea    -0x440(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x494(%rbp),%edi
mov    -0x490(%rbp),%rsi
mov    %eax,%edx
mov    -0x20(%rbp),%r9d
xor    %ecx,%ecx
lea    -0x30(%rbp),%r8
call   1090 <sendto@plt>
mov    %eax,-0x1c(%rbp)
lea    0xc34(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   10f0 <print_time@plt>
lea    -0x470(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
mov    -0x460(%rbp),%rdi
mov    -0x468(%rbp),%edx
mov    -0x464(%rbp),%ecx
mov    -0x470(%rbp),%r8d
mov    -0x46c(%rbp),%r9d
lea    0xbfc(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
cmpl   $0x0,-0x1c(%rbp)
jge    14bd <main+0x28d>
lea    0xc24(%rip),%rdi
call   10e0 <error@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4a4(%rbp)
lea    -0x440(%rbp),%rax
mov    %rax,-0x4a0(%rbp)
lea    -0x440(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x4a4(%rbp),%edi
mov    -0x4a0(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
lea    -0x30(%rbp),%r8
lea    -0x20(%rbp),%r9
call   10c0 <recvfrom@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x480(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
imul   $0xf4240,-0x480(%rbp),%eax
add    -0x47c(%rbp),%eax
cltq
mov    %rax,-0x488(%rbp)
mov    -0x488(%rbp),%rsi
sub    -0x478(%rbp),%rsi
lea    0xbad(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0x0,-0x1c(%rbp)
jge    1568 <main+0x338>
mov    -0x460(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xb8e(%rip),%rdi
call   10e0 <error@plt>
lea    -0x440(%rbp),%rsi
lea    0xb8d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x454(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x454(%rbp)
jmp    13a3 <main+0x173>
xor    %eax,%eax
add    $0x4b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x448,%rsp
mov    %rsi,%rbx
cmp    $0x4,%edi
jne    14b1 <main+0x271>
mov    0x18(%rbx),%rdi
call   1130 <atoi@plt>
mov    %eax,0x8(%rsp)
mov    0x8(%rbx),%r14
mov    0x10(%rbx),%rdi
call   1130 <atoi@plt>
mov    %eax,%r15d
mov    0x2d67(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2d55(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1160 <socket@plt>
mov    %eax,%r12d
test   %eax,%eax
jns    12a7 <main+0x67>
lea    0xd7b(%rip),%rdi
call   10f0 <error@plt>
mov    %r14,%rdi
call   10b0 <gethostbyname@plt>
test   %rax,%rax
je     14c7 <main+0x287>
mov    %rax,%rbx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0xc,%esi
call   1120 <bzero@plt>
mov    0x0(%rbp),%eax
mov    %eax,0x18(%rsp)
mov    0x8(%rbx),%rsi
mov    (%rbx),%edx
mov    %r14,%rdi
call   10e0 <memmove@plt>
mov    %r15d,%edi
call   1070 <htons@plt>
mov    %eax,0x14(%rsp)
mov    0x10(%rsp),%edi
call   1040 <inet_ntoa@plt>
lea    0xd4f(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd56(%rip),%rdi
lea    0xd68(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,0x20(%rsp)
cmpl   $0x0,0x8(%rsp)
jle    149d <main+0x25d>
mov    %r12d,%r15d
lea    0x40(%rsp),%rbx
xor    %r13d,%r13d
mov    %r12d,0x1c(%rsp)
jmp    1360 <main+0x120>
nopl   (%rax)
lea    0xdae(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
add    $0x1,%r13d
cmp    %r13d,0x8(%rsp)
je     149d <main+0x25d>
mov    %rbx,%rdi
mov    $0x400,%esi
call   1120 <bzero@plt>
mov    %rbx,%rdi
lea    0xd09(%rip),%rsi
mov    %r13d,%edx
call   1140 <sprintf@plt>
lea    0x38(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
mov    0x38(%rsp),%r14d
mov    0x3c(%rsp),%r12d
imul   $0xf4240,%r14d,%ebp
add    %r12d,%ebp
movl   $0xc,0xc(%rsp)
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    0xc(%rsp),%r9d
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
lea    0x10(%rsp),%r8
call   10a0 <sendto@plt>
mov    %eax,%r15d
lea    0xd39(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1100 <print_time@plt>
lea    0x30(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
mov    0x30(%rsp),%r8d
mov    0x34(%rsp),%r9d
mov    0x20(%rsp),%rdi
lea    0xc8e(%rip),%rsi
mov    %r14d,%edx
mov    %r12d,%ecx
xor    %eax,%eax
call   10c0 <fprintf@plt>
test   %r15d,%r15d
jns    141e <main+0x1de>
lea    0xcb5(%rip),%rdi
call   10f0 <error@plt>
movslq %ebp,%r14
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    0x1c(%rsp),%r15d
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
lea    0x10(%rsp),%r8
lea    0xc(%rsp),%r9
call   10d0 <recvfrom@plt>
mov    %eax,%ebp
lea    0x28(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
movslq 0x28(%rsp),%rax
imul   $0xf4240,%rax,%rax
movslq 0x2c(%rsp),%rsi
add    %rax,%rsi
sub    %r14,%rsi
lea    0xc6b(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
test   %ebp,%ebp
jns    1340 <main+0x100>
mov    0x20(%rsp),%rdi
call   1050 <fclose@plt>
lea    0xc50(%rip),%rdi
call   10f0 <error@plt>
jmp    1340 <main+0x100>
xor    %eax,%eax
add    $0x448,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b18(%rip),%rax
movslq (%rax),%rdi
mov    (%rbx),%rdx
lea    0xb3b(%rip),%rsi
jmp    14db <main+0x29b>
mov    0x2b02(%rip),%rax
movslq (%rax),%rdi
lea    0xb5a(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
xor    %edi,%edi
call   1150 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32, i64 }
%struct.timeval = type { i32, i32 }
@stderr = global i32 0
@.str = [29 x i8] c"usage: %s <hostname> <port>\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [21 x i8] c"ERROR opening socket\00"
@.str.2 = [27 x i8] c"ERROR, no such host as %s\0A\00"
@.str.3 = [24 x i8] c"Server IP address : %s\0A\00"
@.str.4 = [25 x i8] c"/home/vignesh/client.txt\00"
@.str.5 = [2 x i8] c"a\00"
@.str.6 = [14 x i8] c"Ping SEQ %.4d\00"
@.str.7 = [14 x i8] c"Send Time : \0A\00"
@.str.8 = [64 x i8] c"Send secs = %d, Send usecs = %d, JAS secs = %d, JAS usecs = %d\0A\00"
@.str.9 = [16 x i8] c"ERROR in sendto\00"
@.str.10 = [5 x i8] c"%ld\0A\00"
@.str.11 = [18 x i8] c"ERROR in recvfrom\00"
@.str.12 = [22 x i8] c"Echo from server: %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 i32
%9 = alloca i32
%10 = alloca %struct.sockaddr_in
%11 = alloca %struct.hostent*
%12 = alloca i8*
%13 = alloca [1024 x i8]
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i32*
%18 = alloca %struct.timeval
%19 = alloca %struct.timeval
%20 = alloca i64
%21 = alloca %struct.timeval
%22 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 4
br i1 %24, label %25, label %34
25: ; preds = %2
%26 = load i32, i32* @stderr
%27 = sext i32 %26 to i64
%28 = inttoptr i64 %27 to i32*
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %31)
%33 = call i32 @exit(i32 0)
unreachable
34: ; preds = %2
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 3
%37 = load i8*, i8** %36
%38 = call i32 @atoi(i8* %37)
store i32 %38, i32* %14
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
store i8* %41, i8** %12
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = call i32 @atoi(i8* %44)
store i32 %45, i32* %7
%46 = load i32, i32* @AF_INET
%47 = load i32, i32* @SOCK_DGRAM
%48 = call i32 @socket(i32 %46, i32 %47, i32 0)
store i32 %48, i32* %6
%49 = load i32, i32* %6
%50 = icmp slt i32 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %34
%52 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %53
53: ; preds = %51, %34
%54 = load i8*, i8** %12
%55 = call %struct.hostent* @gethostbyname(i8* %54)
store %struct.hostent* %55, %struct.hostent** %11
%56 = load %struct.hostent*, %struct.hostent** %11
%57 = icmp eq %struct.hostent* %56, null
br i1 %57, label %58, label %65
58: ; preds = %53
%59 = load i32, i32* @stderr
%60 = sext i32 %59 to i64
%61 = inttoptr i64 %60 to i32*
%62 = load i8*, i8** %12
%63 = call i32 (i32*, i8*, ...) @fprintf(i32* %61, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %62)
%64 = call i32 @exit(i32 0)
unreachable
65: ; preds = %53
%66 = bitcast %struct.sockaddr_in* %10 to i8*
%67 = call i32 @bzero(i8* %66, i32 12)
%68 = load i32, i32* @AF_INET
%69 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
store i32 %68, i32* %69
%70 = load %struct.hostent*, %struct.hostent** %11
%71 = getelementptr inbounds %struct.hostent, %struct.hostent* %70, i32 0, i32 1
%72 = load i64, i64* %71
%73 = inttoptr i64 %72 to i8*
%74 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%75 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %74, i32 0, i32 0
%76 = bitcast i32* %75 to i8*
%77 = load %struct.hostent*, %struct.hostent** %11
%78 = getelementptr inbounds %struct.hostent, %struct.hostent* %77, i32 0, i32 0
%79 = load i32, i32* %78
%80 = call i32 @bcopy(i8* %73, i8* %76, i32 %79)
%81 = load i32, i32* %7
%82 = call i32 @htons(i32 %81)
%83 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
store i32 %82, i32* %83
%84 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%85 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %84, i32 0, i32 0
%86 = load i32, i32* %85
%87 = call i8* @inet_ntoa(i32 %86)
store i8* %87, i8** %15
%88 = load i8*, i8** %15
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %88)
store i32 0, i32* %16
%90 = call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %90, i32** %17
store i32 0, i32* %16
br label %91
91: ; preds = %159, %65
%92 = load i32, i32* %16
%93 = load i32, i32* %14
%94 = icmp slt i32 %92, %93
br i1 %94, label %95, label %162
95: ; preds = %91
%96 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%97 = call i32 @bzero(i8* %96, i32 1024)
%98 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%99 = load i32, i32* %16
%100 = call i32 @sprintf(i8* %98, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %99)
%101 = call i32 @gettimeofday(%struct.timeval* %18, i32* null)
%102 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 0
%103 = load i32, i32* %102
%104 = mul nsw i32 %103, 1000000
%105 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 1
%106 = load i32, i32* %105
%107 = add nsw i32 %104, %106
%108 = sext i32 %107 to i64
store i64 %108, i64* %20
store i32 12, i32* %9
%109 = load i32, i32* %6
%110 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%111 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%112 = call i32 @strlen(i8* %111)
%113 = load i32, i32* %9
%114 = call i32 @sendto(i32 %109, i8* %110, i32 %112, i32 0, %struct.sockaddr_in* %10, i32 %113)
store i32 %114, i32* %8
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%116 = call i32 (...) @print_time()
%117 = call i32 @gettimeofday(%struct.timeval* %19, i32* null)
%118 = load i32*, i32** %17
%119 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 0
%120 = load i32, i32* %119
%121 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 1
%122 = load i32, i32* %121
%123 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 0
%124 = load i32, i32* %123
%125 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 1
%126 = load i32, i32* %125
%127 = call i32 (i32*, i8*, ...) @fprintf(i32* %118, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.8, i64 0, i64 0), i32 %120, i32 %122, i32 %124, i32 %126)
%128 = load i32, i32* %8
%129 = icmp slt i32 %128, 0
br i1 %129, label %130, label %132
130: ; preds = %95
%131 = call i32 @error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
br label %132
132: ; preds = %130, %95
%133 = load i32, i32* %6
%134 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%135 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%136 = call i32 @strlen(i8* %135)
%137 = call i32 @recvfrom(i32 %133, i8* %134, i32 %136, i32 0, %struct.sockaddr_in* %10, i32* %9)
store i32 %137, i32* %8
%138 = call i32 @gettimeofday(%struct.timeval* %21, i32* null)
%139 = getelementptr inbounds %struct.timeval, %struct.timeval* %21, i32 0, i32 0
%140 = load i32, i32* %139
%141 = mul nsw i32 %140, 1000000
%142 = getelementptr inbounds %struct.timeval, %struct.timeval* %21, i32 0, i32 1
%143 = load i32, i32* %142
%144 = add nsw i32 %141, %143
%145 = sext i32 %144 to i64
store i64 %145, i64* %22
%146 = load i64, i64* %22
%147 = load i64, i64* %20
%148 = sub nsw i64 %146, %147
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i64 %148)
%150 = load i32, i32* %8
%151 = icmp slt i32 %150, 0
br i1 %151, label %152, label %156
152: ; preds = %132
%153 = load i32*, i32** %17
%154 = call i32 @fclose(i32* %153)
%155 = call i32 @error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
br label %156
156: ; preds = %152, %132
%157 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%158 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), i8* %157)
br label %159
159: ; preds = %156
%160 = load i32, i32* %16
%161 = add nsw i32 %160, 1
store i32 %161, i32* %16
br label %91
162: ; preds = %91
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.timeval = type { i32, i32 }
%struct.hostent = type { i32, i64 }
@stderr = global i32 0
@.str = [29 x i8] c"usage: %s <hostname> <port>\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [21 x i8] c"ERROR opening socket\00"
@.str.2 = [27 x i8] c"ERROR, no such host as %s\0A\00"
@.str.3 = [24 x i8] c"Server IP address : %s\0A\00"
@.str.4 = [25 x i8] c"/home/vignesh/client.txt\00"
@.str.5 = [2 x i8] c"a\00"
@.str.6 = [14 x i8] c"Ping SEQ %.4d\00"
@.str.8 = [64 x i8] c"Send secs = %d, Send usecs = %d, JAS secs = %d, JAS usecs = %d\0A\00"
@.str.9 = [16 x i8] c"ERROR in sendto\00"
@.str.10 = [5 x i8] c"%ld\0A\00"
@.str.11 = [18 x i8] c"ERROR in recvfrom\00"
@.str.12 = [22 x i8] c"Echo from server: %s\0A\00"
@str = [13 x i8] c"Send Time : \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca [1024 x i8]
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
%8 = alloca %struct.timeval
%9 = bitcast i32* %3 to i8*
%10 = bitcast %struct.sockaddr_in* %4 to i8*
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%12 = icmp eq i32 %0, 4
br i1 %12, label %20, label %13
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to i32*
%17 = load i8*, i8** %1
%18 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = tail call i32 @exit(i32 0)
unreachable
20: ; preds = %2
%21 = getelementptr inbounds i8*, i8** %1, i64 3
%22 = load i8*, i8** %21
%23 = tail call i32 @atoi(i8* %22)
%24 = getelementptr inbounds i8*, i8** %1, i64 1
%25 = load i8*, i8** %24
%26 = getelementptr inbounds i8*, i8** %1, i64 2
%27 = load i8*, i8** %26
%28 = tail call i32 @atoi(i8* %27)
%29 = load i32, i32* @AF_INET
%30 = load i32, i32* @SOCK_DGRAM
%31 = tail call i32 @socket(i32 %29, i32 %30, i32 0)
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %20
%34 = tail call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %35
35: ; preds = %33, %20
%36 = tail call %struct.hostent* @gethostbyname(i8* %25)
%37 = icmp eq %struct.hostent* %36, null
br i1 %37, label %38, label %44
38: ; preds = %35
%39 = load i32, i32* @stderr
%40 = sext i32 %39 to i64
%41 = inttoptr i64 %40 to i32*
%42 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%43 = tail call i32 @exit(i32 0)
unreachable
44: ; preds = %35
%45 = call i32 @bzero(i8* %10, i32 12)
%46 = load i32, i32* @AF_INET
%47 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %46, i32* %47
%48 = getelementptr inbounds %struct.hostent, %struct.hostent* %36, i64 0, i32 1
%49 = load i64, i64* %48
%50 = inttoptr i64 %49 to i8*
%51 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0, i32 0
%52 = getelementptr inbounds %struct.hostent, %struct.hostent* %36, i64 0, i32 0
%53 = load i32, i32* %52
%54 = tail call i32 @htons(i32 %28)
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i32 %54, i32* %55
%56 = load i32, i32* %51
%57 = tail call i8* @inet_ntoa(i32 %56)
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %57)
%59 = tail call i32* @fopen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%60 = icmp sgt i32 %23, 0
br i1 %60, label %61, label %112
61: ; preds = %44
%62 = bitcast %struct.timeval* %6 to i8*
%63 = bitcast %struct.timeval* %7 to i8*
%64 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
%65 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
%66 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 0
%67 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 1
%68 = bitcast %struct.timeval* %8 to i8*
%69 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i64 0, i32 0
%70 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i64 0, i32 1
br label %71
71: ; preds = %61, %108
%72 = phi i32 [ 0, %61 ], [ %110, %108 ]
%73 = call i32 @bzero(i8* %11, i32 1024)
%74 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %72)
%75 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%76 = load i32, i32* %64
%77 = mul nsw i32 %76, 1000000
%78 = load i32, i32* %65
%79 = add nsw i32 %77, %78
%80 = sext i32 %79 to i64
store i32 12, i32* %3
%81 = call i32 @strlen(i8* %11)
%82 = load i32, i32* %3
%83 = call i32 @sendto(i32 %31, i8* %11, i32 %81, i32 0, %struct.sockaddr_in* %4, i32 %82)
%84 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%85 = call i32 (...) @print_time()
%86 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%87 = load i32, i32* %66
%88 = load i32, i32* %67
%89 = call i32 (i32*, i8*, ...) @fprintf(i32* %59, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.8, i64 0, i64 0), i32 %76, i32 %78, i32 %87, i32 %88)
%90 = icmp slt i32 %83, 0
br i1 %90, label %91, label %93
91: ; preds = %71
%92 = call i32 @error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
br label %93
93: ; preds = %91, %71
%94 = call i32 @strlen(i8* %11)
%95 = call i32 @recvfrom(i32 %31, i8* %11, i32 %94, i32 0, %struct.sockaddr_in* %4, i32* %3)
%96 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%97 = load i32, i32* %69
%98 = mul nsw i32 %97, 1000000
%99 = load i32, i32* %70
%100 = add nsw i32 %98, %99
%101 = sext i32 %100 to i64
%102 = sub nsw i64 %101, %80
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i64 %102)
%104 = icmp slt i32 %95, 0
br i1 %104, label %105, label %108
105: ; preds = %93
%106 = call i32 @fclose(i32* %59)
%107 = call i32 @error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
br label %108
108: ; preds = %105, %93
%109 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), i8* %11)
%110 = add nuw nsw i32 %72, 1
%111 = icmp eq i32 %110, %23
br i1 %111, label %112, label %71
112: ; preds = %108, %44
ret i32 0
}