#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 uint;
struct timeval {
  double tv_sec;
  double tv_usec;
};
struct stat {
  int st_size;
};
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;
};
typedef int /*<<< orphan*/ servaddr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int ECONNREFUSED;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ SOCK_DGRAM;
int atoi(char *);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ close(int);
int errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fstat(int, struct stat *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
scalar_t__ isNumber(char *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int, char *, int);
int sendto(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usleep(int);
int main(int argc, char *argv[]) {
  uint slotLength = 10000;
  uint quota = 1000000000;
  uint sentInSlot = 0, slot = 1;
  uint total_bytes_sent = 0;
  double elapsedTime;
  struct timeval t_start, t_end, t_now;
  int fd;
  int sockfd;
  char sendbuf[65536];
  struct sockaddr_in servaddr;
  int ret;
  int sendsize = 1472;
  int bytes2send = 0;
  struct stat st;
  if (argc < 4) {
    printf("Usage: %s <bytes2send/file2send> <ip> <port> <[optional] bandwidth "
           "(bps)>  <[optional] sendsize (bytes)>\n",
           argv[0]);
    exit(0);
  }
  if (argc > 4)
    quota = atoi(argv[4]) / 8 / (1000000 / slotLength);
  if (argc > 5)
    sendsize = atoi(argv[5]);
  if ((quota % sendsize) > 0) {
    slotLength =
        (uint)((double)(quota / sendsize + 1) * sendsize / quota * slotLength);
    quota = (quota / sendsize + 1) * sendsize;
  }
  if (isNumber(argv[1])) {
    bytes2send = atoi(argv[1]);
    fd = open("/data/local/tmp/bigfile", O_RDONLY);
    if (fd == -1) {
      fprintf(stderr, "! Unable to open /data/local/tmp/bigfile.\n");
      exit(1);
    }
  } else {
    fd = open(argv[1], O_RDONLY);
    if (fd == -1) {
      fprintf(stderr, "! Unable to open file %s.\n", argv[1]);
      exit(1);
    }
    fstat(fd, &st);
    bytes2send = st.st_size;
    printf("bytes2send:%d\n", bytes2send);
  }
  sockfd = socket(AF_INET, SOCK_DGRAM, 0);
  bzero(&servaddr, sizeof(servaddr));
  servaddr.sin_family = AF_INET;
  servaddr.sin_addr.s_addr = inet_addr(argv[2]);
  servaddr.sin_port = htons(atoi(argv[3]));
  gettimeofday(&t_start, NULL);
  while (total_bytes_sent < bytes2send) {
    if ((bytes2send - total_bytes_sent) < quota) {
      quota = bytes2send - total_bytes_sent;
    }
    ret = 1;
    while (sentInSlot < quota) {
      if (ret > 0)
        read(fd, sendbuf,
             (quota - sentInSlot < sendsize) ? (quota - sentInSlot) : sendsize);
      ret = sendto(sockfd, sendbuf,
                   (quota - sentInSlot < sendsize) ? (quota - sentInSlot)
                                                   : sendsize,
                   0, (struct sockaddr *)&servaddr, sizeof(servaddr));
      if (ret <= 0) {
        if (errno == ECONNREFUSED) {
          fprintf(stderr, "! Connection refused; cannot connect to server.\n");
          close(sockfd);
          close(fd);
          exit(1);
        }
        fprintf(stderr, "! Fail to send: ret:%d, err:%d; wait for 100us..\n",
                ret, errno);
        usleep(100);
        continue;
      }
      total_bytes_sent += ret;
      sentInSlot += ret;
    }
    gettimeofday(&t_now, NULL);
    elapsedTime = (t_now.tv_sec - t_start.tv_sec) * 1000000.0 +
                  (t_now.tv_usec - t_start.tv_usec);
    if (elapsedTime < slotLength * slot) {
      usleep((int)(slotLength * slot - elapsedTime));
    }
    sentInSlot = 0;
    ++slot;
  }
  ret = sendto(sockfd, "=?!\n", 4, 0, (struct sockaddr *)&servaddr,
               sizeof(servaddr));
  if (ret <= 0) {
    fprintf(stderr, "! Unable to end data transfer. errno:%d.\n", errno);
    close(sockfd);
    close(fd);
    exit(1);
  }
  gettimeofday(&t_end, NULL);
  elapsedTime = (t_end.tv_sec - t_start.tv_sec) +
                (t_end.tv_usec - t_start.tv_usec) / 1000000.0;
  printf("sent(bytes):%d\nduration(s):%lf\nthroughput(bps):%lf\n",
         total_bytes_sent, elapsedTime, total_bytes_sent * 8 / elapsedTime);
  close(sockfd);
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x2710,-0x14(%rbp)
movl   $0x3b9aca00,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x5c0,-0x10088(%rbp)
movl   $0x0,-0x1008c(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    1276 <main+0x76>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
cmpl   $0x4,-0x8(%rbp)
jle    12b2 <main+0xb2>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10e0 <atoi@plt>
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10094(%rbp)
mov    $0xf4240,%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,%ecx
mov    -0x10094(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
cmpl   $0x5,-0x8(%rbp)
jle    12cf <main+0xcf>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x10088(%rbp)
mov    -0x18(%rbp),%eax
cltd
idivl  -0x10088(%rbp)
cmp    $0x0,%edx
jle    132f <main+0x12f>
mov    -0x18(%rbp),%eax
cltd
idivl  -0x10088(%rbp)
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
cvtsi2sdl -0x10088(%rbp),%xmm1
ff
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
cltd
idivl  -0x10088(%rbp)
add    $0x1,%eax
imul   -0x10088(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <isNumber@plt>
cmp    $0x0,%rax
je     13a1 <main+0x1a1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x1008c(%rbp)
mov    0x2c80(%rip),%rax
mov    (%rax),%esi
lea    0xd09(%rip),%rdi
call   10c0 <open@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0xffffffff,-0x64(%rbp)
jne    139c <main+0x19c>
mov    0x2c3e(%rip),%rax
mov    (%rax),%edi
lea    0xcff(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    141c <main+0x21c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2c30(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0xffffffff,-0x64(%rbp)
jne    13ed <main+0x1ed>
mov    0x2bf5(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xcd9(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x64(%rbp),%edi
lea    -0x10090(%rbp),%rsi
call   1100 <fstat@plt>
mov    -0x10090(%rbp),%eax
mov    %eax,-0x1008c(%rbp)
mov    -0x1008c(%rbp),%esi
lea    0xcbb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2bc5(%rip),%rax
mov    (%rax),%edi
mov    0x2ba4(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x68(%rbp)
lea    -0x10080(%rbp),%rdi
mov    $0xc,%esi
call   10d0 <bzero@plt>
mov    0x2b98(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10078(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <inet_addr@plt>
mov    %eax,-0x1007c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,%edi
call   1030 <htons@plt>
mov    %eax,-0x10080(%rbp)
lea    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x24(%rbp),%eax
cmp    -0x1008c(%rbp),%eax
jge    16d9 <main+0x4d9>
mov    -0x1008c(%rbp),%eax
sub    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    14bf <main+0x2bf>
mov    -0x1008c(%rbp),%eax
sub    -0x24(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x1,-0x10084(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    165b <main+0x45b>
cmpl   $0x0,-0x10084(%rbp)
jle    1540 <main+0x340>
mov    -0x64(%rbp),%eax
mov    %eax,-0x100a4(%rbp)
lea    -0x10070(%rbp),%rax
mov    %rax,-0x100a0(%rbp)
mov    -0x18(%rbp),%eax
sub    -0x1c(%rbp),%eax
cmp    -0x10088(%rbp),%eax
jge    151c <main+0x31c>
mov    -0x18(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x100a8(%rbp)
jmp    1528 <main+0x328>
mov    -0x10088(%rbp),%eax
mov    %eax,-0x100a8(%rbp)
mov    -0x100a0(%rbp),%rsi
mov    -0x100a4(%rbp),%edi
mov    -0x100a8(%rbp),%edx
call   1080 <read@plt>
mov    -0x68(%rbp),%eax
mov    %eax,-0x100b4(%rbp)
lea    -0x10070(%rbp),%rax
mov    %rax,-0x100b0(%rbp)
mov    -0x18(%rbp),%eax
sub    -0x1c(%rbp),%eax
cmp    -0x10088(%rbp),%eax
jge    157a <main+0x37a>
mov    -0x18(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x100b8(%rbp)
jmp    1586 <main+0x386>
mov    -0x10088(%rbp),%eax
mov    %eax,-0x100b8(%rbp)
mov    -0x100b0(%rbp),%rsi
mov    -0x100b4(%rbp),%edi
mov    -0x100b8(%rbp),%edx
lea    -0x10080(%rbp),%r8
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1060 <sendto@plt>
mov    %eax,-0x10084(%rbp)
cmpl   $0x0,-0x10084(%rbp)
jg     163e <main+0x43e>
mov    0x29f1(%rip),%rax
mov    (%rax),%eax
mov    0x2a08(%rip),%rcx
cmp    (%rcx),%eax
jne    1609 <main+0x409>
mov    0x29e1(%rip),%rax
mov    (%rax),%edi
lea    0xaf7(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x68(%rbp),%edi
call   1070 <close@plt>
mov    -0x64(%rbp),%edi
call   1070 <close@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x29b0(%rip),%rax
mov    (%rax),%edi
mov    -0x10084(%rbp),%edx
mov    0x2999(%rip),%rax
mov    (%rax),%ecx
lea    0xae8(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x64,%edi
call   1110 <usleep@plt>
jmp    14c9 <main+0x2c9>
mov    -0x10084(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10084(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    14c9 <main+0x2c9>
lea    -0x60(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
movsd  -0x60(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
subsd  -0x38(%rbp),%xmm1
movsd  0x97c(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
mov    -0x14(%rbp),%eax
imul   -0x20(%rbp),%eax
cvtsi2sd %eax,%xmm0
ucomisd %xmm1,%xmm0
jbe    16c4 <main+0x4c4>
mov    -0x14(%rbp),%eax
imul   -0x20(%rbp),%eax
cvtsi2sd %eax,%xmm0
subsd  -0x30(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1110 <usleep@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1492 <main+0x292>
mov    -0x68(%rbp),%edi
lea    -0x10080(%rbp),%r8
lea    0xa58(%rip),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1060 <sendto@plt>
mov    %eax,-0x10084(%rbp)
cmpl   $0x0,-0x10084(%rbp)
jg     1749 <main+0x549>
mov    0x28aa(%rip),%rax
mov    (%rax),%edi
mov    0x2899(%rip),%rax
mov    (%rax),%edx
lea    0xa1f(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x68(%rbp),%edi
call   1070 <close@plt>
mov    -0x64(%rbp),%edi
call   1070 <close@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
movsd  -0x50(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
subsd  -0x38(%rbp),%xmm1
movsd  0x88e(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x24(%rbp),%esi
movsd  -0x30(%rbp),%xmm0
mov    -0x24(%rbp),%eax
shl    $0x3,%eax
cvtsi2sd %eax,%xmm1
divsd  -0x30(%rbp),%xmm1
lea    0x9d4(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    -0x68(%rbp),%edi
call   1070 <close@plt>
mov    -0x64(%rbp),%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x100c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10098,%rsp
mov    %rsi,%r15
cmp    $0x3,%edi
jle    15fa <main+0x3fa>
mov    %edi,%ebx
mov    $0x5c0,%ebp
mov    $0x3b9aca00,%r13d
cmp    $0x4,%edi
je     125f <main+0x5f>
mov    0x20(%r15),%rdi
call   10e0 <atoi@plt>
cltq
imul   $0x51eb851f,%rax,%r13
mov    %r13,%rax
shr    $0x3f,%rax
sar    $0x28,%r13
add    %eax,%r13d
cmp    $0x6,%ebx
jb     125f <main+0x5f>
mov    0x28(%r15),%rdi
call   10e0 <atoi@plt>
mov    %eax,%ebp
mov    %r13d,%eax
cltd
idiv   %ebp
test   %edx,%edx
jle    1299 <main+0x99>
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
cvtsi2sd %ebp,%xmm1
cvtsi2sd %r13d,%xmm2
mulsd  %xmm0,%xmm1
divsd  %xmm2,%xmm1
mulsd  0xd77(%rip),%xmm1
cvttsd2si %xmm1,%ecx
mov    %ecx,0x10(%rsp)
imul   %ebp,%eax
mov    %eax,%r13d
jmp    12a1 <main+0xa1>
movl   $0x2710,0x10(%rsp)
mov    0x8(%r15),%rdi
call   10a0 <isNumber@plt>
mov    0x8(%r15),%rdi
test   %rax,%rax
mov    %ebp,0x38(%rsp)
je     12e4 <main+0xe4>
call   10e0 <atoi@plt>
mov    %eax,%ebx
mov    0x2d1b(%rip),%rax
mov    (%rax),%esi
lea    0xdac(%rip),%rdi
call   10c0 <open@plt>
cmp    $0xffffffff,%eax
je     1634 <main+0x434>
mov    %eax,0xc(%rsp)
mov    %ebx,%ebp
jmp    131f <main+0x11f>
mov    0x2cf5(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
cmp    $0xffffffff,%eax
je     1655 <main+0x455>
lea    0x20(%rsp),%rsi
mov    %eax,0xc(%rsp)
mov    %eax,%edi
call   1100 <fstat@plt>
mov    0x20(%rsp),%ebp
lea    0xdc2(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2cc2(%rip),%r14
mov    (%r14),%edi
mov    0x2ca0(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,%ebx
lea    0x28(%rsp),%rdi
mov    $0xc,%esi
call   10d0 <bzero@plt>
mov    (%r14),%eax
mov    %eax,0x30(%rsp)
mov    0x10(%r15),%rdi
call   1090 <inet_addr@plt>
mov    %eax,0x2c(%rsp)
mov    0x18(%r15),%rdi
call   10e0 <atoi@plt>
mov    %eax,%edi
call   1030 <htons@plt>
mov    %eax,0x28(%rsp)
lea    0x40(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
xor    %ecx,%ecx
test   %ebp,%ebp
jle    152e <main+0x32e>
movsd  0x40(%rsp),%xmm0
movsd  %xmm0,0x60(%rsp)
movsd  0x48(%rsp),%xmm0
movsd  %xmm0,0x58(%rsp)
movl   $0x1,0x14(%rsp)
lea    0x90(%rsp),%r12
lea    0x28(%rsp),%r14
lea    0xd5c(%rip),%r15
xor    %ecx,%ecx
mov    %ebp,0x34(%rsp)
jmp    13e8 <main+0x1e8>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebp
mov    %ebp,0x14(%rsp)
mov    0x34(%rsp),%ebp
mov    0x18(%rsp),%rcx
cmp    %ecx,%ebp
jle    152e <main+0x32e>
mov    %r13d,%eax
mov    %ebp,%r13d
sub    %ecx,%r13d
cmp    %eax,%r13d
cmovge %eax,%r13d
test   %r13d,%r13d
mov    %rcx,0x18(%rsp)
jle    14d0 <main+0x2d0>
xor    %eax,%eax
mov    $0x1,%ebp
mov    %r13,0x68(%rsp)
jmp    1440 <main+0x240>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x18(%rsp),%rax
add    %ebp,%eax
mov    %rax,0x18(%rsp)
mov    0x3c(%rsp),%eax
add    %ebp,%eax
mov    0x68(%rsp),%r13
cmp    %eax,%r13d
jle    14d0 <main+0x2d0>
mov    %eax,0x3c(%rsp)
sub    %eax,%r13d
mov    0x38(%rsp),%eax
cmp    %eax,%r13d
cmovge %eax,%r13d
test   %ebp,%ebp
jle    146f <main+0x26f>
cs nopw 0x0(%rax,%rax,1)
mov    0xc(%rsp),%edi
mov    %r12,%rsi
mov    %r13d,%edx
call   1080 <read@plt>
mov    %ebx,%edi
mov    %r12,%rsi
mov    %r13d,%edx
xor    %ecx,%ecx
mov    %r14,%r8
mov    $0xc,%r9d
call   1060 <sendto@plt>
mov    %eax,%ebp
test   %eax,%eax
jg     1420 <main+0x220>
mov    0x2b24(%rip),%rax
mov    (%rax),%ecx
mov    0x2b23(%rip),%rax
mov    (%rax),%edi
mov    0x2b32(%rip),%rax
cmp    (%rax),%ecx
je     15d2 <main+0x3d2>
mov    %r15,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x64,%edi
call   1110 <usleep@plt>
test   %ebp,%ebp
jg     1460 <main+0x260>
jmp    146f <main+0x26f>
nopw   0x0(%rax,%rax,1)
lea    0x70(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
movsd  0x70(%rsp),%xmm0
subsd  0x60(%rsp),%xmm0
movsd  0x78(%rsp),%xmm1
subsd  0x58(%rsp),%xmm1
mulsd  0xb0c(%rip),%xmm0
addsd  %xmm1,%xmm0
mov    0x14(%rsp),%ebp
mov    %ebp,%eax
imul   0x10(%rsp),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
ucomisd %xmm0,%xmm1
jbe    13d0 <main+0x1d0>
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1110 <usleep@plt>
jmp    13d0 <main+0x1d0>
mov    %rcx,%rbp
lea    0xc12(%rip),%rsi
lea    0x28(%rsp),%r8
mov    %ebx,%edi
mov    $0x4,%edx
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1060 <sendto@plt>
test   %eax,%eax
jle    1612 <main+0x412>
lea    0x80(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
movapd 0x80(%rsp),%xmm1
subpd  0x40(%rsp),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
divsd  0xa81(%rip),%xmm0
addsd  %xmm1,%xmm0
mov    %rbp,%rsi
lea    0x0(,%rbp,8),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
divsd  %xmm0,%xmm1
lea    0xbd2(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    %ebx,%edi
call   1070 <close@plt>
mov    0xc(%rsp),%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x10098,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb0e(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    %ebx,%edi
call   1070 <close@plt>
mov    0xc(%rsp),%edi
call   1070 <close@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    (%r15),%rsi
lea    0xa0c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
mov    0x29a7(%rip),%rax
mov    (%rax),%edi
mov    0x2996(%rip),%rax
mov    (%rax),%edx
lea    0xb24(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
jmp    15e0 <main+0x3e0>
mov    0x2985(%rip),%rax
mov    (%rax),%edi
lea    0xa4e(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x2964(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r15),%rdx
lea    0xa54(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { double, double }
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.stat = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [106 x i8] c"Usage: %s <bytes2send/file2send> <ip> <port> <[optional] bandwidth (bps)> <[optional] sendsize (bytes)>\0A\00"
@.str.1 = [24 x i8] c"/data/local/tmp/bigfile\00"
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.2 = [43 x i8] c"! Unable to open /data/local/tmp/bigfile.\0A\00"
@.str.3 = [27 x i8] c"! Unable to open file %s.\0A\00"
@.str.4 = [15 x i8] c"bytes2send:%d\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@errno = global i32 0
@ECONNREFUSED = global i32 0
@.str.5 = [49 x i8] c"! Connection refused; cannot connect to server.\0A\00"
@.str.6 = [50 x i8] c"! Fail to send: ret:%d, err:%d; wait for 100us..\0A\00"
@.str.7 = [5 x i8] c"=?!\0A\00"
@.str.8 = [42 x i8] c"! Unable to end data transfer. errno:%d.\0A\00"
@.str.9 = [52 x i8] c"sent(bytes):%d\0Aduration(s):%lf\0Athroughput(bps):%lf\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 i32
%11 = alloca double
%12 = alloca %struct.timeval
%13 = alloca %struct.timeval
%14 = alloca %struct.timeval
%15 = alloca i32
%16 = alloca i32
%17 = alloca [65536 x i8]
%18 = alloca %struct.sockaddr_in
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 10000, i32* %6
store i32 1000000000, i32* %7
store i32 0, i32* %8
store i32 1, i32* %9
store i32 0, i32* %10
store i32 1472, i32* %20
store i32 0, i32* %21
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 4
br i1 %24, label %25, label %31
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([106 x i8], [106 x i8]* @.str, i64 0, i64 0), i8* %28)
%30 = call i32 @exit(i32 0)
unreachable
31: ; preds = %2
%32 = load i32, i32* %4
%33 = icmp sgt i32 %32, 4
br i1 %33, label %34, label %43
34: ; preds = %31
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 4
%37 = load i8*, i8** %36
%38 = call i32 @atoi(i8* %37)
%39 = sdiv i32 %38, 8
%40 = load i32, i32* %6
%41 = sdiv i32 1000000, %40
%42 = sdiv i32 %39, %41
store i32 %42, i32* %7
br label %43
43: ; preds = %34, %31
%44 = load i32, i32* %4
%45 = icmp sgt i32 %44, 5
br i1 %45, label %46, label %51
46: ; preds = %43
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 5
%49 = load i8*, i8** %48
%50 = call i32 @atoi(i8* %49)
store i32 %50, i32* %20
br label %51
51: ; preds = %46, %43
%52 = load i32, i32* %7
%53 = load i32, i32* %20
%54 = srem i32 %52, %53
%55 = icmp sgt i32 %54, 0
br i1 %55, label %56, label %78
56: ; preds = %51
%57 = load i32, i32* %7
%58 = load i32, i32* %20
%59 = sdiv i32 %57, %58
%60 = add nsw i32 %59, 1
%61 = sitofp i32 %60 to double
%62 = load i32, i32* %20
%63 = sitofp i32 %62 to double
%64 = fmul double %61, %63
%65 = load i32, i32* %7
%66 = sitofp i32 %65 to double
%67 = fdiv double %64, %66
%68 = load i32, i32* %6
%69 = sitofp i32 %68 to double
%70 = fmul double %67, %69
%71 = fptosi double %70 to i32
store i32 %71, i32* %6
%72 = load i32, i32* %7
%73 = load i32, i32* %20
%74 = sdiv i32 %72, %73
%75 = add nsw i32 %74, 1
%76 = load i32, i32* %20
%77 = mul nsw i32 %75, %76
store i32 %77, i32* %7
br label %78
78: ; preds = %56, %51
%79 = load i8**, i8*** %5
%80 = getelementptr inbounds i8*, i8** %79, i64 1
%81 = load i8*, i8** %80
%82 = call i64 @isNumber(i8* %81)
%83 = icmp ne i64 %82, 0
br i1 %83, label %84, label %98
84: ; preds = %78
%85 = load i8**, i8*** %5
%86 = getelementptr inbounds i8*, i8** %85, i64 1
%87 = load i8*, i8** %86
%88 = call i32 @atoi(i8* %87)
store i32 %88, i32* %21
%89 = load i32, i32* @O_RDONLY
%90 = call i32 @open(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %89)
store i32 %90, i32* %15
%91 = load i32, i32* %15
%92 = icmp eq i32 %91, -1
br i1 %92, label %93, label %97
93: ; preds = %84
%94 = load i32, i32* @stderr
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %94, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%96 = call i32 @exit(i32 1)
unreachable
97: ; preds = %84
br label %120
98: ; preds = %78
%99 = load i8**, i8*** %5
%100 = getelementptr inbounds i8*, i8** %99, i64 1
%101 = load i8*, i8** %100
%102 = load i32, i32* @O_RDONLY
%103 = call i32 @open(i8* %101, i32 %102)
store i32 %103, i32* %15
%104 = load i32, i32* %15
%105 = icmp eq i32 %104, -1
br i1 %105, label %106, label %113
106: ; preds = %98
%107 = load i32, i32* @stderr
%108 = load i8**, i8*** %5
%109 = getelementptr inbounds i8*, i8** %108, i64 1
%110 = load i8*, i8** %109
%111 = call i32 (i32, i8*, ...) @fprintf(i32 %107, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %110)
%112 = call i32 @exit(i32 1)
unreachable
113: ; preds = %98
%114 = load i32, i32* %15
%115 = call i32 @fstat(i32 %114, %struct.stat* %22)
%116 = getelementptr inbounds %struct.stat, %struct.stat* %22, i32 0, i32 0
%117 = load i32, i32* %116
store i32 %117, i32* %21
%118 = load i32, i32* %21
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %118)
br label %120
120: ; preds = %113, %97
%121 = load i32, i32* @AF_INET
%122 = load i32, i32* @SOCK_DGRAM
%123 = call i32 @socket(i32 %121, i32 %122, i32 0)
store i32 %123, i32* %16
%124 = call i32 @bzero(%struct.sockaddr_in* %18, i32 12)
%125 = load i32, i32* @AF_INET
%126 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %18, i32 0, i32 2
store i32 %125, i32* %126
%127 = load i8**, i8*** %5
%128 = getelementptr inbounds i8*, i8** %127, i64 2
%129 = load i8*, i8** %128
%130 = call i32 @inet_addr(i8* %129)
%131 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %18, i32 0, i32 1
%132 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %131, i32 0, i32 0
store i32 %130, i32* %132
%133 = load i8**, i8*** %5
%134 = getelementptr inbounds i8*, i8** %133, i64 3
%135 = load i8*, i8** %134
%136 = call i32 @atoi(i8* %135)
%137 = call i32 @htons(i32 %136)
%138 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %18, i32 0, i32 0
store i32 %137, i32* %138
%139 = call i32 @gettimeofday(%struct.timeval* %12, i32* null)
br label %140
140: ; preds = %252, %120
%141 = load i32, i32* %10
%142 = load i32, i32* %21
%143 = icmp slt i32 %141, %142
br i1 %143, label %144, label %255
144: ; preds = %140
%145 = load i32, i32* %21
%146 = load i32, i32* %10
%147 = sub nsw i32 %145, %146
%148 = load i32, i32* %7
%149 = icmp slt i32 %147, %148
br i1 %149, label %150, label %154
150: ; preds = %144
%151 = load i32, i32* %21
%152 = load i32, i32* %10
%153 = sub nsw i32 %151, %152
store i32 %153, i32* %7
br label %154
154: ; preds = %150, %144
store i32 1, i32* %19
br label %155
155: ; preds = %217, %211, %154
%156 = load i32, i32* %8
%157 = load i32, i32* %7
%158 = icmp slt i32 %156, %157
br i1 %158, label %159, label %224
159: ; preds = %155
%160 = load i32, i32* %19
%161 = icmp sgt i32 %160, 0
br i1 %161, label %162, label %179
162: ; preds = %159
%163 = load i32, i32* %15
%164 = getelementptr inbounds [65536 x i8], [65536 x i8]* %17, i64 0, i64 0
%165 = load i32, i32* %7
%166 = load i32, i32* %8
%167 = sub nsw i32 %165, %166
%168 = load i32, i32* %20
%169 = icmp slt i32 %167, %168
br i1 %169, label %170, label %174
170: ; preds = %162
%171 = load i32, i32* %7
%172 = load i32, i32* %8
%173 = sub nsw i32 %171, %172
br label %176
174: ; preds = %162
%175 = load i32, i32* %20
br label %176
176: ; preds = %174, %170
%177 = phi i32 [ %173, %170 ], [ %175, %174 ]
%178 = call i32 @read(i32 %163, i8* %164, i32 %177)
br label %179
179: ; preds = %176, %159
%180 = load i32, i32* %16
%181 = getelementptr inbounds [65536 x i8], [65536 x i8]* %17, i64 0, i64 0
%182 = load i32, i32* %7
%183 = load i32, i32* %8
%184 = sub nsw i32 %182, %183
%185 = load i32, i32* %20
%186 = icmp slt i32 %184, %185
br i1 %186, label %187, label %191
187: ; preds = %179
%188 = load i32, i32* %7
%189 = load i32, i32* %8
%190 = sub nsw i32 %188, %189
br label %193
191: ; preds = %179
%192 = load i32, i32* %20
br label %193
193: ; preds = %191, %187
%194 = phi i32 [ %190, %187 ], [ %192, %191 ]
%195 = bitcast %struct.sockaddr_in* %18 to %struct.sockaddr*
%196 = call i32 @sendto(i32 %180, i8* %181, i32 %194, i32 0, %struct.sockaddr* %195, i32 12)
store i32 %196, i32* %19
%197 = load i32, i32* %19
%198 = icmp sle i32 %197, 0
br i1 %198, label %199, label %217
199: ; preds = %193
%200 = load i32, i32* @errno
%201 = load i32, i32* @ECONNREFUSED
%202 = icmp eq i32 %200, %201
br i1 %202, label %203, label %211
203: ; preds = %199
%204 = load i32, i32* @stderr
%205 = call i32 (i32, i8*, ...) @fprintf(i32 %204, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
%206 = load i32, i32* %16
%207 = call i32 @close(i32 %206)
%208 = load i32, i32* %15
%209 = call i32 @close(i32 %208)
%210 = call i32 @exit(i32 1)
unreachable
211: ; preds = %199
%212 = load i32, i32* @stderr
%213 = load i32, i32* %19
%214 = load i32, i32* @errno
%215 = call i32 (i32, i8*, ...) @fprintf(i32 %212, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i32 %213, i32 %214)
%216 = call i32 @usleep(i32 100)
br label %155
217: ; preds = %193
%218 = load i32, i32* %19
%219 = load i32, i32* %10
%220 = add nsw i32 %219, %218
store i32 %220, i32* %10
%221 = load i32, i32* %19
%222 = load i32, i32* %8
%223 = add nsw i32 %222, %221
store i32 %223, i32* %8
br label %155
224: ; preds = %155
%225 = call i32 @gettimeofday(%struct.timeval* %14, i32* null)
%226 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
%227 = load double, double* %226
%228 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
%229 = load double, double* %228
%230 = fsub double %227, %229
%231 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
%232 = load double, double* %231
%233 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 1
%234 = load double, double* %233
%235 = fsub double %232, %234
%236 = call double @llvm.fmuladd.f64(double %230, double 1.000000e+06, double %235)
store double %236, double* %11
%237 = load double, double* %11
%238 = load i32, i32* %6
%239 = load i32, i32* %9
%240 = mul nsw i32 %238, %239
%241 = sitofp i32 %240 to double
%242 = fcmp olt double %237, %241
br i1 %242, label %243, label %252
243: ; preds = %224
%244 = load i32, i32* %6
%245 = load i32, i32* %9
%246 = mul nsw i32 %244, %245
%247 = sitofp i32 %246 to double
%248 = load double, double* %11
%249 = fsub double %247, %248
%250 = fptosi double %249 to i32
%251 = call i32 @usleep(i32 %250)
br label %252
252: ; preds = %243, %224
store i32 0, i32* %8
%253 = load i32, i32* %9
%254 = add nsw i32 %253, 1
store i32 %254, i32* %9
br label %140
255: ; preds = %140
%256 = load i32, i32* %16
%257 = bitcast %struct.sockaddr_in* %18 to %struct.sockaddr*
%258 = call i32 @sendto(i32 %256, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 4, i32 0, %struct.sockaddr* %257, i32 12)
store i32 %258, i32* %19
%259 = load i32, i32* %19
%260 = icmp sle i32 %259, 0
br i1 %260, label %261, label %270
261: ; preds = %255
%262 = load i32, i32* @stderr
%263 = load i32, i32* @errno
%264 = call i32 (i32, i8*, ...) @fprintf(i32 %262, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i32 %263)
%265 = load i32, i32* %16
%266 = call i32 @close(i32 %265)
%267 = load i32, i32* %15
%268 = call i32 @close(i32 %267)
%269 = call i32 @exit(i32 1)
unreachable
270: ; preds = %255
%271 = call i32 @gettimeofday(%struct.timeval* %13, i32* null)
%272 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
%273 = load double, double* %272
%274 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
%275 = load double, double* %274
%276 = fsub double %273, %275
%277 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
%278 = load double, double* %277
%279 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 1
%280 = load double, double* %279
%281 = fsub double %278, %280
%282 = fdiv double %281, 1.000000e+06
%283 = fadd double %276, %282
store double %283, double* %11
%284 = load i32, i32* %10
%285 = load double, double* %11
%286 = load i32, i32* %10
%287 = mul nsw i32 %286, 8
%288 = sitofp i32 %287 to double
%289 = load double, double* %11
%290 = fdiv double %288, %289
%291 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.9, i64 0, i64 0), i32 %284, double %285, double %290)
%292 = load i32, i32* %16
%293 = call i32 @close(i32 %292)
%294 = load i32, i32* %15
%295 = call i32 @close(i32 %294)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { double, double }
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.stat = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [106 x i8] c"Usage: %s <bytes2send/file2send> <ip> <port> <[optional] bandwidth (bps)> <[optional] sendsize (bytes)>\0A\00"
@.str.1 = [24 x i8] c"/data/local/tmp/bigfile\00"
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.2 = [43 x i8] c"! Unable to open /data/local/tmp/bigfile.\0A\00"
@.str.3 = [27 x i8] c"! Unable to open file %s.\0A\00"
@.str.4 = [15 x i8] c"bytes2send:%d\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@errno = global i32 0
@ECONNREFUSED = global i32 0
@.str.5 = [49 x i8] c"! Connection refused; cannot connect to server.\0A\00"
@.str.6 = [50 x i8] c"! Fail to send: ret:%d, err:%d; wait for 100us..\0A\00"
@.str.7 = [5 x i8] c"=?!\0A\00"
@.str.8 = [42 x i8] c"! Unable to end data transfer. errno:%d.\0A\00"
@.str.9 = [52 x i8] c"sent(bytes):%d\0Aduration(s):%lf\0Athroughput(bps):%lf\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca <2 x double>
%4 = bitcast <2 x double>* %3 to %struct.timeval*
%5 = alloca <2 x double>
%6 = alloca %struct.timeval
%7 = alloca [65536 x i8]
%8 = alloca %struct.sockaddr_in
%9 = alloca %struct.stat
%10 = bitcast <2 x double>* %3 to i8*
%11 = bitcast <2 x double>* %5 to i8*
%12 = bitcast %struct.timeval* %6 to i8*
%13 = getelementptr inbounds [65536 x i8], [65536 x i8]* %7, i64 0, i64 0
%14 = bitcast %struct.sockaddr_in* %8 to i8*
%15 = bitcast %struct.stat* %9 to i8*
%16 = icmp slt i32 %0, 4
br i1 %16, label %17, label %21
17: ; preds = %2
%18 = load i8*, i8** %1
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([106 x i8], [106 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = tail call i32 @exit(i32 0)
unreachable
21: ; preds = %2
%22 = icmp eq i32 %0, 4
br i1 %22, label %33, label %23
23: ; preds = %21
%24 = getelementptr inbounds i8*, i8** %1, i64 4
%25 = load i8*, i8** %24
%26 = tail call i32 @atoi(i8* %25)
%27 = sdiv i32 %26, 800
%28 = icmp ugt i32 %0, 5
br i1 %28, label %29, label %33
29: ; preds = %23
%30 = getelementptr inbounds i8*, i8** %1, i64 5
%31 = load i8*, i8** %30
%32 = tail call i32 @atoi(i8* %31)
br label %33
33: ; preds = %21, %29, %23
%34 = phi i32 [ %27, %29 ], [ %27, %23 ], [ 1000000000, %21 ]
%35 = phi i32 [ %32, %29 ], [ 1472, %23 ], [ 1472, %21 ]
%36 = srem i32 %34, %35
%37 = sdiv i32 %34, %35
%38 = icmp sgt i32 %36, 0
br i1 %38, label %39, label %49
39: ; preds = %33
%40 = add nsw i32 %37, 1
%41 = sitofp i32 %40 to double
%42 = sitofp i32 %35 to double
%43 = fmul double %42, %41
%44 = sitofp i32 %34 to double
%45 = fdiv double %43, %44
%46 = fmul double %45, 1.000000e+04
%47 = fptosi double %46 to i32
%48 = mul nsw i32 %40, %35
br label %49
49: ; preds = %39, %33
%50 = phi i32 [ %48, %39 ], [ %34, %33 ]
%51 = phi i32 [ %47, %39 ], [ 10000, %33 ]
%52 = getelementptr inbounds i8*, i8** %1, i64 1
%53 = load i8*, i8** %52
%54 = tail call i64 @isNumber(i8* %53)
%55 = icmp eq i64 %54, 0
%56 = load i8*, i8** %52
br i1 %55, label %66, label %57
57: ; preds = %49
%58 = tail call i32 @atoi(i8* %56)
%59 = load i32, i32* @O_RDONLY
%60 = tail call i32 @open(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %59)
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %80
62: ; preds = %57
%63 = load i32, i32* @stderr
%64 = tail call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%65 = tail call i32 @exit(i32 1)
unreachable
66: ; preds = %49
%67 = load i32, i32* @O_RDONLY
%68 = tail call i32 @open(i8* %56, i32 %67)
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %75
70: ; preds = %66
%71 = load i32, i32* @stderr
%72 = load i8*, i8** %52
%73 = tail call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %72)
%74 = tail call i32 @exit(i32 1)
unreachable
75: ; preds = %66
%76 = call i32 @fstat(i32 %68, %struct.stat* %9)
%77 = getelementptr inbounds %struct.stat, %struct.stat* %9, i64 0, i32 0
%78 = load i32, i32* %77
%79 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %78)
br label %80
80: ; preds = %57, %75
%81 = phi i32 [ %60, %57 ], [ %68, %75 ]
%82 = phi i32 [ %58, %57 ], [ %78, %75 ]
%83 = load i32, i32* @AF_INET
%84 = load i32, i32* @SOCK_DGRAM
%85 = tail call i32 @socket(i32 %83, i32 %84, i32 0)
%86 = call i32 @bzero(%struct.sockaddr_in* %8, i32 12)
%87 = load i32, i32* @AF_INET
%88 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i64 0, i32 2
store i32 %87, i32* %88
%89 = getelementptr inbounds i8*, i8** %1, i64 2
%90 = load i8*, i8** %89
%91 = tail call i32 @inet_addr(i8* %90)
%92 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i64 0, i32 1, i32 0
store i32 %91, i32* %92
%93 = getelementptr inbounds i8*, i8** %1, i64 3
%94 = load i8*, i8** %93
%95 = tail call i32 @atoi(i8* %94)
%96 = tail call i32 @htons(i32 %95)
%97 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i64 0, i32 0
store i32 %96, i32* %97
%98 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%99 = icmp sgt i32 %82, 0
br i1 %99, label %100, label %166
100: ; preds = %80
%101 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%102 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
%103 = getelementptr inbounds <2 x double>, <2 x double>* %3, i64 0, i64 0
%104 = load double, double* %103
%105 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
%106 = getelementptr inbounds <2 x double>, <2 x double>* %3, i64 0, i64 1
%107 = load double, double* %106
br label %108
108: ; preds = %100, %163
%109 = phi i32 [ 0, %100 ], [ %149, %163 ]
%110 = phi i32 [ 1, %100 ], [ %164, %163 ]
%111 = phi i32 [ %50, %100 ], [ %114, %163 ]
%112 = sub nsw i32 %82, %109
%113 = icmp slt i32 %112, %111
%114 = select i1 %113, i32 %112, i32 %111
%115 = icmp sgt i32 %114, 0
br i1 %115, label %116, label %148
116: ; preds = %108, %144
%117 = phi i32 [ %129, %144 ], [ 1, %108 ]
%118 = phi i32 [ %145, %144 ], [ %109, %108 ]
%119 = phi i32 [ %146, %144 ], [ 0, %108 ]
%120 = sub nsw i32 %114, %119
%121 = icmp slt i32 %120, %35
%122 = select i1 %121, i32 %120, i32 %35
br label %123
123: ; preds = %141, %116
%124 = phi i32 [ %117, %116 ], [ %129, %141 ]
%125 = icmp sgt i32 %124, 0
br i1 %125, label %126, label %128
126: ; preds = %123
%127 = call i32 @read(i32 %81, i8* %13, i32 %122)
br label %128
128: ; preds = %126, %123
%129 = call i32 @sendto(i32 %85, i8* %13, i32 %122, i32 0, %struct.sockaddr* %101, i32 12)
%130 = icmp slt i32 %129, 1
br i1 %130, label %131, label %144
131: ; preds = %128
%132 = load i32, i32* @errno
%133 = load i32, i32* @ECONNREFUSED
%134 = icmp eq i32 %132, %133
%135 = load i32, i32* @stderr
br i1 %134, label %136, label %141
136: ; preds = %131
%137 = call i32 (i32, i8*, ...) @fprintf(i32 %135, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
%138 = call i32 @close(i32 %85)
%139 = call i32 @close(i32 %81)
%140 = call i32 @exit(i32 1)
unreachable
141: ; preds = %131
%142 = call i32 (i32, i8*, ...) @fprintf(i32 %135, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i32 %129, i32 %132)
%143 = call i32 @usleep(i32 100)
br label %123
144: ; preds = %128
%145 = add nsw i32 %129, %118
%146 = add nsw i32 %129, %119
%147 = icmp sgt i32 %114, %146
br i1 %147, label %116, label %148
148: ; preds = %144, %108
%149 = phi i32 [ %109, %108 ], [ %145, %144 ]
%150 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%151 = load double, double* %102
%152 = fsub double %151, %104
%153 = load double, double* %105
%154 = fsub double %153, %107
%155 = call double @llvm.fmuladd.f64(double %152, double 1.000000e+06, double %154)
%156 = mul nsw i32 %110, %51
%157 = sitofp i32 %156 to double
%158 = fcmp olt double %155, %157
br i1 %158, label %159, label %163
159: ; preds = %148
%160 = fsub double %157, %155
%161 = fptosi double %160 to i32
%162 = call i32 @usleep(i32 %161)
br label %163
163: ; preds = %159, %148
%164 = add nuw nsw i32 %110, 1
%165 = icmp sgt i32 %82, %149
br i1 %165, label %108, label %166
166: ; preds = %163, %80
%167 = phi i32 [ 0, %80 ], [ %149, %163 ]
%168 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%169 = call i32 @sendto(i32 %85, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 4, i32 0, %struct.sockaddr* %168, i32 12)
%170 = icmp slt i32 %169, 1
br i1 %170, label %171, label %178
171: ; preds = %166
%172 = load i32, i32* @stderr
%173 = load i32, i32* @errno
%174 = call i32 (i32, i8*, ...) @fprintf(i32 %172, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i32 %173)
%175 = call i32 @close(i32 %85)
%176 = call i32 @close(i32 %81)
%177 = call i32 @exit(i32 1)
unreachable
178: ; preds = %166
%179 = bitcast <2 x double>* %5 to %struct.timeval*
%180 = call i32 @gettimeofday(%struct.timeval* %179, i32* null)
%181 = load <2 x double>, <2 x double>* %5
%182 = load <2 x double>, <2 x double>* %3
%183 = fsub <2 x double> %181, %182
%184 = extractelement <2 x double> %183, i64 1
%185 = fdiv double %184, 1.000000e+06
%186 = extractelement <2 x double> %183, i64 0
%187 = fadd double %186, %185
%188 = shl nsw i32 %167, 3
%189 = sitofp i32 %188 to double
%190 = fdiv double %189, %187
%191 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.9, i64 0, i64 0), i32 %167, double %187, double %190)
%192 = call i32 @close(i32 %85)
%193 = call i32 @close(i32 %81)
ret i32 0
}