#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_DGRAM;
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*/ perror(char *);
int pipe(int *);
int /*<<< orphan*/ printf(char *, ...);
int sendfile(int, int, int /*<<< orphan*/ *, 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;
  int bytes, bytes_sent, bytes_in_pipe;
  double elapsedTime;
  struct timeval t_start, t_end, t_now;
  int fd;
  int sockfd;
  struct sockaddr_in servaddr;
  int ret;
  int sendsize = 1472;
  int bytes2send = 0;
  struct stat st;
  off_t offset = 0;
  int filedes[2];
  ret = pipe(filedes);
  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]));
  if (connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0) {
    perror("connect failed\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, &offset,
          ((quota - sentInSlot < sendsize) ? (quota - sentInSlot) : sendsize));
      if (ret <= 0) {
        fprintf(stderr, "! Fail to send: ret:%d, err:%d; wait for 100us..\n",
                ret, errno);
        usleep(100);
        continue;
      }
      sentInSlot += ret;
      total_bytes_sent += 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    $0xb0,%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,-0x88(%rbp)
movl   $0x0,-0x8c(%rbp)
movl   $0x0,-0x94(%rbp)
lea    -0x9c(%rbp),%rdi
call   1080 <pipe@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    12c2 <main+0x92>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1110 <exit@plt>
cmpl   $0x4,-0x8(%rbp)
jle    12fe <main+0xce>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1100 <atoi@plt>
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0xa0(%rbp)
mov    $0xf4240,%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,%ecx
mov    -0xa0(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
cmpl   $0x5,-0x8(%rbp)
jle    131b <main+0xeb>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   1100 <atoi@plt>
mov    %eax,-0x88(%rbp)
mov    -0x18(%rbp),%eax
cltd
idivl  -0x88(%rbp)
cmp    $0x0,%edx
jle    137b <main+0x14b>
mov    -0x18(%rbp),%eax
cltd
idivl  -0x88(%rbp)
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
cvtsi2sdl -0x88(%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  -0x88(%rbp)
add    $0x1,%eax
imul   -0x88(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <isNumber@plt>
cmp    $0x0,%rax
je     13ed <main+0x1bd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1100 <atoi@plt>
mov    %eax,-0x8c(%rbp)
mov    0x2c34(%rip),%rax
mov    (%rax),%esi
lea    0xcbd(%rip),%rdi
call   10d0 <open@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0xffffffff,-0x6c(%rbp)
jne    13e8 <main+0x1b8>
mov    0x2bfa(%rip),%rax
mov    (%rax),%edi
lea    0xcb3(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    1468 <main+0x238>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2be4(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0xffffffff,-0x6c(%rbp)
jne    1439 <main+0x209>
mov    0x2bb1(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xc8d(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x6c(%rbp),%edi
lea    -0x90(%rbp),%rsi
call   1130 <fstat@plt>
mov    -0x90(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x8c(%rbp),%esi
lea    0xc6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2b79(%rip),%rax
mov    (%rax),%edi
mov    0x2b60(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,-0x70(%rbp)
lea    -0x80(%rbp),%rdi
mov    $0xc,%esi
call   10f0 <bzero@plt>
mov    0x2b4f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x78(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <inet_addr@plt>
mov    %eax,-0x7c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1100 <atoi@plt>
mov    %eax,%edi
call   1030 <htons@plt>
mov    %eax,-0x80(%rbp)
mov    -0x70(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    $0xc,%edx
call   1120 <connect@plt>
cmp    $0x0,%rax
jge    14f6 <main+0x2c6>
lea    0xbf8(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xffffffff,%edi
call   1110 <exit@plt>
lea    -0x48(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x24(%rbp),%eax
cmp    -0x8c(%rbp),%eax
jge    1683 <main+0x453>
mov    -0x8c(%rbp),%eax
sub    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1530 <main+0x300>
mov    -0x8c(%rbp),%eax
sub    -0x24(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1535 <main+0x305>
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1605 <main+0x3d5>
mov    -0x70(%rbp),%eax
mov    %eax,-0xa8(%rbp)
mov    -0x6c(%rbp),%eax
mov    %eax,-0xa4(%rbp)
mov    -0x18(%rbp),%eax
sub    -0x1c(%rbp),%eax
cmp    -0x88(%rbp),%eax
jge    1576 <main+0x346>
mov    -0x18(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0xac(%rbp)
jmp    1582 <main+0x352>
mov    -0x88(%rbp),%eax
mov    %eax,-0xac(%rbp)
mov    -0xa4(%rbp),%esi
mov    -0xa8(%rbp),%edi
mov    -0xac(%rbp),%ecx
lea    -0x94(%rbp),%rdx
call   10c0 <sendfile@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x84(%rbp)
jg     15e8 <main+0x3b8>
mov    0x2a0e(%rip),%rax
mov    (%rax),%edi
mov    -0x84(%rbp),%edx
mov    0x29f7(%rip),%rax
mov    (%rax),%ecx
lea    0xb1d(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x64,%edi
call   1140 <usleep@plt>
jmp    1535 <main+0x305>
mov    -0x84(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x84(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1535 <main+0x305>
lea    -0x68(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
movsd  -0x68(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
subsd  -0x40(%rbp),%xmm1
movsd  0x9d2(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm1
mov    -0x14(%rbp),%eax
imul   -0x20(%rbp),%eax
cvtsi2sd %eax,%xmm0
ucomisd %xmm1,%xmm0
jbe    166e <main+0x43e>
mov    -0x14(%rbp),%eax
imul   -0x20(%rbp),%eax
cvtsi2sd %eax,%xmm0
subsd  -0x38(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1140 <usleep@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1503 <main+0x2d3>
mov    -0x70(%rbp),%edi
lea    -0x80(%rbp),%r8
lea    0xa90(%rip),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1060 <sendto@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x84(%rbp)
jg     16f0 <main+0x4c0>
mov    0x290b(%rip),%rax
mov    (%rax),%edi
mov    0x28fa(%rip),%rax
mov    (%rax),%edx
lea    0xa57(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x70(%rbp),%edi
call   1070 <close@plt>
mov    -0x6c(%rbp),%edi
call   1070 <close@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    -0x58(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
movsd  -0x58(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
subsd  -0x40(%rbp),%xmm1
movsd  0x8e7(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x24(%rbp),%esi
movsd  -0x38(%rbp),%xmm0
mov    -0x24(%rbp),%eax
shl    $0x3,%eax
cvtsi2sd %eax,%xmm1
divsd  -0x38(%rbp),%xmm1
lea    0xa0c(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    -0x70(%rbp),%edi
call   1070 <close@plt>
mov    -0x6c(%rbp),%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
movl   $0x0,0x2c(%rsp)
lea    0x90(%rsp),%rdi
call   1080 <pipe@plt>
cmp    $0x3,%ebx
jle    1624 <main+0x3f4>
mov    $0x5c0,%r15d
mov    $0x3b9aca00,%ebp
cmp    $0x4,%ebx
je     12a4 <main+0x74>
mov    0x20(%r14),%rdi
call   1100 <atoi@plt>
cltq
imul   $0x51eb851f,%rax,%rbp
mov    %rbp,%rax
shr    $0x3f,%rax
sar    $0x28,%rbp
add    %eax,%ebp
cmp    $0x6,%ebx
jb     12a4 <main+0x74>
mov    0x28(%r14),%rdi
call   1100 <atoi@plt>
mov    %eax,%r15d
mov    %ebp,%eax
cltd
idiv   %r15d
test   %edx,%edx
jle    12de <main+0xae>
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
cvtsi2sd %r15d,%xmm1
cvtsi2sd %ebp,%xmm2
mulsd  %xmm0,%xmm1
divsd  %xmm2,%xmm1
mulsd  0xd32(%rip),%xmm1
cvttsd2si %xmm1,%ecx
mov    %ecx,0x14(%rsp)
imul   %r15d,%eax
mov    %eax,%ebp
jmp    12e6 <main+0xb6>
movl   $0x2710,0x14(%rsp)
mov    0x8(%r14),%rdi
call   10a0 <isNumber@plt>
mov    0x8(%r14),%rdi
test   %rax,%rax
mov    %r15d,0x24(%rsp)
mov    %r14,%rbx
mov    %rbp,%r12
je     132f <main+0xff>
call   1100 <atoi@plt>
mov    %eax,%r13d
mov    0x2cce(%rip),%rax
mov    (%rax),%esi
lea    0xd5f(%rip),%rdi
call   10d0 <open@plt>
cmp    $0xffffffff,%eax
je     168c <main+0x45c>
mov    %eax,0xc(%rsp)
jmp    136c <main+0x13c>
mov    0x2caa(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
cmp    $0xffffffff,%eax
je     16ad <main+0x47d>
lea    0x18(%rsp),%rsi
mov    %eax,0xc(%rsp)
mov    %eax,%edi
call   1130 <fstat@plt>
mov    0x18(%rsp),%r13d
lea    0xd76(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2c75(%rip),%r15
mov    (%r15),%edi
mov    0x2c5b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,%ebp
lea    0x30(%rsp),%r14
mov    %r14,%rdi
mov    $0xc,%esi
call   10f0 <bzero@plt>
mov    (%r15),%eax
mov    %eax,0x38(%rsp)
mov    0x10(%rbx),%rdi
call   1090 <inet_addr@plt>
mov    %eax,0x34(%rsp)
mov    0x18(%rbx),%rdi
call   1100 <atoi@plt>
mov    %eax,%edi
call   1030 <htons@plt>
mov    %eax,0x30(%rsp)
mov    %ebp,0x10(%rsp)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   1120 <connect@plt>
test   %rax,%rax
js     163c <main+0x40c>
lea    0x40(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
test   %r13d,%r13d
mov    $0x0,%ebx
jle    1580 <main+0x350>
mov    %r12,%rbp
movsd  0x40(%rsp),%xmm0
movsd  %xmm0,0x58(%rsp)
movsd  0x48(%rsp),%xmm0
movsd  %xmm0,0x50(%rsp)
mov    $0x1,%r15d
lea    0x2c(%rsp),%r12
xor    %ebx,%ebx
mov    %r13d,0x1c(%rsp)
jmp    1442 <main+0x212>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r15d
mov    0x1c(%rsp),%r13d
cmp    %ebx,%r13d
jle    1580 <main+0x350>
mov    %r15d,0x20(%rsp)
mov    %ebp,%eax
mov    %r13d,%ebp
sub    %ebx,%ebp
cmp    %eax,%ebp
cmovge %eax,%ebp
test   %ebp,%ebp
jle    1520 <main+0x2f0>
xor    %ecx,%ecx
mov    %rbp,0x60(%rsp)
jmp    148a <main+0x25a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x28(%rsp),%ecx
add    %eax,%ecx
mov    0x68(%rsp),%rbx
add    %eax,%ebx
mov    0x60(%rsp),%rbp
cmp    %ecx,%ebp
jle    1520 <main+0x2f0>
mov    %rbx,0x68(%rsp)
mov    %ebp,%r15d
mov    %ecx,0x28(%rsp)
sub    %ecx,%r15d
mov    0x24(%rsp),%eax
cmp    %eax,%r15d
cmovge %eax,%r15d
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%ebp
mov    %ebp,%esi
mov    %r12,%rbx
mov    %r12,%rdx
mov    %r15d,%ecx
call   10c0 <sendfile@plt>
test   %eax,%eax
jg     1470 <main+0x240>
mov    0x10(%rsp),%ebx
mov    0x2af5(%rip),%r13
lea    0xc25(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x2ae1(%rip),%rcx
mov    (%rcx),%edi
mov    0x0(%r13),%ecx
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x64,%edi
call   1140 <usleep@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r12,%rdx
mov    %r15d,%ecx
call   10c0 <sendfile@plt>
test   %eax,%eax
jle    14e0 <main+0x2b0>
jmp    1470 <main+0x240>
nopl   0x0(%rax,%rax,1)
lea    0x70(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
movsd  0x70(%rsp),%xmm0
subsd  0x58(%rsp),%xmm0
movsd  0x78(%rsp),%xmm1
subsd  0x50(%rsp),%xmm1
mulsd  0xabc(%rip),%xmm0
addsd  %xmm1,%xmm0
mov    0x20(%rsp),%r15d
mov    %r15d,%eax
imul   0x14(%rsp),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
ucomisd %xmm0,%xmm1
jbe    1430 <main+0x200>
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1140 <usleep@plt>
jmp    1430 <main+0x200>
lea    0xba2(%rip),%rsi
lea    0x30(%rsp),%r8
mov    0x10(%rsp),%ebp
mov    %ebp,%edi
mov    $0x4,%edx
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1060 <sendto@plt>
test   %eax,%eax
jle    1652 <main+0x422>
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  0xa2e(%rip),%xmm0
addsd  %xmm1,%xmm0
lea    0x0(,%rbx,8),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
divsd  %xmm0,%xmm1
lea    0xb61(%rip),%rdi
mov    %ebx,%esi
mov    $0x2,%al
call   1040 <printf@plt>
mov    %ebp,%edi
call   1070 <close@plt>
mov    0xc(%rsp),%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r14),%rsi
lea    0x9e2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1110 <exit@plt>
lea    0xaa4(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xffffffff,%edi
call   1110 <exit@plt>
mov    0x296f(%rip),%rax
mov    (%rax),%edi
mov    0x295e(%rip),%rax
mov    (%rax),%edx
lea    0xac3(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    %ebp,%edi
call   1070 <close@plt>
mov    0xc(%rsp),%edi
call   1070 <close@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x2935(%rip),%rax
mov    (%rax),%edi
lea    0x9f6(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x2914(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0x9fc(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <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
@.str.5 = [16 x i8] c"connect failed\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 = [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 i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
%15 = alloca %struct.timeval
%16 = alloca %struct.timeval
%17 = alloca %struct.timeval
%18 = alloca i32
%19 = alloca i32
%20 = alloca %struct.sockaddr_in
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca %struct.stat
%25 = alloca i32
%26 = alloca [2 x i32]
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* %22
store i32 0, i32* %23
store i32 0, i32* %25
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %26, i64 0, i64 0
%28 = call i32 @pipe(i32* %27)
store i32 %28, i32* %21
%29 = load i32, i32* %4
%30 = icmp slt i32 %29, 4
br i1 %30, label %31, label %37
31: ; preds = %2
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 0
%34 = load i8*, i8** %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([106 x i8], [106 x i8]* @.str, i64 0, i64 0), i8* %34)
%36 = call i32 @exit(i32 0)
unreachable
37: ; preds = %2
%38 = load i32, i32* %4
%39 = icmp sgt i32 %38, 4
br i1 %39, label %40, label %49
40: ; preds = %37
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 4
%43 = load i8*, i8** %42
%44 = call i32 @atoi(i8* %43)
%45 = sdiv i32 %44, 8
%46 = load i32, i32* %6
%47 = sdiv i32 1000000, %46
%48 = sdiv i32 %45, %47
store i32 %48, i32* %7
br label %49
49: ; preds = %40, %37
%50 = load i32, i32* %4
%51 = icmp sgt i32 %50, 5
br i1 %51, label %52, label %57
52: ; preds = %49
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 5
%55 = load i8*, i8** %54
%56 = call i32 @atoi(i8* %55)
store i32 %56, i32* %22
br label %57
57: ; preds = %52, %49
%58 = load i32, i32* %7
%59 = load i32, i32* %22
%60 = srem i32 %58, %59
%61 = icmp sgt i32 %60, 0
br i1 %61, label %62, label %84
62: ; preds = %57
%63 = load i32, i32* %7
%64 = load i32, i32* %22
%65 = sdiv i32 %63, %64
%66 = add nsw i32 %65, 1
%67 = sitofp i32 %66 to double
%68 = load i32, i32* %22
%69 = sitofp i32 %68 to double
%70 = fmul double %67, %69
%71 = load i32, i32* %7
%72 = sitofp i32 %71 to double
%73 = fdiv double %70, %72
%74 = load i32, i32* %6
%75 = sitofp i32 %74 to double
%76 = fmul double %73, %75
%77 = fptosi double %76 to i32
store i32 %77, i32* %6
%78 = load i32, i32* %7
%79 = load i32, i32* %22
%80 = sdiv i32 %78, %79
%81 = add nsw i32 %80, 1
%82 = load i32, i32* %22
%83 = mul nsw i32 %81, %82
store i32 %83, i32* %7
br label %84
84: ; preds = %62, %57
%85 = load i8**, i8*** %5
%86 = getelementptr inbounds i8*, i8** %85, i64 1
%87 = load i8*, i8** %86
%88 = call i64 @isNumber(i8* %87)
%89 = icmp ne i64 %88, 0
br i1 %89, label %90, label %104
90: ; preds = %84
%91 = load i8**, i8*** %5
%92 = getelementptr inbounds i8*, i8** %91, i64 1
%93 = load i8*, i8** %92
%94 = call i32 @atoi(i8* %93)
store i32 %94, i32* %23
%95 = load i32, i32* @O_RDONLY
%96 = call i32 @open(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %95)
store i32 %96, i32* %18
%97 = load i32, i32* %18
%98 = icmp eq i32 %97, -1
br i1 %98, label %99, label %103
99: ; preds = %90
%100 = load i32, i32* @stderr
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%102 = call i32 @exit(i32 1)
unreachable
103: ; preds = %90
br label %126
104: ; preds = %84
%105 = load i8**, i8*** %5
%106 = getelementptr inbounds i8*, i8** %105, i64 1
%107 = load i8*, i8** %106
%108 = load i32, i32* @O_RDONLY
%109 = call i32 @open(i8* %107, i32 %108)
store i32 %109, i32* %18
%110 = load i32, i32* %18
%111 = icmp eq i32 %110, -1
br i1 %111, label %112, label %119
112: ; preds = %104
%113 = load i32, i32* @stderr
%114 = load i8**, i8*** %5
%115 = getelementptr inbounds i8*, i8** %114, i64 1
%116 = load i8*, i8** %115
%117 = call i32 (i32, i8*, ...) @fprintf(i32 %113, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %116)
%118 = call i32 @exit(i32 1)
unreachable
119: ; preds = %104
%120 = load i32, i32* %18
%121 = call i32 @fstat(i32 %120, %struct.stat* %24)
%122 = getelementptr inbounds %struct.stat, %struct.stat* %24, i32 0, i32 0
%123 = load i32, i32* %122
store i32 %123, i32* %23
%124 = load i32, i32* %23
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %124)
br label %126
126: ; preds = %119, %103
%127 = load i32, i32* @AF_INET
%128 = load i32, i32* @SOCK_DGRAM
%129 = call i32 @socket(i32 %127, i32 %128, i32 0)
store i32 %129, i32* %19
%130 = call i32 @bzero(%struct.sockaddr_in* %20, i32 12)
%131 = load i32, i32* @AF_INET
%132 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %20, i32 0, i32 2
store i32 %131, i32* %132
%133 = load i8**, i8*** %5
%134 = getelementptr inbounds i8*, i8** %133, i64 2
%135 = load i8*, i8** %134
%136 = call i32 @inet_addr(i8* %135)
%137 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %20, i32 0, i32 1
%138 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %137, i32 0, i32 0
store i32 %136, i32* %138
%139 = load i8**, i8*** %5
%140 = getelementptr inbounds i8*, i8** %139, i64 3
%141 = load i8*, i8** %140
%142 = call i32 @atoi(i8* %141)
%143 = call i32 @htons(i32 %142)
%144 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %20, i32 0, i32 0
store i32 %143, i32* %144
%145 = load i32, i32* %19
%146 = bitcast %struct.sockaddr_in* %20 to %struct.sockaddr*
%147 = call i64 @connect(i32 %145, %struct.sockaddr* %146, i32 12)
%148 = icmp slt i64 %147, 0
br i1 %148, label %149, label %152
149: ; preds = %126
%150 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%151 = call i32 @exit(i32 -1)
unreachable
152: ; preds = %126
%153 = call i32 @gettimeofday(%struct.timeval* %15, i32* null)
br label %154
154: ; preds = %233, %152
%155 = load i32, i32* %10
%156 = load i32, i32* %23
%157 = icmp slt i32 %155, %156
br i1 %157, label %158, label %236
158: ; preds = %154
%159 = load i32, i32* %23
%160 = load i32, i32* %10
%161 = sub nsw i32 %159, %160
%162 = load i32, i32* %7
%163 = icmp slt i32 %161, %162
br i1 %163, label %164, label %168
164: ; preds = %158
%165 = load i32, i32* %23
%166 = load i32, i32* %10
%167 = sub nsw i32 %165, %166
store i32 %167, i32* %7
br label %168
168: ; preds = %164, %158
br label %169
169: ; preds = %198, %192, %168
%170 = load i32, i32* %8
%171 = load i32, i32* %7
%172 = icmp slt i32 %170, %171
br i1 %172, label %173, label %205
173: ; preds = %169
%174 = load i32, i32* %19
%175 = load i32, i32* %18
%176 = load i32, i32* %7
%177 = load i32, i32* %8
%178 = sub nsw i32 %176, %177
%179 = load i32, i32* %22
%180 = icmp slt i32 %178, %179
br i1 %180, label %181, label %185
181: ; preds = %173
%182 = load i32, i32* %7
%183 = load i32, i32* %8
%184 = sub nsw i32 %182, %183
br label %187
185: ; preds = %173
%186 = load i32, i32* %22
br label %187
187: ; preds = %185, %181
%188 = phi i32 [ %184, %181 ], [ %186, %185 ]
%189 = call i32 @sendfile(i32 %174, i32 %175, i32* %25, i32 %188)
store i32 %189, i32* %21
%190 = load i32, i32* %21
%191 = icmp sle i32 %190, 0
br i1 %191, label %192, label %198
192: ; preds = %187
%193 = load i32, i32* @stderr
%194 = load i32, i32* %21
%195 = load i32, i32* @errno
%196 = call i32 (i32, i8*, ...) @fprintf(i32 %193, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i32 %194, i32 %195)
%197 = call i32 @usleep(i32 100)
br label %169
198: ; preds = %187
%199 = load i32, i32* %21
%200 = load i32, i32* %8
%201 = add nsw i32 %200, %199
store i32 %201, i32* %8
%202 = load i32, i32* %21
%203 = load i32, i32* %10
%204 = add nsw i32 %203, %202
store i32 %204, i32* %10
br label %169
205: ; preds = %169
%206 = call i32 @gettimeofday(%struct.timeval* %17, i32* null)
%207 = getelementptr inbounds %struct.timeval, %struct.timeval* %17, i32 0, i32 0
%208 = load double, double* %207
%209 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 0
%210 = load double, double* %209
%211 = fsub double %208, %210
%212 = getelementptr inbounds %struct.timeval, %struct.timeval* %17, i32 0, i32 1
%213 = load double, double* %212
%214 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 1
%215 = load double, double* %214
%216 = fsub double %213, %215
%217 = call double @llvm.fmuladd.f64(double %211, double 1.000000e+06, double %216)
store double %217, double* %14
%218 = load double, double* %14
%219 = load i32, i32* %6
%220 = load i32, i32* %9
%221 = mul nsw i32 %219, %220
%222 = sitofp i32 %221 to double
%223 = fcmp olt double %218, %222
br i1 %223, label %224, label %233
224: ; preds = %205
%225 = load i32, i32* %6
%226 = load i32, i32* %9
%227 = mul nsw i32 %225, %226
%228 = sitofp i32 %227 to double
%229 = load double, double* %14
%230 = fsub double %228, %229
%231 = fptosi double %230 to i32
%232 = call i32 @usleep(i32 %231)
br label %233
233: ; preds = %224, %205
store i32 0, i32* %8
%234 = load i32, i32* %9
%235 = add nsw i32 %234, 1
store i32 %235, i32* %9
br label %154
236: ; preds = %154
%237 = load i32, i32* %19
%238 = bitcast %struct.sockaddr_in* %20 to %struct.sockaddr*
%239 = call i32 @sendto(i32 %237, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 4, i32 0, %struct.sockaddr* %238, i32 12)
store i32 %239, i32* %21
%240 = load i32, i32* %21
%241 = icmp sle i32 %240, 0
br i1 %241, label %242, label %251
242: ; preds = %236
%243 = load i32, i32* @stderr
%244 = load i32, i32* @errno
%245 = call i32 (i32, i8*, ...) @fprintf(i32 %243, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i32 %244)
%246 = load i32, i32* %19
%247 = call i32 @close(i32 %246)
%248 = load i32, i32* %18
%249 = call i32 @close(i32 %248)
%250 = call i32 @exit(i32 1)
unreachable
251: ; preds = %236
%252 = call i32 @gettimeofday(%struct.timeval* %16, i32* null)
%253 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 0
%254 = load double, double* %253
%255 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 0
%256 = load double, double* %255
%257 = fsub double %254, %256
%258 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 1
%259 = load double, double* %258
%260 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 1
%261 = load double, double* %260
%262 = fsub double %259, %261
%263 = fdiv double %262, 1.000000e+06
%264 = fadd double %257, %263
store double %264, double* %14
%265 = load i32, i32* %10
%266 = load double, double* %14
%267 = load i32, i32* %10
%268 = mul nsw i32 %267, 8
%269 = sitofp i32 %268 to double
%270 = load double, double* %14
%271 = fdiv double %269, %270
%272 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.9, i64 0, i64 0), i32 %265, double %266, double %271)
%273 = load i32, i32* %19
%274 = call i32 @close(i32 %273)
%275 = load i32, i32* %18
%276 = call i32 @close(i32 %275)
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
@.str.5 = [16 x i8] c"connect failed\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 = [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 %struct.sockaddr_in
%8 = alloca %struct.stat
%9 = alloca i32
%10 = alloca [2 x i32]
%11 = bitcast <2 x double>* %3 to i8*
%12 = bitcast <2 x double>* %5 to i8*
%13 = bitcast %struct.timeval* %6 to i8*
%14 = bitcast %struct.sockaddr_in* %7 to i8*
%15 = bitcast %struct.stat* %8 to i8*
%16 = bitcast i32* %9 to i8*
store i32 0, i32* %9
%17 = bitcast [2 x i32]* %10 to i8*
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%19 = call i32 @pipe(i32* %18)
%20 = icmp slt i32 %0, 4
br i1 %20, label %21, label %25
21: ; preds = %2
%22 = load i8*, i8** %1
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([106 x i8], [106 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = call i32 @exit(i32 0)
unreachable
25: ; preds = %2
%26 = icmp eq i32 %0, 4
br i1 %26, label %37, label %27
27: ; preds = %25
%28 = getelementptr inbounds i8*, i8** %1, i64 4
%29 = load i8*, i8** %28
%30 = call i32 @atoi(i8* %29)
%31 = sdiv i32 %30, 800
%32 = icmp ugt i32 %0, 5
br i1 %32, label %33, label %37
33: ; preds = %27
%34 = getelementptr inbounds i8*, i8** %1, i64 5
%35 = load i8*, i8** %34
%36 = call i32 @atoi(i8* %35)
br label %37
37: ; preds = %25, %33, %27
%38 = phi i32 [ %31, %33 ], [ %31, %27 ], [ 1000000000, %25 ]
%39 = phi i32 [ %36, %33 ], [ 1472, %27 ], [ 1472, %25 ]
%40 = srem i32 %38, %39
%41 = sdiv i32 %38, %39
%42 = icmp sgt i32 %40, 0
br i1 %42, label %43, label %53
43: ; preds = %37
%44 = add nsw i32 %41, 1
%45 = sitofp i32 %44 to double
%46 = sitofp i32 %39 to double
%47 = fmul double %46, %45
%48 = sitofp i32 %38 to double
%49 = fdiv double %47, %48
%50 = fmul double %49, 1.000000e+04
%51 = fptosi double %50 to i32
%52 = mul nsw i32 %44, %39
br label %53
53: ; preds = %43, %37
%54 = phi i32 [ %52, %43 ], [ %38, %37 ]
%55 = phi i32 [ %51, %43 ], [ 10000, %37 ]
%56 = getelementptr inbounds i8*, i8** %1, i64 1
%57 = load i8*, i8** %56
%58 = call i64 @isNumber(i8* %57)
%59 = icmp eq i64 %58, 0
%60 = load i8*, i8** %56
br i1 %59, label %70, label %61
61: ; preds = %53
%62 = call i32 @atoi(i8* %60)
%63 = load i32, i32* @O_RDONLY
%64 = call i32 @open(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %63)
%65 = icmp eq i32 %64, -1
br i1 %65, label %66, label %84
66: ; preds = %61
%67 = load i32, i32* @stderr
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%69 = call i32 @exit(i32 1)
unreachable
70: ; preds = %53
%71 = load i32, i32* @O_RDONLY
%72 = call i32 @open(i8* %60, i32 %71)
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %79
74: ; preds = %70
%75 = load i32, i32* @stderr
%76 = load i8*, i8** %56
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %76)
%78 = call i32 @exit(i32 1)
unreachable
79: ; preds = %70
%80 = call i32 @fstat(i32 %72, %struct.stat* %8)
%81 = getelementptr inbounds %struct.stat, %struct.stat* %8, i64 0, i32 0
%82 = load i32, i32* %81
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %82)
br label %84
84: ; preds = %61, %79
%85 = phi i32 [ %64, %61 ], [ %72, %79 ]
%86 = phi i32 [ %62, %61 ], [ %82, %79 ]
%87 = load i32, i32* @AF_INET
%88 = load i32, i32* @SOCK_DGRAM
%89 = call i32 @socket(i32 %87, i32 %88, i32 0)
%90 = call i32 @bzero(%struct.sockaddr_in* %7, i32 12)
%91 = load i32, i32* @AF_INET
%92 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 2
store i32 %91, i32* %92
%93 = getelementptr inbounds i8*, i8** %1, i64 2
%94 = load i8*, i8** %93
%95 = call i32 @inet_addr(i8* %94)
%96 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 1, i32 0
store i32 %95, i32* %96
%97 = getelementptr inbounds i8*, i8** %1, i64 3
%98 = load i8*, i8** %97
%99 = call i32 @atoi(i8* %98)
%100 = call i32 @htons(i32 %99)
%101 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 0
store i32 %100, i32* %101
%102 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%103 = call i64 @connect(i32 %89, %struct.sockaddr* %102, i32 12)
%104 = icmp slt i64 %103, 0
br i1 %104, label %105, label %108
105: ; preds = %84
%106 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%107 = call i32 @exit(i32 -1)
unreachable
108: ; preds = %84
%109 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%110 = icmp sgt i32 %86, 0
br i1 %110, label %111, label %165
111: ; preds = %108
%112 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
%113 = getelementptr inbounds <2 x double>, <2 x double>* %3, i64 0, i64 0
%114 = load double, double* %113
%115 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
%116 = getelementptr inbounds <2 x double>, <2 x double>* %3, i64 0, i64 1
%117 = load double, double* %116
br label %118
118: ; preds = %111, %162
%119 = phi i32 [ %54, %111 ], [ %124, %162 ]
%120 = phi i32 [ 1, %111 ], [ %163, %162 ]
%121 = phi i32 [ 0, %111 ], [ %148, %162 ]
%122 = sub nsw i32 %86, %121
%123 = icmp slt i32 %122, %119
%124 = select i1 %123, i32 %122, i32 %119
%125 = icmp sgt i32 %124, 0
br i1 %125, label %126, label %147
126: ; preds = %118, %142
%127 = phi i32 [ %144, %142 ], [ 0, %118 ]
%128 = phi i32 [ %145, %142 ], [ %121, %118 ]
%129 = sub nsw i32 %124, %127
%130 = icmp slt i32 %129, %39
%131 = select i1 %130, i32 %129, i32 %39
%132 = call i32 @sendfile(i32 %89, i32 %85, i32* %9, i32 %131)
%133 = icmp slt i32 %132, 1
br i1 %133, label %134, label %142
134: ; preds = %126, %134
%135 = phi i32 [ %140, %134 ], [ %132, %126 ]
%136 = load i32, i32* @stderr
%137 = load i32, i32* @errno
%138 = call i32 (i32, i8*, ...) @fprintf(i32 %136, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i32 %135, i32 %137)
%139 = call i32 @usleep(i32 100)
%140 = call i32 @sendfile(i32 %89, i32 %85, i32* %9, i32 %131)
%141 = icmp slt i32 %140, 1
br i1 %141, label %134, label %142
142: ; preds = %134, %126
%143 = phi i32 [ %132, %126 ], [ %140, %134 ]
%144 = add nsw i32 %143, %127
%145 = add nsw i32 %143, %128
%146 = icmp sgt i32 %124, %144
br i1 %146, label %126, label %147
147: ; preds = %142, %118
%148 = phi i32 [ %121, %118 ], [ %145, %142 ]
%149 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%150 = load double, double* %112
%151 = fsub double %150, %114
%152 = load double, double* %115
%153 = fsub double %152, %117
%154 = call double @llvm.fmuladd.f64(double %151, double 1.000000e+06, double %153)
%155 = mul nsw i32 %120, %55
%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 %120, 1
%164 = icmp sgt i32 %86, %148
br i1 %164, label %118, label %165
165: ; preds = %162, %108
%166 = phi i32 [ 0, %108 ], [ %148, %162 ]
%167 = call i32 @sendto(i32 %89, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 4, i32 0, %struct.sockaddr* %102, i32 12)
%168 = icmp slt i32 %167, 1
br i1 %168, label %169, label %176
169: ; preds = %165
%170 = load i32, i32* @stderr
%171 = load i32, i32* @errno
%172 = call i32 (i32, i8*, ...) @fprintf(i32 %170, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i32 %171)
%173 = call i32 @close(i32 %89)
%174 = call i32 @close(i32 %85)
%175 = call i32 @exit(i32 1)
unreachable
176: ; preds = %165
%177 = bitcast <2 x double>* %5 to %struct.timeval*
%178 = call i32 @gettimeofday(%struct.timeval* %177, i32* null)
%179 = load <2 x double>, <2 x double>* %5
%180 = load <2 x double>, <2 x double>* %3
%181 = fsub <2 x double> %179, %180
%182 = extractelement <2 x double> %181, i64 1
%183 = fdiv double %182, 1.000000e+06
%184 = extractelement <2 x double> %181, i64 0
%185 = fadd double %184, %183
%186 = shl nsw i32 %166, 3
%187 = sitofp i32 %186 to double
%188 = fdiv double %187, %185
%189 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.9, i64 0, i64 0), i32 %166, double %185, double %188)
%190 = call i32 @close(i32 %89)
%191 = call i32 @close(i32 %85)
ret i32 0
}