#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;
typedef int /*<<< orphan*/ off_t;

/* 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 sendfile(int, int, int /*<<< orphan*/ *, 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;
  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) {
      ret =
          sendfile(sockfd, fd, (off_t *)&total_bytes_sent, quota - sentInSlot);
      if (ret <= 0) {
        fprintf(stderr, "! Fail to send: ret:%d, err:%d; wait for 100us..\n",
                ret, errno);
        usleep(100);
        continue;
      }
      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    $0x90,%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,-0x80(%rbp)
movl   $0x0,-0x84(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    1273 <main+0x73>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
cmpl   $0x4,-0x8(%rbp)
jle    12af <main+0xaf>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10d0 <atoi@plt>
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8c(%rbp)
mov    $0xf4240,%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,%ecx
mov    -0x8c(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
cmpl   $0x5,-0x8(%rbp)
jle    12c9 <main+0xc9>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x80(%rbp)
mov    -0x18(%rbp),%eax
cltd
idivl  -0x80(%rbp)
cmp    $0x0,%edx
jle    131a <main+0x11a>
mov    -0x18(%rbp),%eax
cltd
idivl  -0x80(%rbp)
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
cvtsi2sdl -0x80(%rbp),%xmm1
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  -0x80(%rbp)
add    $0x1,%eax
imul   -0x80(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <isNumber@plt>
cmp    $0x0,%rax
je     138c <main+0x18c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x84(%rbp)
mov    0x2c95(%rip),%rax
mov    (%rax),%esi
lea    0xd1d(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0xffffffff,-0x64(%rbp)
jne    1387 <main+0x187>
mov    0x2c63(%rip),%rax
mov    (%rax),%edi
lea    0xd13(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
jmp    1407 <main+0x207>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2c45(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0xffffffff,-0x64(%rbp)
jne    13d8 <main+0x1d8>
mov    0x2c1a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xced(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x64(%rbp),%edi
lea    -0x88(%rbp),%rsi
call   1100 <fstat@plt>
mov    -0x88(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%esi
lea    0xccf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2bda(%rip),%rax
mov    (%rax),%edi
mov    0x2bb1(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x68(%rbp)
lea    -0x78(%rbp),%rdi
mov    $0xc,%esi
call   10c0 <bzero@plt>
mov    0x2bb0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x70(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <inet_addr@plt>
mov    %eax,-0x74(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,%edi
call   1030 <htons@plt>
mov    %eax,-0x78(%rbp)
mov    -0x68(%rbp),%edi
lea    -0x78(%rbp),%rsi
mov    $0xc,%edx
call   10f0 <connect@plt>
cmp    $0x0,%rax
jge    14a0 <main+0x2a0>
mov    0x2b4a(%rip),%rax
mov    (%rax),%edi
lea    0xc4f(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x24(%rbp),%eax
cmp    -0x84(%rbp),%eax
jge    15cb <main+0x3cb>
mov    -0x84(%rbp),%eax
sub    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    14da <main+0x2da>
mov    -0x84(%rbp),%eax
sub    -0x24(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    14df <main+0x2df>
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    154d <main+0x34d>
mov    -0x68(%rbp),%edi
mov    -0x64(%rbp),%esi
mov    -0x18(%rbp),%ecx
sub    -0x1c(%rbp),%ecx
lea    -0x24(%rbp),%rdx
call   10a0 <sendfile@plt>
mov    %eax,-0x7c(%rbp)
cmpl   $0x0,-0x7c(%rbp)
jg     153f <main+0x33f>
mov    0x2abc(%rip),%rax
mov    (%rax),%edi
mov    -0x7c(%rbp),%edx
mov    0x2aa0(%rip),%rax
mov    (%rax),%ecx
lea    0xbd6(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x64,%edi
call   1110 <usleep@plt>
jmp    14df <main+0x2df>
mov    -0x7c(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    14df <main+0x2df>
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  0xa8a(%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    15b6 <main+0x3b6>
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    14ad <main+0x2ad>
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  0xa0c(%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    0xb12(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    -0x68(%rbp),%edi
call   1060 <close@plt>
mov    -0x64(%rbp),%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %rsi,%r12
movl   $0x0,0x10(%rsp)
cmp    $0x3,%edi
jle    15cd <main+0x3cd>
mov    %edi,%ebp
mov    $0x5b4,%r14d
mov    $0x3b9aca00,%ebx
cmp    $0x4,%edi
je     1269 <main+0x69>
mov    0x20(%r12),%rdi
call   10d0 <atoi@plt>
cltq
imul   $0x51eb851f,%rax,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x28,%rbx
add    %eax,%ebx
cmp    $0x6,%ebp
jb     1269 <main+0x69>
mov    0x28(%r12),%rdi
call   10d0 <atoi@plt>
mov    %eax,%r14d
mov    %ebx,%eax
cltd
idiv   %r14d
test   %edx,%edx
jle    12a3 <main+0xa3>
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
cvtsi2sd %r14d,%xmm1
cvtsi2sd %ebx,%xmm2
mulsd  %xmm0,%xmm1
divsd  %xmm2,%xmm1
mulsd  0xd6d(%rip),%xmm1
cvttsd2si %xmm1,%ecx
mov    %ecx,0x14(%rsp)
imul   %r14d,%eax
mov    %eax,%ebx
jmp    12ab <main+0xab>
movl   $0x2710,0x14(%rsp)
mov    0x8(%r12),%rdi
call   1080 <isNumber@plt>
mov    0x8(%r12),%rdi
test   %rax,%rax
je     12f0 <main+0xf0>
call   10d0 <atoi@plt>
mov    %eax,%ebp
mov    0x2d13(%rip),%rax
mov    (%rax),%esi
lea    0xda3(%rip),%rdi
call   10b0 <open@plt>
cmp    $0xffffffff,%eax
je     15f8 <main+0x3f8>
mov    %eax,%r13d
mov    %ebp,0xc(%rsp)
mov    %rbx,%r15
jmp    132f <main+0x12f>
mov    0x2ce9(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
cmp    $0xffffffff,%eax
je     1619 <main+0x419>
mov    %eax,%r13d
mov    %rbx,%r15
lea    0x20(%rsp),%rsi
mov    %eax,%edi
call   1100 <fstat@plt>
mov    0x20(%rsp),%esi
lea    0xdb3(%rip),%rdi
mov    %esi,0xc(%rsp)
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2cb2(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2c88(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,%ebx
lea    0x30(%rsp),%r14
mov    %r14,%rdi
mov    $0xc,%esi
call   10c0 <bzero@plt>
mov    0x0(%rbp),%eax
mov    %eax,0x38(%rsp)
mov    0x10(%r12),%rdi
call   1070 <inet_addr@plt>
mov    %eax,0x34(%rsp)
mov    0x18(%r12),%rdi
mov    %ebx,%r12d
call   10d0 <atoi@plt>
mov    %eax,%edi
call   1030 <htons@plt>
mov    %eax,0x30(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   10f0 <connect@plt>
test   %rax,%rax
js     15e6 <main+0x3e6>
lea    0x60(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    0xc(%rsp),%edx
test   %edx,%edx
jle    1547 <main+0x347>
mov    %r15,%rbp
movapd 0x60(%rsp),%xmm2
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
movapd %xmm0,0x80(%rsp)
mov    $0x1,%r14d
lea    0x10(%rsp),%rbx
xor    %eax,%eax
movapd %xmm2,0x40(%rsp)
mov    %r13d,0x1c(%rsp)
mov    %r12d,0x18(%rsp)
jmp    1414 <main+0x214>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r14d
mov    0x10(%rsp),%eax
mov    0xc(%rsp),%edx
cmp    %eax,%edx
jle    1553 <main+0x353>
mov    %r14d,0x28(%rsp)
mov    %ebp,%ecx
mov    %edx,%ebp
sub    %eax,%ebp
cmp    %ecx,%ebp
cmovge %ecx,%ebp
test   %ebp,%ebp
jle    14e0 <main+0x2e0>
xor    %eax,%eax
mov    %rbp,0x58(%rsp)
jmp    1462 <main+0x262>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x1c(%rsp),%r13d
mov    %r12,%rbx
mov    0x18(%rsp),%r12d
mov    0x2c(%rsp),%ecx
add    %eax,%ecx
mov    %ecx,%eax
mov    0x58(%rsp),%rbp
cmp    %ecx,%ebp
jle    14e0 <main+0x2e0>
mov    %ebp,%r14d
mov    %eax,0x2c(%rsp)
sub    %eax,%r14d
mov    %r12d,%edi
mov    %r13d,%esi
mov    %rbx,%r12
mov    %rbx,%rdx
mov    %r14d,%ecx
call   10a0 <sendfile@plt>
test   %eax,%eax
jg     1440 <main+0x240>
mov    0x2b35(%rip),%r15
mov    0x1c(%rsp),%r13d
mov    %r12,%rbx
mov    0x18(%rsp),%r12d
lea    0xc68(%rip),%rbp
nop
mov    0x2b29(%rip),%rcx
mov    (%rcx),%edi
mov    (%r15),%ecx
mov    %rbp,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x64,%edi
call   1110 <usleep@plt>
mov    %r12d,%edi
mov    %r13d,%esi
mov    %rbx,%rdx
mov    %r14d,%ecx
call   10a0 <sendfile@plt>
test   %eax,%eax
jle    14a0 <main+0x2a0>
jmp    144d <main+0x24d>
nopl   0x0(%rax)
lea    0x70(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
movsd  0x70(%rsp),%xmm0
movsd  0x78(%rsp),%xmm1
movapd 0x40(%rsp),%xmm2
subsd  %xmm2,%xmm0
subsd  0x80(%rsp),%xmm1
mulsd  0xaf5(%rip),%xmm0
addsd  %xmm1,%xmm0
mov    0x28(%rsp),%r14d
mov    %r14d,%eax
imul   0x14(%rsp),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
ucomisd %xmm0,%xmm1
jbe    1400 <main+0x200>
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1110 <usleep@plt>
jmp    1400 <main+0x200>
movapd 0x60(%rsp),%xmm0
movapd %xmm0,0x40(%rsp)
lea    0x90(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
movapd 0x90(%rsp),%xmm1
subpd  0x40(%rsp),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
divsd  0xa87(%rip),%xmm0
addsd  %xmm1,%xmm0
mov    0x10(%rsp),%esi
lea    0x0(,%rsi,8),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
divsd  %xmm0,%xmm1
lea    0xb97(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    %r12d,%edi
call   1060 <close@plt>
mov    %r13d,%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r12),%rsi
lea    0xa38(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
mov    0x29e3(%rip),%rax
mov    (%rax),%edi
lea    0xaf0(%rip),%rsi
jmp    1608 <main+0x408>
mov    0x29d1(%rip),%rax
mov    (%rax),%edi
lea    0xa89(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    0x29b0(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r12),%rdx
lea    0xa8e(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <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 %struct.sockaddr_in
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = 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* %19
store i32 0, i32* %20
%22 = load i32, i32* %4
%23 = icmp slt i32 %22, 4
br i1 %23, label %24, label %30
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([105 x i8], [105 x i8]* @.str, i64 0, i64 0), i8* %27)
%29 = call i32 @exit(i32 0)
unreachable
30: ; preds = %2
%31 = load i32, i32* %4
%32 = icmp sgt i32 %31, 4
br i1 %32, label %33, label %42
33: ; preds = %30
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 4
%36 = load i8*, i8** %35
%37 = call i32 @atoi(i8* %36)
%38 = sdiv i32 %37, 8
%39 = load i32, i32* %6
%40 = sdiv i32 1000000, %39
%41 = sdiv i32 %38, %40
store i32 %41, i32* %7
br label %42
42: ; preds = %33, %30
%43 = load i32, i32* %4
%44 = icmp sgt i32 %43, 5
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 5
%48 = load i8*, i8** %47
%49 = call i32 @atoi(i8* %48)
store i32 %49, i32* %19
br label %50
50: ; preds = %45, %42
%51 = load i32, i32* %7
%52 = load i32, i32* %19
%53 = srem i32 %51, %52
%54 = icmp sgt i32 %53, 0
br i1 %54, label %55, label %77
55: ; preds = %50
%56 = load i32, i32* %7
%57 = load i32, i32* %19
%58 = sdiv i32 %56, %57
%59 = add nsw i32 %58, 1
%60 = sitofp i32 %59 to double
%61 = load i32, i32* %19
%62 = sitofp i32 %61 to double
%63 = fmul double %60, %62
%64 = load i32, i32* %7
%65 = sitofp i32 %64 to double
%66 = fdiv double %63, %65
%67 = load i32, i32* %6
%68 = sitofp i32 %67 to double
%69 = fmul double %66, %68
%70 = fptosi double %69 to i32
store i32 %70, i32* %6
%71 = load i32, i32* %7
%72 = load i32, i32* %19
%73 = sdiv i32 %71, %72
%74 = add nsw i32 %73, 1
%75 = load i32, i32* %19
%76 = mul nsw i32 %74, %75
store i32 %76, i32* %7
br label %77
77: ; preds = %55, %50
%78 = load i8**, i8*** %5
%79 = getelementptr inbounds i8*, i8** %78, i64 1
%80 = load i8*, i8** %79
%81 = call i64 @isNumber(i8* %80)
%82 = icmp ne i64 %81, 0
br i1 %82, label %83, label %97
83: ; preds = %77
%84 = load i8**, i8*** %5
%85 = getelementptr inbounds i8*, i8** %84, i64 1
%86 = load i8*, i8** %85
%87 = call i32 @atoi(i8* %86)
store i32 %87, i32* %20
%88 = load i32, i32* @O_RDONLY
%89 = call i32 @open(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %88)
store i32 %89, i32* %15
%90 = load i32, i32* %15
%91 = icmp eq i32 %90, -1
br i1 %91, label %92, label %96
92: ; preds = %83
%93 = load i32, i32* @stderr
%94 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%95 = call i32 @exit(i32 1)
unreachable
96: ; preds = %83
br label %119
97: ; preds = %77
%98 = load i8**, i8*** %5
%99 = getelementptr inbounds i8*, i8** %98, i64 1
%100 = load i8*, i8** %99
%101 = load i32, i32* @O_RDONLY
%102 = call i32 @open(i8* %100, i32 %101)
store i32 %102, i32* %15
%103 = load i32, i32* %15
%104 = icmp eq i32 %103, -1
br i1 %104, label %105, label %112
105: ; preds = %97
%106 = load i32, i32* @stderr
%107 = load i8**, i8*** %5
%108 = getelementptr inbounds i8*, i8** %107, i64 1
%109 = load i8*, i8** %108
%110 = call i32 (i32, i8*, ...) @fprintf(i32 %106, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %109)
%111 = call i32 @exit(i32 1)
unreachable
112: ; preds = %97
%113 = load i32, i32* %15
%114 = call i32 @fstat(i32 %113, %struct.stat* %21)
%115 = getelementptr inbounds %struct.stat, %struct.stat* %21, i32 0, i32 0
%116 = load i32, i32* %115
store i32 %116, i32* %20
%117 = load i32, i32* %20
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %117)
br label %119
119: ; preds = %112, %96
%120 = load i32, i32* @AF_INET
%121 = load i32, i32* @SOCK_STREAM
%122 = call i32 @socket(i32 %120, i32 %121, i32 0)
store i32 %122, i32* %16
%123 = call i32 @bzero(%struct.sockaddr_in* %17, i32 12)
%124 = load i32, i32* @AF_INET
%125 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 2
store i32 %124, i32* %125
%126 = load i8**, i8*** %5
%127 = getelementptr inbounds i8*, i8** %126, i64 2
%128 = load i8*, i8** %127
%129 = call i32 @inet_addr(i8* %128)
%130 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 1
%131 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %130, i32 0, i32 0
store i32 %129, i32* %131
%132 = load i8**, i8*** %5
%133 = getelementptr inbounds i8*, i8** %132, i64 3
%134 = load i8*, i8** %133
%135 = call i32 @atoi(i8* %134)
%136 = call i32 @htons(i32 %135)
%137 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %17, i32 0, i32 0
store i32 %136, i32* %137
%138 = load i32, i32* %16
%139 = bitcast %struct.sockaddr_in* %17 to %struct.sockaddr*
%140 = call i64 @connect(i32 %138, %struct.sockaddr* %139, i32 12)
%141 = icmp slt i64 %140, 0
br i1 %141, label %142, label %146
142: ; preds = %119
%143 = load i32, i32* @stderr
%144 = call i32 (i32, i8*, ...) @fprintf(i32 %143, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%145 = call i32 @exit(i32 1)
unreachable
146: ; preds = %119
%147 = call i32 @gettimeofday(%struct.timeval* %12, i32* null)
br label %148
148: ; preds = %214, %146
%149 = load i32, i32* %10
%150 = load i32, i32* %20
%151 = icmp slt i32 %149, %150
br i1 %151, label %152, label %217
152: ; preds = %148
%153 = load i32, i32* %20
%154 = load i32, i32* %10
%155 = sub nsw i32 %153, %154
%156 = load i32, i32* %7
%157 = icmp slt i32 %155, %156
br i1 %157, label %158, label %162
158: ; preds = %152
%159 = load i32, i32* %20
%160 = load i32, i32* %10
%161 = sub nsw i32 %159, %160
store i32 %161, i32* %7
br label %162
162: ; preds = %158, %152
br label %163
163: ; preds = %182, %176, %162
%164 = load i32, i32* %8
%165 = load i32, i32* %7
%166 = icmp slt i32 %164, %165
br i1 %166, label %167, label %186
167: ; preds = %163
%168 = load i32, i32* %16
%169 = load i32, i32* %15
%170 = load i32, i32* %7
%171 = load i32, i32* %8
%172 = sub nsw i32 %170, %171
%173 = call i32 @sendfile(i32 %168, i32 %169, i32* %10, i32 %172)
store i32 %173, i32* %18
%174 = load i32, i32* %18
%175 = icmp sle i32 %174, 0
br i1 %175, label %176, label %182
176: ; preds = %167
%177 = load i32, i32* @stderr
%178 = load i32, i32* %18
%179 = load i32, i32* @errno
%180 = call i32 (i32, i8*, ...) @fprintf(i32 %177, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i32 %178, i32 %179)
%181 = call i32 @usleep(i32 100)
br label %163
182: ; preds = %167
%183 = load i32, i32* %18
%184 = load i32, i32* %8
%185 = add nsw i32 %184, %183
store i32 %185, i32* %8
br label %163
186: ; preds = %163
%187 = call i32 @gettimeofday(%struct.timeval* %14, i32* null)
%188 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
%189 = load double, double* %188
%190 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
%191 = load double, double* %190
%192 = fsub double %189, %191
%193 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
%194 = load double, double* %193
%195 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 1
%196 = load double, double* %195
%197 = fsub double %194, %196
%198 = call double @llvm.fmuladd.f64(double %192, double 1.000000e+06, double %197)
store double %198, double* %11
%199 = load double, double* %11
%200 = load i32, i32* %6
%201 = load i32, i32* %9
%202 = mul nsw i32 %200, %201
%203 = sitofp i32 %202 to double
%204 = fcmp olt double %199, %203
br i1 %204, label %205, label %214
205: ; preds = %186
%206 = load i32, i32* %6
%207 = load i32, i32* %9
%208 = mul nsw i32 %206, %207
%209 = sitofp i32 %208 to double
%210 = load double, double* %11
%211 = fsub double %209, %210
%212 = fptosi double %211 to i32
%213 = call i32 @usleep(i32 %212)
br label %214
214: ; preds = %205, %186
store i32 0, i32* %8
%215 = load i32, i32* %9
%216 = add nsw i32 %215, 1
store i32 %216, i32* %9
br label %148
217: ; preds = %148
%218 = call i32 @gettimeofday(%struct.timeval* %13, i32* null)
%219 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
%220 = load double, double* %219
%221 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
%222 = load double, double* %221
%223 = fsub double %220, %222
%224 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
%225 = load double, double* %224
%226 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 1
%227 = load double, double* %226
%228 = fsub double %225, %227
%229 = fdiv double %228, 1.000000e+06
%230 = fadd double %223, %229
store double %230, double* %11
%231 = load i32, i32* %10
%232 = load double, double* %11
%233 = load i32, i32* %10
%234 = mul nsw i32 %233, 8
%235 = sitofp i32 %234 to double
%236 = load double, double* %11
%237 = fdiv double %235, %236
%238 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0), i32 %231, double %232, double %237)
%239 = load i32, i32* %16
%240 = call i32 @close(i32 %239)
%241 = load i32, i32* %15
%242 = call i32 @close(i32 %241)
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 i32
%4 = alloca <2 x double>
%5 = bitcast <2 x double>* %4 to %struct.timeval*
%6 = alloca <2 x double>
%7 = alloca %struct.timeval
%8 = alloca %struct.sockaddr_in
%9 = alloca %struct.stat
%10 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%11 = bitcast <2 x double>* %4 to i8*
%12 = bitcast <2 x double>* %6 to i8*
%13 = bitcast %struct.timeval* %7 to i8*
%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* %5, 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>* %4
br label %159
110: ; preds = %105
%111 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 0
%112 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 1
%113 = load <2 x double>, <2 x double>* %4
%114 = extractelement <2 x double> %113, i64 0
%115 = extractelement <2 x double> %113, i64 1
br label %116
116: ; preds = %110, %155
%117 = phi i32 [ 0, %110 ], [ %157, %155 ]
%118 = phi i32 [ %50, %110 ], [ %122, %155 ]
%119 = phi i32 [ 1, %110 ], [ %156, %155 ]
%120 = sub nsw i32 %82, %117
%121 = icmp slt i32 %120, %118
%122 = select i1 %121, i32 %120, i32 %118
%123 = icmp sgt i32 %122, 0
br i1 %123, label %124, label %141
124: ; preds = %116, %137
%125 = phi i32 [ %139, %137 ], [ 0, %116 ]
%126 = sub nsw i32 %122, %125
%127 = call i32 @sendfile(i32 %85, i32 %81, i32* %3, i32 %126)
%128 = icmp slt i32 %127, 1
br i1 %128, label %129, label %137
129: ; preds = %124, %129
%130 = phi i32 [ %135, %129 ], [ %127, %124 ]
%131 = load i32, i32* @stderr
%132 = load i32, i32* @errno
%133 = call i32 (i32, i8*, ...) @fprintf(i32 %131, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i32 %130, i32 %132)
%134 = call i32 @usleep(i32 100)
%135 = call i32 @sendfile(i32 %85, i32 %81, i32* %3, i32 %126)
%136 = icmp slt i32 %135, 1
br i1 %136, label %129, label %137
137: ; preds = %129, %124
%138 = phi i32 [ %127, %124 ], [ %135, %129 ]
%139 = add nsw i32 %138, %125
%140 = icmp sgt i32 %122, %139
br i1 %140, label %124, label %141
141: ; preds = %137, %116
%142 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%143 = load double, double* %111
%144 = fsub double %143, %114
%145 = load double, double* %112
%146 = fsub double %145, %115
%147 = call double @llvm.fmuladd.f64(double %144, double 1.000000e+06, double %146)
%148 = mul nsw i32 %119, %51
%149 = sitofp i32 %148 to double
%150 = fcmp olt double %147, %149
br i1 %150, label %151, label %155
151: ; preds = %141
%152 = fsub double %149, %147
%153 = fptosi double %152 to i32
%154 = call i32 @usleep(i32 %153)
br label %155
155: ; preds = %151, %141
%156 = add nuw nsw i32 %119, 1
%157 = load i32, i32* %3
%158 = icmp sgt i32 %82, %157
br i1 %158, label %116, label %159
159: ; preds = %155, %108
%160 = phi <2 x double> [ %109, %108 ], [ %113, %155 ]
%161 = bitcast <2 x double>* %6 to %struct.timeval*
%162 = call i32 @gettimeofday(%struct.timeval* %161, i32* null)
%163 = load <2 x double>, <2 x double>* %6
%164 = fsub <2 x double> %163, %160
%165 = extractelement <2 x double> %164, i64 1
%166 = fdiv double %165, 1.000000e+06
%167 = extractelement <2 x double> %164, i64 0
%168 = fadd double %167, %166
%169 = load i32, i32* %3
%170 = shl nsw i32 %169, 3
%171 = sitofp i32 %170 to double
%172 = fdiv double %171, %168
%173 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0), i32 %169, double %168, double %172)
%174 = call i32 @close(i32 %85)
%175 = call i32 @close(i32 %81)
ret i32 0
}