#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 timespec {
  int tv_sec;
  unsigned long tv_nsec;
  int /*<<< orphan*/ member_1;
  int /*<<< orphan*/ member_0;
};
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  int /*<<< orphan*/ h_length;
  scalar_t__ h_addr;
};
typedef int ssize_t;
typedef int /*<<< orphan*/ serv_addr;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ SOCK_STREAM;
void *atoi(char *);
int /*<<< orphan*/ bcopy(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, 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 *, ...);
int /*<<< orphan*/ free(char *);
struct hostent *gethostbyname(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ printf(char *, ...);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int strlen(char *);
int /*<<< orphan*/ usleep(int);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  unsigned int burst_i;
  unsigned long counter = 0;
  unsigned long eventCounter = 0;
  unsigned long time = 0;
  int sockfd, portno, n;
  struct sockaddr_in serv_addr;
  struct hostent *server;
  unsigned int eventsPerSec;
  unsigned long sleeptimeNanosec;
  int slow = 0;
  char terminate = 0;
  char buffer[256];
  if (argc < 7) {
    fprintf(
        stderr,
        "usage %s hostname port filename numBursts BurstSize EventsPerSec\n",
        argv[0]);
    exit(0);
  }
  portno = atoi(argv[2]);
  unsigned long numBursts = atoi(argv[4]);
  unsigned long burstSize = atoi(argv[5]);
  eventsPerSec = atoi(argv[6]);
  sleeptimeNanosec = 1000000000 / eventsPerSec;
  printf("sending %f events/sec\n", 1000000000.0 / sleeptimeNanosec);
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
  if (sockfd < 0)
    error("ERROR opening socket");
  server = gethostbyname(argv[1]);
  if (server == NULL) {
    fprintf(stderr, "ERROR, no such host\n");
    exit(0);
  }
  bzero((char *)&serv_addr, sizeof(serv_addr));
  serv_addr.sin_family = AF_INET;
  bcopy((char *)server->h_addr, (char *)&serv_addr.sin_addr.s_addr,
        server->h_length);
  serv_addr.sin_port = htons(portno);
  while (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) <
         0) {
    error("ERROR connecting");
    usleep(500000);
  }
  printf("connection established\n");
  struct timespec tsbeginSend = {0, 0}, tsendSend = {0, 0};
  {
    FILE *fp;
    char *line = NULL;
    size_t len = 0;
    ssize_t read;
    unsigned long endtime;
    fp = fopen(argv[3], "r");
    if (fp == NULL)
      exit(EXIT_FAILURE);
    struct timespec tstart = {0, 0}, tend = {0, 0};
    clock_gettime(CLOCK_MONOTONIC, &tsbeginSend);
    clock_gettime(CLOCK_MONOTONIC, &tstart);
    long gesEvents = numBursts * burstSize;
    while (gesEvents > eventCounter &&
           (read = getline(&line, &len, fp)) != -1) {
      n = write(sockfd, line, strlen(line));
      eventCounter++;
      counter++;
    }
    n = write(sockfd, &terminate, 1);
    fclose(fp);
    if (line)
      free(line);
  }
  clock_gettime(CLOCK_MONOTONIC, &tsendSend);
  time = (tsendSend.tv_sec - tsbeginSend.tv_sec) * 1000000000 +
         tsendSend.tv_nsec - tsbeginSend.tv_nsec;
  printf("time: %f\n", ((double)time / 1000000000));
  printf("events: %lu\n", eventCounter);
  printf("average events/sec: %f\n",
         (double)eventCounter / ((double)time / 1000000000));
  close(sockfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x64(%rbp)
movb   $0x0,-0x65(%rbp)
cmpl   $0x7,-0x8(%rbp)
jge    12bb <main+0x6b>
mov    0x2d33(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd83(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
xor    %edi,%edi
call   1140 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1120 <atoi@plt>
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1120 <atoi@plt>
mov    %rax,-0x178(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   1120 <atoi@plt>
mov    %rax,-0x180(%rbp)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
call   1120 <atoi@plt>
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%ecx
xor    %edx,%edx
mov    $0x3b9aca00,%eax
div    %ecx
mov    %rax,-0x60(%rbp)
movaps 0xcf6(%rip),%xmm0
movq   -0x60(%rbp),%xmm1
punpckldq %xmm0,%xmm1
movapd 0xcf5(%rip),%xmm0
subpd  %xmm0,%xmm1
movaps %xmm1,%xmm0
unpckhpd %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0xcbe(%rip),%xmm0
divsd  %xmm1,%xmm0
lea    0xd25(%rip),%rdi
mov    $0x1,%al
call   1090 <printf@plt>
mov    0x2c8d(%rip),%rax
mov    (%rax),%edi
mov    0x2c64(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1170 <socket@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    1386 <main+0x136>
lea    0xd08(%rip),%rdi
call   10f0 <error@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <gethostbyname@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    13c0 <main+0x170>
mov    0x2c27(%rip),%rax
mov    (%rax),%edi
lea    0xcec(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
xor    %edi,%edi
call   1140 <exit@plt>
lea    -0x48(%rbp),%rdi
mov    $0xc,%esi
call   1110 <bzero@plt>
mov    0x2c13(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x50(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x48(%rbp),%rsi
add    $0x4,%rsi
mov    -0x50(%rbp),%rax
mov    (%rax),%edx
call   10e0 <bcopy@plt>
mov    -0x38(%rbp),%edi
call   1080 <htons@plt>
mov    %eax,-0x48(%rbp)
mov    -0x34(%rbp),%edi
lea    -0x48(%rbp),%rsi
mov    $0xc,%edx
call   1150 <connect@plt>
cmp    $0x0,%rax
jge    1436 <main+0x1e6>
lea    0xc91(%rip),%rdi
call   10f0 <error@plt>
mov    $0x7a120,%edi
call   1160 <usleep@plt>
jmp    1400 <main+0x1b0>
lea    0xc87(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
lea    -0x198(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   10a0 <memset@plt>
lea    -0x1b0(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   10a0 <memset@plt>
movq   $0x0,-0x1c0(%rbp)
movq   $0x0,-0x1c8(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xc4d(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x1b8(%rbp)
cmpq   $0x0,-0x1b8(%rbp)
jne    14b7 <main+0x267>
mov    0x2b10(%rip),%rax
mov    (%rax),%edi
call   1140 <exit@plt>
lea    -0x1f0(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   10a0 <memset@plt>
lea    -0x208(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   10a0 <memset@plt>
mov    0x2afc(%rip),%rax
mov    (%rax),%edi
lea    -0x198(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    0x2ae7(%rip),%rax
mov    (%rax),%edi
lea    -0x1f0(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    -0x178(%rbp),%rax
imul   -0x180(%rbp),%rax
ff
mov    %rax,-0x210(%rbp)
mov    -0x210(%rbp),%rcx
xor    %eax,%eax
cmp    -0x28(%rbp),%rcx
mov    %al,-0x211(%rbp)
jbe    1562 <main+0x312>
mov    -0x1b8(%rbp),%rdx
lea    -0x1c0(%rbp),%rdi
lea    -0x1c8(%rbp),%rsi
call   1130 <getline@plt>
mov    %eax,-0x1cc(%rbp)
cmp    $0xffffffff,%eax
setne  %al
mov    %al,-0x211(%rbp)
mov    -0x211(%rbp),%al
test   $0x1,%al
jne    1575 <main+0x325>
jmp    15cc <main+0x37c>
mov    -0x34(%rbp),%eax
mov    %eax,-0x224(%rbp)
mov    -0x1c0(%rbp),%rax
mov    %rax,-0x220(%rbp)
mov    -0x1c0(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x224(%rbp),%edi
mov    -0x220(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    151d <main+0x2cd>
mov    -0x34(%rbp),%edi
lea    -0x65(%rbp),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x1b8(%rbp),%rdi
call   1060 <fclose@plt>
cmpq   $0x0,-0x1c0(%rbp)
je     1606 <main+0x3b6>
mov    -0x1c0(%rbp),%rdi
call   1030 <free@plt>
mov    0x29d3(%rip),%rax
mov    (%rax),%edi
lea    -0x1b0(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    -0x1b0(%rbp),%eax
mov    -0x198(%rbp),%ecx
sub    %ecx,%eax
imul   $0x3b9aca00,%eax,%eax
cltq
mov    -0x1a8(%rbp),%rcx
add    %rcx,%rax
mov    -0x190(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x30(%rbp)
movq   -0x30(%rbp),%xmm0
movaps 0x9bb(%rip),%xmm1
movaps %xmm1,-0x250(%rbp)
punpckldq %xmm1,%xmm0
movapd 0x9b8(%rip),%xmm1
movaps %xmm1,-0x240(%rbp)
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0x97a(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xa4d(%rip),%rdi
mov    $0x1,%al
call   1090 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xa45(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
movaps -0x250(%rbp),%xmm3
movaps -0x240(%rbp),%xmm2
movq   -0x28(%rbp),%xmm0
punpckldq %xmm3,%xmm0
subpd  %xmm2,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movq   -0x30(%rbp),%xmm1
punpckldq %xmm3,%xmm1
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
movsd  0x910(%rip),%xmm2
divsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
lea    0x9f6(%rip),%rdi
mov    $0x1,%al
call   1090 <printf@plt>
mov    -0x34(%rbp),%edi
call   10b0 <close@plt>
xor    %eax,%eax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rsi,%r12
movb   $0x0,0x7(%rsp)
cmp    $0x6,%edi
jle    158c <main+0x33c>
mov    0x10(%r12),%rdi
call   1120 <atoi@plt>
mov    %rax,%r14
mov    0x20(%r12),%rdi
call   1120 <atoi@plt>
mov    %rax,0x30(%rsp)
mov    0x28(%r12),%rdi
call   1120 <atoi@plt>
mov    %rax,0x20(%rsp)
mov    0x30(%r12),%rdi
call   1120 <atoi@plt>
mov    %rax,%rcx
mov    $0x3b9aca00,%eax
xor    %edx,%edx
div    %ecx
cvtsi2sd %eax,%xmm1
movsd  0xd41(%rip),%xmm0
divsd  %xmm1,%xmm0
lea    0xdb8(%rip),%rdi
mov    $0x1,%al
call   10a0 <printf@plt>
mov    0x2d10(%rip),%r13
mov    0x0(%r13),%edi
mov    0x2ce5(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1170 <socket@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    12fe <main+0xae>
lea    0xda0(%rip),%rdi
call   10f0 <error@plt>
mov    0x8(%r12),%rdi
call   10c0 <gethostbyname@plt>
test   %rax,%rax
je     15ae <main+0x35e>
mov    %rax,%rbp
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    $0xc,%esi
call   1110 <bzero@plt>
mov    0x0(%r13),%eax
mov    %eax,0x18(%rsp)
mov    0x8(%rbp),%rsi
lea    0x14(%rsp),%rdi
mov    0x0(%rbp),%edx
call   10e0 <memmove@plt>
mov    %r14d,%edi
call   1090 <htons@plt>
mov    %eax,0x10(%rsp)
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0xc,%edx
call   1150 <connect@plt>
test   %rax,%rax
jns    1396 <main+0x146>
lea    0xd5d(%rip),%r14
lea    0x10(%rsp),%rbp
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   10f0 <error@plt>
mov    $0x7a120,%edi
call   1160 <usleep@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0xc,%edx
call   1150 <connect@plt>
test   %rax,%rax
js     1370 <main+0x120>
mov    %ebx,%r15d
lea    0xd65(%rip),%rdi
call   1040 <puts@plt>
xorpd  %xmm0,%xmm0
movapd %xmm0,0x60(%rsp)
movq   $0x0,0x70(%rsp)
movapd %xmm0,0x40(%rsp)
movq   $0x0,0x50(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x38(%rsp)
mov    0x18(%r12),%rdi
lea    0xcef(%rip),%rsi
call   1100 <fopen@plt>
test   %rax,%rax
je     15cc <main+0x37c>
mov    %rax,%rbp
xorpd  %xmm0,%xmm0
movapd %xmm0,0x80(%rsp)
movq   $0x0,0x90(%rsp)
mov    0x2bca(%rip),%r14
mov    (%r14),%edi
lea    0x60(%rsp),%rsi
call   1050 <clock_gettime@plt>
mov    (%r14),%edi
lea    0x80(%rsp),%rsi
call   1050 <clock_gettime@plt>
mov    0x20(%rsp),%rax
imul   0x30(%rsp),%rax
test   %rax,%rax
je     1494 <main+0x244>
mov    %rax,%r13
xor    %ebx,%ebx
lea    0x38(%rsp),%r12
nopl   (%rax)
lea    0x8(%rsp),%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1130 <getline@plt>
cmp    $0xffffffff,%eax
je     148b <main+0x23b>
mov    0x8(%rsp),%r14
mov    %r14,%rdi
call   1080 <strlen@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1060 <write@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1450 <main+0x200>
mov    %r13,%rbx
mov    0x2b4e(%rip),%r14
jmp    1496 <main+0x246>
xor    %ebx,%ebx
lea    0x7(%rsp),%rsi
mov    %r15d,%edi
mov    $0x1,%edx
call   1060 <write@plt>
mov    %rbp,%rdi
call   1070 <fclose@plt>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     14bf <main+0x26f>
call   1030 <free@plt>
mov    (%r14),%edi
lea    0x40(%rsp),%rsi
call   1050 <clock_gettime@plt>
movslq 0x40(%rsp),%rax
movslq 0x60(%rsp),%rcx
sub    %rcx,%rax
imul   $0x3b9aca00,%rax,%rax
mov    0x48(%rsp),%rcx
sub    0x68(%rsp),%rcx
add    %rax,%rcx
movq   %rcx,%xmm1
punpckldq 0xb16(%rip),%xmm1
subpd  0xb1e(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
divsd  0xaea(%rip),%xmm0
movapd %xmm0,0x20(%rsp)
lea    0xbb3(%rip),%rdi
mov    $0x1,%al
call   10a0 <printf@plt>
lea    0xbaf(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
movq   %rbx,%xmm1
punpckldq 0xac8(%rip),%xmm1
subpd  0xad0(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
divsd  0x20(%rsp),%xmm0
lea    0xb84(%rip),%rdi
mov    $0x1,%al
call   10a0 <printf@plt>
mov    %r15d,%edi
call   10b0 <close@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2a3d(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%rdx
lea    0xaa0(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
xor    %edi,%edi
call   1140 <exit@plt>
mov    0x2a1b(%rip),%rax
mov    (%rax),%edi
lea    0xaf0(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
xor    %edi,%edi
call   1140 <exit@plt>
mov    0x29ed(%rip),%rax
mov    (%rax),%edi
call   1140 <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.timespec = type { i32, i64, i32, i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [66 x i8] c"usage %s hostname port filename numBursts BurstSize EventsPerSec\0A\00"
@.str.1 = [23 x i8] c"sending %f events/sec\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [21 x i8] c"ERROR opening socket\00"
@.str.3 = [21 x i8] c"ERROR, no such host\0A\00"
@.str.4 = [17 x i8] c"ERROR connecting\00"
@.str.5 = [24 x i8] c"connection established\0A\00"
@.str.6 = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@CLOCK_MONOTONIC = global i32 0
@.str.7 = [10 x i8] c"time: %f\0A\00"
@.str.8 = [13 x i8] c"events: %lu\0A\00"
@.str.9 = [24 x i8] c"average events/sec: %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca %struct.sockaddr_in
%14 = alloca %struct.hostent*
%15 = alloca i32
%16 = alloca i64
%17 = alloca i32
%18 = alloca i8
%19 = alloca [256 x i8]
%20 = alloca i64
%21 = alloca i64
%22 = alloca %struct.timespec
%23 = alloca %struct.timespec
%24 = alloca i32*
%25 = alloca i8*
%26 = alloca i64
%27 = alloca i32
%28 = alloca i64
%29 = alloca %struct.timespec
%30 = alloca %struct.timespec
%31 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %7
store i64 0, i64* %8
store i64 0, i64* %9
store i32 0, i32* %17
store i8 0, i8* %18
%32 = load i32, i32* %4
%33 = icmp slt i32 %32, 7
br i1 %33, label %34, label %41
34: ; preds = %2
%35 = load i32, i32* @stderr
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 0
%38 = load i8*, i8** %37
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i8* %38)
%40 = call i32 @exit(i32 0)
unreachable
41: ; preds = %2
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = call i8* @atoi(i8* %44)
%46 = ptrtoint i8* %45 to i32
store i32 %46, i32* %11
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 4
%49 = load i8*, i8** %48
%50 = call i8* @atoi(i8* %49)
%51 = ptrtoint i8* %50 to i64
store i64 %51, i64* %20
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 5
%54 = load i8*, i8** %53
%55 = call i8* @atoi(i8* %54)
%56 = ptrtoint i8* %55 to i64
store i64 %56, i64* %21
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 6
%59 = load i8*, i8** %58
%60 = call i8* @atoi(i8* %59)
%61 = ptrtoint i8* %60 to i32
store i32 %61, i32* %15
%62 = load i32, i32* %15
%63 = udiv i32 1000000000, %62
%64 = zext i32 %63 to i64
store i64 %64, i64* %16
%65 = load i64, i64* %16
%66 = uitofp i64 %65 to double
%67 = fdiv double 1.000000e+09, %66
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), double %67)
%69 = load i32, i32* @AF_INET
%70 = load i32, i32* @SOCK_STREAM
%71 = call i32 @socket(i32 %69, i32 %70, i32 0)
store i32 %71, i32* %10
%72 = load i32, i32* %10
%73 = icmp slt i32 %72, 0
br i1 %73, label %74, label %76
74: ; preds = %41
%75 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %76
76: ; preds = %74, %41
%77 = load i8**, i8*** %5
%78 = getelementptr inbounds i8*, i8** %77, i64 1
%79 = load i8*, i8** %78
%80 = call %struct.hostent* @gethostbyname(i8* %79)
store %struct.hostent* %80, %struct.hostent** %14
%81 = load %struct.hostent*, %struct.hostent** %14
%82 = icmp eq %struct.hostent* %81, null
br i1 %82, label %83, label %87
83: ; preds = %76
%84 = load i32, i32* @stderr
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%86 = call i32 @exit(i32 0)
unreachable
87: ; preds = %76
%88 = bitcast %struct.sockaddr_in* %13 to i8*
%89 = call i32 @bzero(i8* %88, i32 12)
%90 = load i32, i32* @AF_INET
%91 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 2
store i32 %90, i32* %91
%92 = load %struct.hostent*, %struct.hostent** %14
%93 = getelementptr inbounds %struct.hostent, %struct.hostent* %92, i32 0, i32 1
%94 = load i64, i64* %93
%95 = inttoptr i64 %94 to i8*
%96 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 1
%97 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %96, i32 0, i32 0
%98 = bitcast i32* %97 to i8*
%99 = load %struct.hostent*, %struct.hostent** %14
%100 = getelementptr inbounds %struct.hostent, %struct.hostent* %99, i32 0, i32 0
%101 = load i32, i32* %100
%102 = call i32 @bcopy(i8* %95, i8* %98, i32 %101)
%103 = load i32, i32* %11
%104 = call i32 @htons(i32 %103)
%105 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 0
store i32 %104, i32* %105
br label %106
106: ; preds = %111, %87
%107 = load i32, i32* %10
%108 = bitcast %struct.sockaddr_in* %13 to %struct.sockaddr*
%109 = call i64 @connect(i32 %107, %struct.sockaddr* %108, i32 12)
%110 = icmp slt i64 %109, 0
br i1 %110, label %111, label %114
111: ; preds = %106
%112 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%113 = call i32 @usleep(i32 500000)
br label %106
114: ; preds = %106
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%116 = bitcast %struct.timespec* %22 to i8*
%117 = bitcast %struct.timespec* %23 to i8*
store i8* null, i8** %25
store i64 0, i64* %26
%118 = load i8**, i8*** %5
%119 = getelementptr inbounds i8*, i8** %118, i64 3
%120 = load i8*, i8** %119
%121 = call i32* @fopen(i8* %120, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %121, i32** %24
%122 = load i32*, i32** %24
%123 = icmp eq i32* %122, null
br i1 %123, label %124, label %127
124: ; preds = %114
%125 = load i32, i32* @EXIT_FAILURE
%126 = call i32 @exit(i32 %125)
unreachable
127: ; preds = %114
%128 = bitcast %struct.timespec* %29 to i8*
%129 = bitcast %struct.timespec* %30 to i8*
%130 = load i32, i32* @CLOCK_MONOTONIC
%131 = call i32 @clock_gettime(i32 %130, %struct.timespec* %22)
%132 = load i32, i32* @CLOCK_MONOTONIC
%133 = call i32 @clock_gettime(i32 %132, %struct.timespec* %29)
%134 = load i64, i64* %20
%135 = load i64, i64* %21
%136 = mul i64 %134, %135
store i64 %136, i64* %31
br label %137
137: ; preds = %147, %127
%138 = load i64, i64* %31
%139 = load i64, i64* %8
%140 = icmp ugt i64 %138, %139
br i1 %140, label %141, label %145
141: ; preds = %137
%142 = load i32*, i32** %24
%143 = call i32 @getline(i8** %25, i64* %26, i32* %142)
store i32 %143, i32* %27
%144 = icmp ne i32 %143, -1
br label %145
145: ; preds = %141, %137
%146 = phi i1 [ false, %137 ], [ %144, %141 ]
br i1 %146, label %147, label %157
147: ; preds = %145
%148 = load i32, i32* %10
%149 = load i8*, i8** %25
%150 = load i8*, i8** %25
%151 = call i32 @strlen(i8* %150)
%152 = call i32 @write(i32 %148, i8* %149, i32 %151)
store i32 %152, i32* %12
%153 = load i64, i64* %8
%154 = add i64 %153, 1
store i64 %154, i64* %8
%155 = load i64, i64* %7
%156 = add i64 %155, 1
store i64 %156, i64* %7
br label %137
157: ; preds = %145
%158 = load i32, i32* %10
%159 = call i32 @write(i32 %158, i8* %18, i32 1)
store i32 %159, i32* %12
%160 = load i32*, i32** %24
%161 = call i32 @fclose(i32* %160)
%162 = load i8*, i8** %25
%163 = icmp ne i8* %162, null
br i1 %163, label %164, label %167
164: ; preds = %157
%165 = load i8*, i8** %25
%166 = call i32 @free(i8* %165)
br label %167
167: ; preds = %164, %157
%168 = load i32, i32* @CLOCK_MONOTONIC
%169 = call i32 @clock_gettime(i32 %168, %struct.timespec* %23)
%170 = getelementptr inbounds %struct.timespec, %struct.timespec* %23, i32 0, i32 0
%171 = load i32, i32* %170
%172 = getelementptr inbounds %struct.timespec, %struct.timespec* %22, i32 0, i32 0
%173 = load i32, i32* %172
%174 = sub nsw i32 %171, %173
%175 = mul nsw i32 %174, 1000000000
%176 = sext i32 %175 to i64
%177 = getelementptr inbounds %struct.timespec, %struct.timespec* %23, i32 0, i32 1
%178 = load i64, i64* %177
%179 = add i64 %176, %178
%180 = getelementptr inbounds %struct.timespec, %struct.timespec* %22, i32 0, i32 1
%181 = load i64, i64* %180
%182 = sub i64 %179, %181
store i64 %182, i64* %9
%183 = load i64, i64* %9
%184 = uitofp i64 %183 to double
%185 = fdiv double %184, 1.000000e+09
%186 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), double %185)
%187 = load i64, i64* %8
%188 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i64 %187)
%189 = load i64, i64* %8
%190 = uitofp i64 %189 to double
%191 = load i64, i64* %9
%192 = uitofp i64 %191 to double
%193 = fdiv double %192, 1.000000e+09
%194 = fdiv double %190, %193
%195 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), double %194)
%196 = load i32, i32* %10
%197 = call i32 @close(i32 %196)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.timespec = type { i32, i64, i32, i32 }
%struct.hostent = type { i32, i64 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [66 x i8] c"usage %s hostname port filename numBursts BurstSize EventsPerSec\0A\00"
@.str.1 = [23 x i8] c"sending %f events/sec\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [21 x i8] c"ERROR opening socket\00"
@.str.3 = [21 x i8] c"ERROR, no such host\0A\00"
@.str.4 = [17 x i8] c"ERROR connecting\00"
@.str.6 = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@CLOCK_MONOTONIC = global i32 0
@.str.7 = [10 x i8] c"time: %f\0A\00"
@.str.8 = [13 x i8] c"events: %lu\0A\00"
@.str.9 = [24 x i8] c"average events/sec: %f\0A\00"
@str = [23 x i8] c"connection established\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i8
%5 = alloca %struct.timespec
%6 = alloca %struct.timespec
%7 = alloca i8*
%8 = alloca i64
%9 = alloca %struct.timespec
%10 = bitcast %struct.sockaddr_in* %3 to i8*
store i8 0, i8* %4
%11 = icmp slt i32 %0, 7
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %1
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([66 x i8], [66 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 2
%19 = load i8*, i8** %18
%20 = tail call i8* @atoi(i8* %19)
%21 = ptrtoint i8* %20 to i64
%22 = trunc i64 %21 to i32
%23 = getelementptr inbounds i8*, i8** %1, i64 4
%24 = load i8*, i8** %23
%25 = tail call i8* @atoi(i8* %24)
%26 = ptrtoint i8* %25 to i64
%27 = getelementptr inbounds i8*, i8** %1, i64 5
%28 = load i8*, i8** %27
%29 = tail call i8* @atoi(i8* %28)
%30 = ptrtoint i8* %29 to i64
%31 = getelementptr inbounds i8*, i8** %1, i64 6
%32 = load i8*, i8** %31
%33 = tail call i8* @atoi(i8* %32)
%34 = ptrtoint i8* %33 to i64
%35 = trunc i64 %34 to i32
%36 = udiv i32 1000000000, %35
%37 = uitofp i32 %36 to double
%38 = fdiv double 1.000000e+09, %37
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), double %38)
%40 = load i32, i32* @AF_INET
%41 = load i32, i32* @SOCK_STREAM
%42 = tail call i32 @socket(i32 %40, i32 %41, i32 0)
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %17
%45 = tail call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %46
46: ; preds = %44, %17
%47 = getelementptr inbounds i8*, i8** %1, i64 1
%48 = load i8*, i8** %47
%49 = tail call %struct.hostent* @gethostbyname(i8* %48)
%50 = icmp eq %struct.hostent* %49, null
br i1 %50, label %51, label %55
51: ; preds = %46
%52 = load i32, i32* @stderr
%53 = tail call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%54 = tail call i32 @exit(i32 0)
unreachable
55: ; preds = %46
%56 = call i32 @bzero(i8* %10, i32 12)
%57 = load i32, i32* @AF_INET
%58 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %57, i32* %58
%59 = getelementptr inbounds %struct.hostent, %struct.hostent* %49, i64 0, i32 1
%60 = load i64, i64* %59
%61 = inttoptr i64 %60 to i8*
%62 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
%63 = bitcast i32* %62 to i8*
%64 = getelementptr inbounds %struct.hostent, %struct.hostent* %49, i64 0, i32 0
%65 = load i32, i32* %64
%66 = tail call i32 @htons(i32 %22)
%67 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %66, i32* %67
%68 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%69 = call i64 @connect(i32 %42, %struct.sockaddr* %68, i32 12)
%70 = icmp slt i64 %69, 0
br i1 %70, label %71, label %76
71: ; preds = %55, %71
%72 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%73 = call i32 @usleep(i32 500000)
%74 = call i64 @connect(i32 %42, %struct.sockaddr* %68, i32 12)
%75 = icmp slt i64 %74, 0
br i1 %75, label %71, label %76
76: ; preds = %71, %55
%77 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%78 = bitcast %struct.timespec* %5 to i8*
%79 = bitcast %struct.timespec* %6 to i8*
%80 = bitcast i8** %7 to i8*
store i8* null, i8** %7
%81 = bitcast i64* %8 to i8*
store i64 0, i64* %8
%82 = getelementptr inbounds i8*, i8** %1, i64 3
%83 = load i8*, i8** %82
%84 = call i32* @fopen(i8* %83, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%85 = icmp eq i32* %84, null
br i1 %85, label %86, label %89
86: ; preds = %76
%87 = load i32, i32* @EXIT_FAILURE
%88 = call i32 @exit(i32 %87)
unreachable
89: ; preds = %76
%90 = bitcast %struct.timespec* %9 to i8*
%91 = load i32, i32* @CLOCK_MONOTONIC
%92 = call i32 @clock_gettime(i32 %91, %struct.timespec* %5)
%93 = load i32, i32* @CLOCK_MONOTONIC
%94 = call i32 @clock_gettime(i32 %93, %struct.timespec* %9)
%95 = mul i64 %30, %26
%96 = icmp eq i64 %95, 0
br i1 %96, label %107, label %97
97: ; preds = %89, %101
%98 = phi i64 [ %105, %101 ], [ 0, %89 ]
%99 = call i32 @getline(i8** %7, i64* %8, i32* %84)
%100 = icmp eq i32 %99, -1
br i1 %100, label %107, label %101
101: ; preds = %97
%102 = load i8*, i8** %7
%103 = call i32 @strlen(i8* %102)
%104 = call i32 @write(i32 %42, i8* %102, i32 %103)
%105 = add nuw i64 %98, 1
%106 = icmp eq i64 %105, %95
br i1 %106, label %107, label %97
107: ; preds = %97, %101, %89
%108 = phi i64 [ 0, %89 ], [ %95, %101 ], [ %98, %97 ]
%109 = call i32 @write(i32 %42, i8* %4, i32 1)
%110 = call i32 @fclose(i32* %84)
%111 = load i8*, i8** %7
%112 = icmp eq i8* %111, null
br i1 %112, label %115, label %113
113: ; preds = %107
%114 = call i32 @free(i8* %111)
br label %115
115: ; preds = %113, %107
%116 = load i32, i32* @CLOCK_MONOTONIC
%117 = call i32 @clock_gettime(i32 %116, %struct.timespec* %6)
%118 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%119 = load i32, i32* %118
%120 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 0
%121 = load i32, i32* %120
%122 = sub nsw i32 %119, %121
%123 = mul nsw i32 %122, 1000000000
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 1
%126 = load i64, i64* %125
%127 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 1
%128 = load i64, i64* %127
%129 = sub i64 %126, %128
%130 = add i64 %129, %124
%131 = uitofp i64 %130 to double
%132 = fdiv double %131, 1.000000e+09
%133 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), double %132)
%134 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i64 %108)
%135 = uitofp i64 %108 to double
%136 = fdiv double %135, %132
%137 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), double %136)
%138 = call i32 @close(i32 %42)
ret i32 0
}