#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 /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ SOCK_STREAM;
int atoi(char *);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, 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 send(int, char *, int, int /*<<< orphan*/);
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 = 1460;
  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_STREAM, 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]));
  if (connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0) {
    fprintf(stderr, "! Unable to connect the server.\n");
    exit(1);
  }
  gettimeofday(&t_start, NULL);
  while (total_bytes_sent < bytes2send) {
    if ((bytes2send - total_bytes_sent) < quota) {
      quota = bytes2send - total_bytes_sent;
    }
    while (sentInSlot < quota) {
      read(fd, sendbuf,
           (quota - sentInSlot < sendsize) ? (quota - sentInSlot) : sendsize);
      ret = send(
          sockfd, sendbuf,
          (quota - sentInSlot < sendsize) ? (quota - sentInSlot) : sendsize, 0);
      if (ret <= 0) {
        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;
  }
  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   $0x5b4,-0x10088(%rbp)
movl   $0x0,-0x1008c(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    1286 <main+0x76>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd90(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
cmpl   $0x4,-0x8(%rbp)
jle    12c2 <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    12df <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    133f <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     13b1 <main+0x1a1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x1008c(%rbp)
mov    0x2c70(%rip),%rax
mov    (%rax),%esi
lea    0xcf8(%rip),%rdi
call   10c0 <open@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0xffffffff,-0x64(%rbp)
jne    13ac <main+0x19c>
mov    0x2c3e(%rip),%rax
mov    (%rax),%edi
lea    0xcee(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    142c <main+0x21c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2c20(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0xffffffff,-0x64(%rbp)
jne    13fd <main+0x1ed>
mov    0x2bf5(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xcc8(%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   1110 <fstat@plt>
mov    -0x10090(%rbp),%eax
mov    %eax,-0x1008c(%rbp)
mov    -0x1008c(%rbp),%esi
lea    0xcaa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2bb5(%rip),%rax
mov    (%rax),%edi
mov    0x2b8c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,-0x68(%rbp)
lea    -0x10080(%rbp),%rdi
mov    $0xc,%esi
call   10d0 <bzero@plt>
mov    0x2b88(%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)
mov    -0x68(%rbp),%edi
lea    -0x10080(%rbp),%rsi
mov    $0xc,%edx
call   1100 <connect@plt>
cmp    $0x0,%rax
jge    14d4 <main+0x2c4>
mov    0x2b16(%rip),%rax
mov    (%rax),%edi
lea    0xc1b(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
mov    -0x24(%rbp),%eax
cmp    -0x1008c(%rbp),%eax
jge    16c0 <main+0x4b0>
mov    -0x1008c(%rbp),%eax
sub    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    150e <main+0x2fe>
mov    -0x1008c(%rbp),%eax
sub    -0x24(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1513 <main+0x303>
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1642 <main+0x432>
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    1559 <main+0x349>
mov    -0x18(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x100a8(%rbp)
jmp    1565 <main+0x355>
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    15b7 <main+0x3a7>
mov    -0x18(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x100b8(%rbp)
jmp    15c3 <main+0x3b3>
mov    -0x10088(%rbp),%eax
mov    %eax,-0x100b8(%rbp)
mov    -0x100b0(%rbp),%rsi
mov    -0x100b4(%rbp),%edi
mov    -0x100b8(%rbp),%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    %eax,-0x10084(%rbp)
cmpl   $0x0,-0x10084(%rbp)
jg     1625 <main+0x415>
mov    0x29d9(%rip),%rax
mov    (%rax),%edi
mov    -0x10084(%rbp),%edx
mov    0x29ba(%rip),%rax
mov    (%rax),%ecx
lea    0xaf0(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x64,%edi
call   1120 <usleep@plt>
jmp    1513 <main+0x303>
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    1513 <main+0x303>
lea    -0x60(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
movsd  -0x60(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
subsd  -0x38(%rbp),%xmm1
movsd  0x995(%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    16ab <main+0x49b>
mov    -0x14(%rbp),%eax
imul   -0x20(%rbp),%eax
cvtsi2sd %eax,%xmm0
subsd  -0x30(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1120 <usleep@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    14e1 <main+0x2d1>
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
movsd  -0x50(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
subsd  -0x38(%rbp),%xmm1
movsd  0x917(%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    0xa1d(%rip),%rdi
mov    $0x2,%al
call   1050 <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    $0x100a8,%rsp
mov    %rsi,%r13
cmp    $0x3,%edi
jle    160c <main+0x3fc>
mov    %edi,%ebx
mov    $0x5b4,%r12d
mov    $0x3b9aca00,%ebp
cmp    $0x4,%edi
je     126f <main+0x5f>
mov    0x20(%r13),%rdi
call   10e0 <atoi@plt>
cltq
imul   $0x51eb851f,%rax,%rbp
mov    %rbp,%rax
shr    $0x3f,%rax
sar    $0x28,%rbp
add    %eax,%ebp
cmp    $0x6,%ebx
jb     126f <main+0x5f>
mov    0x28(%r13),%rdi
call   10e0 <atoi@plt>
mov    %eax,%r12d
mov    %ebp,%eax
cltd
idiv   %r12d
test   %edx,%edx
jle    12a9 <main+0x99>
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
cvtsi2sd %r12d,%xmm1
cvtsi2sd %ebp,%xmm2
mulsd  %xmm0,%xmm1
divsd  %xmm2,%xmm1
mulsd  0xd67(%rip),%xmm1
cvttsd2si %xmm1,%ecx
mov    %ecx,0x10(%rsp)
imul   %r12d,%eax
mov    %eax,%ebp
jmp    12b1 <main+0xa1>
movl   $0x2710,0x10(%rsp)
mov    0x8(%r13),%rdi
call   10a0 <isNumber@plt>
mov    0x8(%r13),%rdi
test   %rax,%rax
mov    %rbp,0x18(%rsp)
je     12f7 <main+0xe7>
call   10e0 <atoi@plt>
mov    %eax,%ebx
mov    0x2d0a(%rip),%rax
mov    (%rax),%esi
lea    0xd9a(%rip),%rdi
call   10c0 <open@plt>
mov    %eax,0xc(%rsp)
cmp    $0xffffffff,%eax
je     1637 <main+0x427>
mov    %ebx,0x8(%rsp)
jmp    1334 <main+0x124>
mov    0x2ce2(%rip),%rax
mov    (%rax),%esi
call   10c0 <open@plt>
cmp    $0xffffffff,%eax
je     1658 <main+0x448>
lea    0x20(%rsp),%rsi
mov    %eax,0xc(%rsp)
mov    %eax,%edi
call   1110 <fstat@plt>
mov    0x20(%rsp),%esi
lea    0xdae(%rip),%rdi
mov    %esi,0x8(%rsp)
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2cad(%rip),%r15
mov    (%r15),%edi
mov    0x2c83(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,%r14d
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
mov    $0xc,%esi
call   10d0 <bzero@plt>
mov    (%r15),%eax
mov    %eax,0x38(%rsp)
mov    0x10(%r13),%rdi
call   1090 <inet_addr@plt>
mov    %eax,0x34(%rsp)
mov    0x18(%r13),%rdi
call   10e0 <atoi@plt>
mov    %eax,%edi
call   1030 <htons@plt>
mov    %eax,0x30(%rsp)
mov    %r14d,%edi
mov    %rbp,%rsi
mov    $0xc,%edx
call   1100 <connect@plt>
test   %rax,%rax
js     1625 <main+0x415>
xor    %ebp,%ebp
lea    0x60(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    0x8(%rsp),%ecx
test   %ecx,%ecx
mov    0x18(%rsp),%r13
jle    1587 <main+0x377>
mov    %r12d,0x28(%rsp)
movapd 0x60(%rsp),%xmm0
movapd %xmm0,0x40(%rsp)
unpckhpd %xmm0,%xmm0
movapd %xmm0,0x80(%rsp)
mov    $0x1,%r15d
lea    0xa0(%rsp),%rbx
xor    %ebp,%ebp
mov    %r14d,0x14(%rsp)
jmp    1410 <main+0x200>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15d
mov    0x8(%rsp),%ecx
cmp    %ebp,%ecx
jle    1593 <main+0x383>
mov    %r15d,0x24(%rsp)
mov    %r13d,%eax
mov    %ecx,%r13d
sub    %ebp,%r13d
cmp    %eax,%r13d
cmovge %eax,%r13d
test   %r13d,%r13d
jle    1520 <main+0x310>
xor    %eax,%eax
mov    %r13,0x18(%rsp)
jmp    146a <main+0x25a>
nopw   0x0(%rax,%rax,1)
mov    0x14(%rsp),%r14d
lea    0xa0(%rsp),%rbx
mov    0x58(%rsp),%rbp
add    %eax,%ebp
mov    0x2c(%rsp),%ecx
add    %eax,%ecx
mov    %ecx,%eax
mov    0x18(%rsp),%r13
cmp    %ecx,%r13d
jle    1520 <main+0x310>
mov    %rbp,0x58(%rsp)
mov    %r13,%rbp
mov    %ebp,%r15d
mov    %eax,0x2c(%rsp)
sub    %eax,%r15d
mov    0x28(%rsp),%eax
cmp    %eax,%r15d
cmovge %eax,%r15d
mov    0xc(%rsp),%ebp
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1080 <read@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
test   %eax,%eax
jg     1440 <main+0x230>
mov    0x14(%rsp),%r14d
mov    0x2b08(%rip),%r13
lea    0xc48(%rip),%r12
lea    0xa0(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    0x2af9(%rip),%rcx
mov    (%rcx),%edi
mov    0x0(%r13),%ecx
mov    %r12,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x64,%edi
call   1120 <usleep@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1080 <read@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
test   %eax,%eax
jle    14d0 <main+0x2c0>
jmp    144d <main+0x23d>
nopl   0x0(%rax)
lea    0x70(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
movsd  0x70(%rsp),%xmm0
movsd  0x78(%rsp),%xmm1
movapd 0x40(%rsp),%xmm2
subsd  %xmm2,%xmm0
subsd  0x80(%rsp),%xmm1
mulsd  0xab5(%rip),%xmm0
addsd  %xmm1,%xmm0
mov    0x24(%rsp),%r15d
mov    %r15d,%eax
imul   0x10(%rsp),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
ucomisd %xmm0,%xmm1
jbe    1400 <main+0x1f0>
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1120 <usleep@plt>
jmp    1400 <main+0x1f0>
movapd 0x60(%rsp),%xmm0
movapd %xmm0,0x40(%rsp)
lea    0x90(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
movapd 0x90(%rsp),%xmm1
subpd  0x40(%rsp),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
divsd  0xa47(%rip),%xmm0
addsd  %xmm1,%xmm0
lea    0x0(,%rbp,8),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
divsd  %xmm0,%xmm1
lea    0xb5b(%rip),%rdi
mov    %ebp,%esi
mov    $0x2,%al
call   1050 <printf@plt>
mov    %r14d,%edi
call   1070 <close@plt>
mov    0xc(%rsp),%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x100a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x0(%r13),%rsi
lea    0x9f9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
mov    0x29a4(%rip),%rax
mov    (%rax),%edi
lea    0xab1(%rip),%rsi
jmp    1647 <main+0x437>
mov    0x2992(%rip),%rax
mov    (%rax),%edi
lea    0xa4a(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x2971(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r13),%rdx
lea    0xa50(%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 = [105 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_STREAM = global i32 0
@.str.5 = [33 x i8] c"! Unable to connect the server.\0A\00"
@.str.6 = [50 x i8] c"! Fail to send: ret:%d, err:%d; wait for 100us..\0A\00"
@errno = global i32 0
@.str.7 = [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 1460, 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 ([105 x i8], [105 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_STREAM
%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 = load i32, i32* %16
%140 = bitcast %struct.sockaddr_in* %18 to %struct.sockaddr*
%141 = call i64 @connect(i32 %139, %struct.sockaddr* %140, i32 12)
%142 = icmp slt i64 %141, 0
br i1 %142, label %143, label %147
143: ; preds = %120
%144 = load i32, i32* @stderr
%145 = call i32 (i32, i8*, ...) @fprintf(i32 %144, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%146 = call i32 @exit(i32 1)
unreachable
147: ; preds = %120
%148 = call i32 @gettimeofday(%struct.timeval* %12, i32* null)
br label %149
149: ; preds = %244, %147
%150 = load i32, i32* %10
%151 = load i32, i32* %21
%152 = icmp slt i32 %150, %151
br i1 %152, label %153, label %247
153: ; preds = %149
%154 = load i32, i32* %21
%155 = load i32, i32* %10
%156 = sub nsw i32 %154, %155
%157 = load i32, i32* %7
%158 = icmp slt i32 %156, %157
br i1 %158, label %159, label %163
159: ; preds = %153
%160 = load i32, i32* %21
%161 = load i32, i32* %10
%162 = sub nsw i32 %160, %161
store i32 %162, i32* %7
br label %163
163: ; preds = %159, %153
br label %164
164: ; preds = %209, %203, %163
%165 = load i32, i32* %8
%166 = load i32, i32* %7
%167 = icmp slt i32 %165, %166
br i1 %167, label %168, label %216
168: ; preds = %164
%169 = load i32, i32* %15
%170 = getelementptr inbounds [65536 x i8], [65536 x i8]* %17, i64 0, i64 0
%171 = load i32, i32* %7
%172 = load i32, i32* %8
%173 = sub nsw i32 %171, %172
%174 = load i32, i32* %20
%175 = icmp slt i32 %173, %174
br i1 %175, label %176, label %180
176: ; preds = %168
%177 = load i32, i32* %7
%178 = load i32, i32* %8
%179 = sub nsw i32 %177, %178
br label %182
180: ; preds = %168
%181 = load i32, i32* %20
br label %182
182: ; preds = %180, %176
%183 = phi i32 [ %179, %176 ], [ %181, %180 ]
%184 = call i32 @read(i32 %169, i8* %170, i32 %183)
%185 = load i32, i32* %16
%186 = getelementptr inbounds [65536 x i8], [65536 x i8]* %17, i64 0, i64 0
%187 = load i32, i32* %7
%188 = load i32, i32* %8
%189 = sub nsw i32 %187, %188
%190 = load i32, i32* %20
%191 = icmp slt i32 %189, %190
br i1 %191, label %192, label %196
192: ; preds = %182
%193 = load i32, i32* %7
%194 = load i32, i32* %8
%195 = sub nsw i32 %193, %194
br label %198
196: ; preds = %182
%197 = load i32, i32* %20
br label %198
198: ; preds = %196, %192
%199 = phi i32 [ %195, %192 ], [ %197, %196 ]
%200 = call i32 @send(i32 %185, i8* %186, i32 %199, i32 0)
store i32 %200, i32* %19
%201 = load i32, i32* %19
%202 = icmp sle i32 %201, 0
br i1 %202, label %203, label %209
203: ; preds = %198
%204 = load i32, i32* @stderr
%205 = load i32, i32* %19
%206 = load i32, i32* @errno
%207 = call i32 (i32, i8*, ...) @fprintf(i32 %204, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i32 %205, i32 %206)
%208 = call i32 @usleep(i32 100)
br label %164
209: ; preds = %198
%210 = load i32, i32* %19
%211 = load i32, i32* %10
%212 = add nsw i32 %211, %210
store i32 %212, i32* %10
%213 = load i32, i32* %19
%214 = load i32, i32* %8
%215 = add nsw i32 %214, %213
store i32 %215, i32* %8
br label %164
216: ; preds = %164
%217 = call i32 @gettimeofday(%struct.timeval* %14, i32* null)
%218 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
%219 = load double, double* %218
%220 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
%221 = load double, double* %220
%222 = fsub double %219, %221
%223 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
%224 = load double, double* %223
%225 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 1
%226 = load double, double* %225
%227 = fsub double %224, %226
%228 = call double @llvm.fmuladd.f64(double %222, double 1.000000e+06, double %227)
store double %228, double* %11
%229 = load double, double* %11
%230 = load i32, i32* %6
%231 = load i32, i32* %9
%232 = mul nsw i32 %230, %231
%233 = sitofp i32 %232 to double
%234 = fcmp olt double %229, %233
br i1 %234, label %235, label %244
235: ; preds = %216
%236 = load i32, i32* %6
%237 = load i32, i32* %9
%238 = mul nsw i32 %236, %237
%239 = sitofp i32 %238 to double
%240 = load double, double* %11
%241 = fsub double %239, %240
%242 = fptosi double %241 to i32
%243 = call i32 @usleep(i32 %242)
br label %244
244: ; preds = %235, %216
store i32 0, i32* %8
%245 = load i32, i32* %9
%246 = add nsw i32 %245, 1
store i32 %246, i32* %9
br label %149
247: ; preds = %149
%248 = call i32 @gettimeofday(%struct.timeval* %13, i32* null)
%249 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
%250 = load double, double* %249
%251 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
%252 = load double, double* %251
%253 = fsub double %250, %252
%254 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
%255 = load double, double* %254
%256 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 1
%257 = load double, double* %256
%258 = fsub double %255, %257
%259 = fdiv double %258, 1.000000e+06
%260 = fadd double %253, %259
store double %260, double* %11
%261 = load i32, i32* %10
%262 = load double, double* %11
%263 = load i32, i32* %10
%264 = mul nsw i32 %263, 8
%265 = sitofp i32 %264 to double
%266 = load double, double* %11
%267 = fdiv double %265, %266
%268 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0), i32 %261, double %262, double %267)
%269 = load i32, i32* %16
%270 = call i32 @close(i32 %269)
%271 = load i32, i32* %15
%272 = call i32 @close(i32 %271)
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 = [105 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_STREAM = global i32 0
@.str.5 = [33 x i8] c"! Unable to connect the server.\0A\00"
@.str.6 = [50 x i8] c"! Fail to send: ret:%d, err:%d; wait for 100us..\0A\00"
@errno = global i32 0
@.str.7 = [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 ([105 x i8], [105 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 ], [ 1460, %23 ], [ 1460, %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_STREAM
%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 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%99 = call i64 @connect(i32 %85, %struct.sockaddr* %98, i32 12)
%100 = icmp slt i64 %99, 0
br i1 %100, label %101, label %105
101: ; preds = %80
%102 = load i32, i32* @stderr
%103 = call i32 (i32, i8*, ...) @fprintf(i32 %102, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%104 = call i32 @exit(i32 1)
unreachable
105: ; preds = %80
%106 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%107 = icmp sgt i32 %82, 0
br i1 %107, label %110, label %108
108: ; preds = %105
%109 = load <2 x double>, <2 x double>* %3
br label %165
110: ; preds = %105
%111 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
%112 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
%113 = load <2 x double>, <2 x double>* %3
%114 = extractelement <2 x double> %113, i64 0
%115 = extractelement <2 x double> %113, i64 1
br label %116
116: ; preds = %110, %162
%117 = phi i32 [ %50, %110 ], [ %122, %162 ]
%118 = phi i32 [ 0, %110 ], [ %148, %162 ]
%119 = phi i32 [ 1, %110 ], [ %163, %162 ]
%120 = sub nsw i32 %82, %118
%121 = icmp slt i32 %120, %117
%122 = select i1 %121, i32 %120, i32 %117
%123 = icmp sgt i32 %122, 0
br i1 %123, label %124, label %147
124: ; preds = %116, %142
%125 = phi i32 [ %144, %142 ], [ %118, %116 ]
%126 = phi i32 [ %145, %142 ], [ 0, %116 ]
%127 = sub nsw i32 %122, %126
%128 = icmp slt i32 %127, %35
%129 = select i1 %128, i32 %127, i32 %35
%130 = call i32 @read(i32 %81, i8* %13, i32 %129)
%131 = call i32 @send(i32 %85, i8* %13, i32 %129, i32 0)
%132 = icmp slt i32 %131, 1
br i1 %132, label %133, label %142
133: ; preds = %124, %133
%134 = phi i32 [ %140, %133 ], [ %131, %124 ]
%135 = load i32, i32* @stderr
%136 = load i32, i32* @errno
%137 = call i32 (i32, i8*, ...) @fprintf(i32 %135, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i32 %134, i32 %136)
%138 = call i32 @usleep(i32 100)
%139 = call i32 @read(i32 %81, i8* %13, i32 %129)
%140 = call i32 @send(i32 %85, i8* %13, i32 %129, i32 0)
%141 = icmp slt i32 %140, 1
br i1 %141, label %133, label %142
142: ; preds = %133, %124
%143 = phi i32 [ %131, %124 ], [ %140, %133 ]
%144 = add nsw i32 %143, %125
%145 = add nsw i32 %143, %126
%146 = icmp sgt i32 %122, %145
br i1 %146, label %124, label %147
147: ; preds = %142, %116
%148 = phi i32 [ %118, %116 ], [ %144, %142 ]
%149 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%150 = load double, double* %111
%151 = fsub double %150, %114
%152 = load double, double* %112
%153 = fsub double %152, %115
%154 = call double @llvm.fmuladd.f64(double %151, double 1.000000e+06, double %153)
%155 = mul nsw i32 %119, %51
%156 = sitofp i32 %155 to double
%157 = fcmp olt double %154, %156
br i1 %157, label %158, label %162
158: ; preds = %147
%159 = fsub double %156, %154
%160 = fptosi double %159 to i32
%161 = call i32 @usleep(i32 %160)
br label %162
162: ; preds = %158, %147
%163 = add nuw nsw i32 %119, 1
%164 = icmp sgt i32 %82, %148
br i1 %164, label %116, label %165
165: ; preds = %162, %108
%166 = phi i32 [ 0, %108 ], [ %148, %162 ]
%167 = phi <2 x double> [ %109, %108 ], [ %113, %162 ]
%168 = bitcast <2 x double>* %5 to %struct.timeval*
%169 = call i32 @gettimeofday(%struct.timeval* %168, i32* null)
%170 = load <2 x double>, <2 x double>* %5
%171 = fsub <2 x double> %170, %167
%172 = extractelement <2 x double> %171, i64 1
%173 = fdiv double %172, 1.000000e+06
%174 = extractelement <2 x double> %171, i64 0
%175 = fadd double %174, %173
%176 = shl nsw i32 %166, 3
%177 = sitofp i32 %176 to double
%178 = fdiv double %177, %175
%179 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0), i32 %166, double %175, double %178)
%180 = call i32 @close(i32 %85)
%181 = call i32 @close(i32 %81)
ret i32 0
}