#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 */

/* Type definitions */
typedef int /*<<< orphan*/ time_t;

/* Variables and functions */
int /*<<< orphan*/ BLKGETSIZE64;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ die(char *, ...);
double difftime(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int ioctl(int, int /*<<< orphan*/, long long *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
unsigned int rand();
int read(int, char *, int);
int /*<<< orphan*/ srand(unsigned int);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ sync();
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int write(int, char *, int);
int main(int argc, char **argv) {
  time_t t, start, end;
  int fd, i;
  long long length;
  char buffer[1024 * 1024 * 5];
  unsigned int seed = (unsigned)time(&t);
  char *device;
  int die_at_error = 1;
  if (argc == 3 && !strcmp(argv[1], "--print-range")) {
    die_at_error = 0;
    device = argv[2];
  } else if (argc == 2) {
    device = argv[1];
  } else {
    die("Usage: ./%s [--print-range] device", argv[0]);
  }
  fd = open(device, O_WRONLY);
  if (fd < 0)
    die("Failed to open device!");
  if (ioctl(fd, BLKGETSIZE64, &length) == -1)
    die("Failed to get device size");
  printf("Device size: %lld\n", length);
  srand(seed);
  long long written = 0;
  time(&start);
  long long percent = length / 100;
  while (written < length) {
    if (written > percent) {
      printf(".");
      fflush(stdout);
      percent = percent + length / 100;
    }
    for (i = 0; i < 1024 * 1024 * 5; i += 4) {
      *((unsigned int *)&buffer[i]) = rand();
    }
    int l = write(fd, buffer, 1024 * 1024 * 5);
    written += l;
    if (l < 0)
      die("\nFailed to write to device");
    if (l != 1024 * 1024 * 5 && written != length)
      die("\nFailed to write full int");
  }
  printf("\nManaged to write all data!\n");
  close(fd);
  sync();
  time(&end);
  double seconds = difftime(end, start);
  printf("Wrote %lld bytes in %d seconds (%.2f MB/s)\n", written, (int)seconds,
         ((double)written / (1024.0 * 1024.0)) / (seconds));
  fd = open(device, O_RDONLY);
  if (fd < 0)
    die("Failed to open device");
  srand(seed);
  time(&start);
  long long readbytes = 0;
  long long failstart = -1;
  long long failend = -1;
  percent = length / 100;
  while (readbytes < length) {
    if (readbytes > percent) {
      printf(failstart == -1 ? "." : ",");
      fflush(stdout);
      percent = percent + length / 100;
    }
    int l = read(fd, buffer, 1024 * 1024 * 5);
    readbytes += l;
    if (l < 0)
      die("\nFailed to read from device");
    if (l != 1024 * 1024 * 5 && readbytes != length)
      die("\nFailed to read full int");
    for (i = 0; i < 1024 * 1024 * 5; i += 4) {
      if (*((unsigned int *)&buffer[i]) != rand()) {
        if (failstart == -1)
          failstart = readbytes - l + i;
        if (die_at_error)
          die("\nFailed to validate byte %lld", readbytes - l + i);
      } else if (failstart != -1) {
        failend = readbytes - l + i;
        printf("\nFail at range: %lld-%lld\n", failstart, failend);
        failstart = -1;
      }
    }
  }
  printf("\nManaged to read all data correctly\n");
  close(fd);
  time(&end);
  seconds = difftime(end, start);
  printf("Read %lld bytes in %d seconds (%.2f MB/s)\n", readbytes, (int)seconds,
         ((double)readbytes / (1024.0 * 1024.0)) / (seconds));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x5000a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   10b0 <time@plt>
mov    %eax,-0x500034(%rbp)
movl   $0x1,-0x500044(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1257 <main+0x77>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xddd(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    1257 <main+0x77>
movl   $0x0,-0x500044(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x500040(%rbp)
jmp    128f <main+0xaf>
cmpl   $0x2,-0x8(%rbp)
jne    1275 <main+0x95>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x500040(%rbp)
jmp    128a <main+0xaa>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   10f0 <die@plt>
jmp    128f <main+0xaf>
mov    -0x500040(%rbp),%rdi
mov    0x2d23(%rip),%rax
mov    (%rax),%esi
call   10e0 <open@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    12bf <main+0xdf>
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   10f0 <die@plt>
mov    -0x20(%rbp),%edi
mov    0x2d17(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    12eb <main+0x10b>
lea    0xd6c(%rip),%rdi
mov    $0x0,%al
call   10f0 <die@plt>
mov    -0x30(%rbp),%rsi
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x500034(%rbp),%edi
call   1090 <srand@plt>
movq   $0x0,-0x500050(%rbp)
lea    -0x18(%rbp),%rdi
call   10b0 <time@plt>
mov    -0x30(%rbp),%rax
mov    $0x64,%ecx
cqto
idiv   %rcx
mov    %rax,-0x500058(%rbp)
mov    -0x500050(%rbp),%rax
cmp    -0x30(%rbp),%rax
jge    1456 <main+0x276>
mov    -0x500050(%rbp),%rax
cmp    -0x500058(%rbp),%rax
jle    13a2 <main+0x1c2>
lea    0xd20(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2c65(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
mov    -0x500058(%rbp),%rax
mov    %rax,-0x500090(%rbp)
mov    -0x30(%rbp),%rax
mov    $0x64,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x500090(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x500058(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x500000,-0x24(%rbp)
jge    13d8 <main+0x1f8>
mov    $0x0,%al
call   1100 <rand@plt>
mov    %eax,%ecx
movslq -0x24(%rbp),%rax
mov    %ecx,-0x500030(%rbp,%rax,1)
mov    -0x24(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x24(%rbp)
jmp    13a9 <main+0x1c9>
mov    -0x20(%rbp),%edi
lea    -0x500030(%rbp),%rsi
mov    $0x500000,%edx
call   1030 <write@plt>
mov    %eax,-0x50005c(%rbp)
movslq -0x50005c(%rbp),%rax
add    -0x500050(%rbp),%rax
mov    %rax,-0x500050(%rbp)
cmpl   $0x0,-0x50005c(%rbp)
jge    1422 <main+0x242>
lea    0xc64(%rip),%rdi
mov    $0x0,%al
call   10f0 <die@plt>
cmpl   $0x500000,-0x50005c(%rbp)
je     1451 <main+0x271>
mov    -0x500050(%rbp),%rax
cmp    -0x30(%rbp),%rax
je     1451 <main+0x271>
lea    0xc50(%rip),%rdi
mov    $0x0,%al
call   10f0 <die@plt>
jmp    1331 <main+0x151>
lea    0xc57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%edi
call   1070 <close@plt>
mov    $0x0,%al
call   10c0 <sync@plt>
lea    -0x1c(%rbp),%rdi
call   10b0 <time@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1050 <difftime@plt>
movsd  %xmm0,-0x500068(%rbp)
ff
mov    -0x500050(%rbp),%rsi
cvttsd2si -0x500068(%rbp),%edx
ff
cvtsi2sdq -0x500050(%rbp),%xmm0
af ff
movsd  0xb51(%rip),%xmm1
divsd  %xmm1,%xmm0
divsd  -0x500068(%rbp),%xmm0
ff
lea    0xc0f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x500040(%rbp),%rdi
mov    0x2b11(%rip),%rax
mov    (%rax),%esi
call   10e0 <open@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    14f9 <main+0x319>
lea    0xc0b(%rip),%rdi
mov    $0x0,%al
call   10f0 <die@plt>
mov    -0x500034(%rbp),%edi
call   1090 <srand@plt>
lea    -0x18(%rbp),%rdi
call   10b0 <time@plt>
movq   $0x0,-0x500070(%rbp)
movq   $0xffffffffffffffff,-0x500078(%rbp)
ff ff ff ff
movq   $0xffffffffffffffff,-0x500080(%rbp)
ff ff ff ff
mov    -0x30(%rbp),%rax
mov    $0x64,%ecx
cqto
idiv   %rcx
mov    %rax,-0x500058(%rbp)
mov    -0x500070(%rbp),%rax
cmp    -0x30(%rbp),%rax
jge    1755 <main+0x575>
mov    -0x500070(%rbp),%rax
cmp    -0x500058(%rbp),%rax
jle    15ca <main+0x3ea>
mov    -0x500078(%rbp),%rcx
lea    0xb9d(%rip),%rdi
lea    0xb00(%rip),%rax
cmp    $0xffffffffffffffff,%rcx
cmove  %rax,%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2a3d(%rip),%rax
mov    (%rax),%edi
call   10d0 <fflush@plt>
mov    -0x500058(%rbp),%rax
mov    %rax,-0x500098(%rbp)
mov    -0x30(%rbp),%rax
mov    $0x64,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x500098(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x500058(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x500030(%rbp),%rsi
mov    $0x500000,%edx
call   1080 <read@plt>
mov    %eax,-0x500084(%rbp)
movslq -0x500084(%rbp),%rax
add    -0x500070(%rbp),%rax
mov    %rax,-0x500070(%rbp)
cmpl   $0x0,-0x500084(%rbp)
jge    1614 <main+0x434>
lea    0xb08(%rip),%rdi
mov    $0x0,%al
call   10f0 <die@plt>
cmpl   $0x500000,-0x500084(%rbp)
je     1643 <main+0x463>
mov    -0x500070(%rbp),%rax
cmp    -0x30(%rbp),%rax
je     1643 <main+0x463>
lea    0xaf5(%rip),%rdi
mov    $0x0,%al
call   10f0 <die@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x500000,-0x24(%rbp)
jge    1750 <main+0x570>
movslq -0x24(%rbp),%rax
mov    -0x500030(%rbp,%rax,1),%eax
mov    %eax,-0x50009c(%rbp)
mov    $0x0,%al
call   1100 <rand@plt>
mov    %eax,%ecx
mov    -0x50009c(%rbp),%eax
cmp    %ecx,%eax
je     16e4 <main+0x504>
cmpq   $0xffffffffffffffff,-0x500078(%rbp)
ff
jne    16ac <main+0x4cc>
mov    -0x500070(%rbp),%rax
movslq -0x500084(%rbp),%rcx
sub    %rcx,%rax
movslq -0x24(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x500078(%rbp)
cmpl   $0x0,-0x500044(%rbp)
je     16df <main+0x4ff>
mov    -0x500070(%rbp),%rsi
movslq -0x500084(%rbp),%rax
sub    %rax,%rsi
movslq -0x24(%rbp),%rax
add    %rax,%rsi
lea    0xa72(%rip),%rdi
mov    $0x0,%al
call   10f0 <die@plt>
jmp    173d <main+0x55d>
cmpq   $0xffffffffffffffff,-0x500078(%rbp)
ff
je     1738 <main+0x558>
mov    -0x500070(%rbp),%rax
movslq -0x500084(%rbp),%rcx
sub    %rcx,%rax
movslq -0x24(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x500080(%rbp)
mov    -0x500078(%rbp),%rsi
mov    -0x500080(%rbp),%rdx
lea    0xa42(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0xffffffffffffffff,-0x500078(%rbp)
ff ff ff ff
jmp    173d <main+0x55d>
jmp    1742 <main+0x562>
mov    -0x24(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x24(%rbp)
jmp    164a <main+0x46a>
jmp    1543 <main+0x363>
lea    0xa27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%edi
call   1070 <close@plt>
lea    -0x1c(%rbp),%rdi
call   10b0 <time@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1050 <difftime@plt>
movsd  %xmm0,-0x500068(%rbp)
ff
mov    -0x500070(%rbp),%rsi
cvttsd2si -0x500068(%rbp),%edx
ff
cvtsi2sdq -0x500070(%rbp),%xmm0
af ff
movsd  0x859(%rip),%xmm1
divsd  %xmm1,%xmm0
divsd  -0x500068(%rbp),%xmm0
ff
lea    0x9ee(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x5000a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x500038,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x2c(%rsp),%rdi
call   10d0 <time@plt>
mov    %eax,%r14d
cmp    $0x2,%ebp
je     125c <main+0x5c>
cmp    $0x3,%ebp
jne    1241 <main+0x41>
mov    0x8(%rbx),%rdi
lea    0xdd0(%rip),%rsi
call   10c0 <strcmp@plt>
test   %eax,%eax
je     126a <main+0x6a>
mov    (%rbx),%rsi
lea    0xdcb(%rip),%rdi
movl   $0x0,0xc(%rsp)
xor    %eax,%eax
call   1110 <die@plt>
jmp    1274 <main+0x74>
mov    0x8(%rbx),%rbp
movl   $0x0,0xc(%rsp)
jmp    1274 <main+0x74>
mov    0x10(%rbx),%rbp
mov    $0x1,%al
mov    %eax,0xc(%rsp)
mov    0x2d45(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   1100 <open@plt>
mov    %eax,%r12d
test   %eax,%eax
jns    129a <main+0x9a>
lea    0xda6(%rip),%rdi
xor    %eax,%eax
call   1110 <die@plt>
mov    0x2d3f(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
mov    %r12d,%edi
call   1080 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    12c1 <main+0xc1>
lea    0xd96(%rip),%rdi
xor    %eax,%eax
call   1110 <die@plt>
mov    (%rsp),%rsi
lea    0xd9e(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14d,%edi
call   10b0 <srand@plt>
lea    0x14(%rsp),%rdi
call   10d0 <time@plt>
mov    (%rsp),%rax
movabs $0x28f5c28f5c28f5c3,%rcx
c2 f5 28
movabs $0xa3d70a3d70a3d70b,%r13
0a d7 a3
test   %rax,%rax
mov    %r14d,0x20(%rsp)
mov    %rbp,0x18(%rsp)
jle    13f6 <main+0x1f6>
shr    $0x2,%rax
mul    %rcx
mov    %rdx,%r15
shr    $0x2,%r15
xor    %ebx,%ebx
jmp    1339 <main+0x139>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    %rax,%rbx
jge    13f6 <main+0x1f6>
cmp    %r15,%rbx
jle    1374 <main+0x174>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    0x2c81(%rip),%rax
mov    (%rax),%edi
call   10f0 <fflush@plt>
mov    (%rsp),%rcx
mov    %rcx,%rax
imul   %r13
add    %rcx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x6,%rdx
add    %rax,%rdx
add    %rdx,%r15
mov    $0xfffffffffffffffc,%rbp
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1120 <rand@plt>
mov    %eax,0x34(%rsp,%rbp,1)
add    $0x4,%rbp
cmp    $0x4ffffc,%rbp
jb     1380 <main+0x180>
mov    %r12d,%edi
lea    0x30(%rsp),%rsi
mov    $0x500000,%edx
call   1050 <write@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    13bf <main+0x1bf>
lea    0xcc7(%rip),%rdi
xor    %eax,%eax
call   1110 <die@plt>
movslq %r14d,%rax
add    %rax,%rbx
mov    (%rsp),%rax
cmp    $0x500000,%r14d
je     1330 <main+0x130>
cmp    %rax,%rbx
je     1330 <main+0x130>
lea    0xcb4(%rip),%rdi
xor    %eax,%eax
call   1110 <die@plt>
mov    (%rsp),%rax
jmp    1330 <main+0x130>
lea    0xd94(%rip),%rdi
call   1040 <puts@plt>
mov    %r12d,%edi
call   1090 <close@plt>
xor    %eax,%eax
call   10e0 <sync@plt>
lea    0x10(%rsp),%rdi
call   10d0 <time@plt>
mov    0x10(%rsp),%edi
mov    0x14(%rsp),%esi
call   1070 <difftime@plt>
cvttsd2si %xmm0,%edx
cvtsi2sd %rbx,%xmm1
mulsd  0xbc7(%rip),%xmm1
divsd  %xmm0,%xmm1
lea    0xc70(%rip),%rdi
mov    %rbx,%rsi
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1060 <printf@plt>
mov    0x2b8f(%rip),%rax
mov    (%rax),%esi
mov    0x18(%rsp),%rdi
call   1100 <open@plt>
mov    %eax,0x18(%rsp)
test   %eax,%eax
jns    147b <main+0x27b>
lea    0xc6c(%rip),%rdi
xor    %eax,%eax
call   1110 <die@plt>
mov    0x20(%rsp),%edi
call   10b0 <srand@plt>
lea    0x14(%rsp),%rdi
call   10d0 <time@plt>
mov    (%rsp),%rax
test   %rax,%rax
jle    15f8 <main+0x3f8>
shr    $0x2,%rax
movabs $0x28f5c28f5c28f5c3,%rcx
c2 f5 28
mul    %rcx
mov    %rdx,%rbx
shr    $0x2,%rbx
mov    $0xffffffffffffffff,%r13
xor    %r14d,%r14d
jmp    14d2 <main+0x2d2>
nop
mov    %r15,%r14
cmp    (%rsp),%r15
mov    0x20(%rsp),%rbx
jge    15fb <main+0x3fb>
cmp    %rbx,%r14
jle    152a <main+0x32a>
cmp    $0xffffffffffffffff,%r13
lea    0xc14(%rip),%rdi
lea    0xb94(%rip),%rax
cmove  %rax,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2ad5(%rip),%rax
mov    (%rax),%edi
call   10f0 <fflush@plt>
mov    (%rsp),%rcx
mov    %rcx,%rax
movabs $0xa3d70a3d70a3d70b,%rdx
0a d7 a3
imul   %rdx
add    %rcx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x6,%rdx
add    %rax,%rdx
add    %rdx,%rbx
mov    %rbx,0x20(%rsp)
mov    0x18(%rsp),%edi
lea    0x30(%rsp),%rsi
mov    $0x500000,%edx
call   10a0 <read@plt>
mov    %eax,%r12d
test   %eax,%eax
jns    1557 <main+0x357>
lea    0xba8(%rip),%rdi
xor    %eax,%eax
call   1110 <die@plt>
movslq %r12d,%r15
add    %r14,%r15
cmp    $0x500000,%r12d
je     157a <main+0x37a>
cmp    (%rsp),%r15
je     157a <main+0x37a>
lea    0xba1(%rip),%rdi
xor    %eax,%eax
call   1110 <die@plt>
xor    %ebx,%ebx
mov    0xc(%rsp),%r12d
jmp    15b1 <main+0x3b1>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    $0xffffffffffffffff,%r13
jne    15e1 <main+0x3e1>
mov    $0xffffffffffffffff,%r13
lea    0x4(%rbx),%rax
cmp    $0x4ffffc,%rbx
mov    %rax,%rbx
jae    14c0 <main+0x2c0>
mov    0x30(%rsp,%rbx,1),%ebp
xor    %eax,%eax
call   1120 <rand@plt>
cmp    %eax,%ebp
je     1590 <main+0x390>
lea    (%r14,%rbx,1),%rsi
cmp    $0xffffffffffffffff,%r13
cmove  %rsi,%r13
test   %r12b,%r12b
jne    159d <main+0x39d>
lea    0xb55(%rip),%rdi
xor    %eax,%eax
call   1110 <die@plt>
jmp    159d <main+0x39d>
lea    (%r14,%rbx,1),%rdx
lea    0xb5f(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1596 <main+0x396>
xor    %r15d,%r15d
lea    0xbab(%rip),%rdi
call   1040 <puts@plt>
mov    0x18(%rsp),%edi
call   1090 <close@plt>
lea    0x10(%rsp),%rdi
call   10d0 <time@plt>
mov    0x10(%rsp),%edi
mov    0x14(%rsp),%esi
call   1070 <difftime@plt>
cvttsd2si %xmm0,%edx
xorps  %xmm1,%xmm1
cvtsi2sd %r15,%xmm1
mulsd  0x9c5(%rip),%xmm1
divsd  %xmm0,%xmm1
lea    0xb20(%rip),%rdi
mov    %r15,%rsi
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x500038,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"--print-range\00"
@.str.1 = [35 x i8] c"Usage: ./%s [--print-range] device\00"
@O_WRONLY = global i32 0
@.str.2 = [23 x i8] c"Failed to open device!\00"
@BLKGETSIZE64 = global i32 0
@.str.3 = [26 x i8] c"Failed to get device size\00"
@.str.4 = [19 x i8] c"Device size: %lld\0A\00"
@.str.5 = [2 x i8] c".\00"
@stdout = global i32 0
@.str.6 = [27 x i8] c"\0AFailed to write to device\00"
@.str.7 = [26 x i8] c"\0AFailed to write full int\00"
@.str.8 = [29 x i8] c"\0AManaged to write all data!\0A\00"
@.str.9 = [44 x i8] c"Wrote %lld bytes in %d seconds (%.2f MB/s)\0A\00"
@O_RDONLY = global i32 0
@.str.10 = [22 x i8] c"Failed to open device\00"
@.str.11 = [2 x i8] c",\00"
@.str.12 = [28 x i8] c"\0AFailed to read from device\00"
@.str.13 = [25 x i8] c"\0AFailed to read full int\00"
@.str.14 = [30 x i8] c"\0AFailed to validate byte %lld\00"
@.str.15 = [27 x i8] c"\0AFail at range: %lld-%lld\0A\00"
@.str.16 = [37 x i8] c"\0AManaged to read all data correctly\0A\00"
@.str.17 = [43 x i8] c"Read %lld bytes in %d seconds (%.2f MB/s)\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 i64
%12 = alloca [5242880 x i8]
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i64
%17 = alloca i64
%18 = alloca i32
%19 = alloca double
%20 = alloca i64
%21 = alloca i64
%22 = alloca i64
%23 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%24 = call i32 @time(i32* %6)
store i32 %24, i32* %13
store i32 1, i32* %15
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 3
br i1 %26, label %27, label %37
27: ; preds = %2
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @strcmp(i8* %30, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%32 = icmp ne i32 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %27
store i32 0, i32* %15
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
store i8* %36, i8** %14
br label %50
37: ; preds = %27, %2
%38 = load i32, i32* %4
%39 = icmp eq i32 %38, 2
br i1 %39, label %40, label %44
40: ; preds = %37
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
store i8* %43, i8** %14
br label %49
44: ; preds = %37
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 0
%47 = load i8*, i8** %46
%48 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %47)
br label %49
49: ; preds = %44, %40
br label %50
50: ; preds = %49, %33
%51 = load i8*, i8** %14
%52 = load i32, i32* @O_WRONLY
%53 = call i32 @open(i8* %51, i32 %52)
store i32 %53, i32* %9
%54 = load i32, i32* %9
%55 = icmp slt i32 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %50
%57 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %58
58: ; preds = %56, %50
%59 = load i32, i32* %9
%60 = load i32, i32* @BLKGETSIZE64
%61 = call i32 @ioctl(i32 %59, i32 %60, i64* %11)
%62 = icmp eq i32 %61, -1
br i1 %62, label %63, label %65
63: ; preds = %58
%64 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %65
65: ; preds = %63, %58
%66 = load i64, i64* %11
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i64 %66)
%68 = load i32, i32* %13
%69 = call i32 @srand(i32 %68)
store i64 0, i64* %16
%70 = call i32 @time(i32* %7)
%71 = load i64, i64* %11
%72 = sdiv i64 %71, 100
store i64 %72, i64* %17
br label %73
73: ; preds = %123, %65
%74 = load i64, i64* %16
%75 = load i64, i64* %11
%76 = icmp slt i64 %74, %75
br i1 %76, label %77, label %124
77: ; preds = %73
%78 = load i64, i64* %16
%79 = load i64, i64* %17
%80 = icmp sgt i64 %78, %79
br i1 %80, label %81, label %89
81: ; preds = %77
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%83 = load i32, i32* @stdout
%84 = call i32 @fflush(i32 %83)
%85 = load i64, i64* %17
%86 = load i64, i64* %11
%87 = sdiv i64 %86, 100
%88 = add nsw i64 %85, %87
store i64 %88, i64* %17
br label %89
89: ; preds = %81, %77
store i32 0, i32* %10
br label %90
90: ; preds = %99, %89
%91 = load i32, i32* %10
%92 = icmp slt i32 %91, 5242880
br i1 %92, label %93, label %102
93: ; preds = %90
%94 = call i32 (...) @rand()
%95 = load i32, i32* %10
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [5242880 x i8], [5242880 x i8]* %12, i64 0, i64 %96
%98 = bitcast i8* %97 to i32*
store i32 %94, i32* %98
br label %99
99: ; preds = %93
%100 = load i32, i32* %10
%101 = add nsw i32 %100, 4
store i32 %101, i32* %10
br label %90
102: ; preds = %90
%103 = load i32, i32* %9
%104 = getelementptr inbounds [5242880 x i8], [5242880 x i8]* %12, i64 0, i64 0
%105 = call i32 @write(i32 %103, i8* %104, i32 5242880)
store i32 %105, i32* %18
%106 = load i32, i32* %18
%107 = sext i32 %106 to i64
%108 = load i64, i64* %16
%109 = add nsw i64 %108, %107
store i64 %109, i64* %16
%110 = load i32, i32* %18
%111 = icmp slt i32 %110, 0
br i1 %111, label %112, label %114
112: ; preds = %102
%113 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
br label %114
114: ; preds = %112, %102
%115 = load i32, i32* %18
%116 = icmp ne i32 %115, 5242880
br i1 %116, label %117, label %123
117: ; preds = %114
%118 = load i64, i64* %16
%119 = load i64, i64* %11
%120 = icmp ne i64 %118, %119
br i1 %120, label %121, label %123
121: ; preds = %117
%122 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
br label %123
123: ; preds = %121, %117, %114
br label %73
124: ; preds = %73
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
%126 = load i32, i32* %9
%127 = call i32 @close(i32 %126)
%128 = call i32 (...) @sync()
%129 = call i32 @time(i32* %8)
%130 = load i32, i32* %8
%131 = load i32, i32* %7
%132 = call double @difftime(i32 %130, i32 %131)
store double %132, double* %19
%133 = load i64, i64* %16
%134 = load double, double* %19
%135 = fptosi double %134 to i32
%136 = load i64, i64* %16
%137 = sitofp i64 %136 to double
%138 = fdiv double %137, 0x4130000000000000
%139 = load double, double* %19
%140 = fdiv double %138, %139
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.9, i64 0, i64 0), i64 %133, i32 %135, double %140)
%142 = load i8*, i8** %14
%143 = load i32, i32* @O_RDONLY
%144 = call i32 @open(i8* %142, i32 %143)
store i32 %144, i32* %9
%145 = load i32, i32* %9
%146 = icmp slt i32 %145, 0
br i1 %146, label %147, label %149
147: ; preds = %124
%148 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0))
br label %149
149: ; preds = %147, %124
%150 = load i32, i32* %13
%151 = call i32 @srand(i32 %150)
%152 = call i32 @time(i32* %7)
store i64 0, i64* %20
store i64 -1, i64* %21
store i64 -1, i64* %22
%153 = load i64, i64* %11
%154 = sdiv i64 %153, 100
store i64 %154, i64* %17
br label %155
155: ; preds = %251, %149
%156 = load i64, i64* %20
%157 = load i64, i64* %11
%158 = icmp slt i64 %156, %157
br i1 %158, label %159, label %252
159: ; preds = %155
%160 = load i64, i64* %20
%161 = load i64, i64* %17
%162 = icmp sgt i64 %160, %161
br i1 %162, label %163, label %175
163: ; preds = %159
%164 = load i64, i64* %21
%165 = icmp eq i64 %164, -1
%166 = zext i1 %165 to i64
%167 = select i1 %165, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0)
%168 = call i32 (i8*, ...) @printf(i8* %167)
%169 = load i32, i32* @stdout
%170 = call i32 @fflush(i32 %169)
%171 = load i64, i64* %17
%172 = load i64, i64* %11
%173 = sdiv i64 %172, 100
%174 = add nsw i64 %171, %173
store i64 %174, i64* %17
br label %175
175: ; preds = %163, %159
%176 = load i32, i32* %9
%177 = getelementptr inbounds [5242880 x i8], [5242880 x i8]* %12, i64 0, i64 0
%178 = call i32 @read(i32 %176, i8* %177, i32 5242880)
store i32 %178, i32* %23
%179 = load i32, i32* %23
%180 = sext i32 %179 to i64
%181 = load i64, i64* %20
%182 = add nsw i64 %181, %180
store i64 %182, i64* %20
%183 = load i32, i32* %23
%184 = icmp slt i32 %183, 0
br i1 %184, label %185, label %187
185: ; preds = %175
%186 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.12, i64 0, i64 0))
br label %187
187: ; preds = %185, %175
%188 = load i32, i32* %23
%189 = icmp ne i32 %188, 5242880
br i1 %189, label %190, label %196
190: ; preds = %187
%191 = load i64, i64* %20
%192 = load i64, i64* %11
%193 = icmp ne i64 %191, %192
br i1 %193, label %194, label %196
194: ; preds = %190
%195 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0))
br label %196
196: ; preds = %194, %190, %187
store i32 0, i32* %10
br label %197
197: ; preds = %248, %196
%198 = load i32, i32* %10
%199 = icmp slt i32 %198, 5242880
br i1 %199, label %200, label %251
200: ; preds = %197
%201 = load i32, i32* %10
%202 = sext i32 %201 to i64
%203 = getelementptr inbounds [5242880 x i8], [5242880 x i8]* %12, i64 0, i64 %202
%204 = bitcast i8* %203 to i32*
%205 = load i32, i32* %204
%206 = call i32 (...) @rand()
%207 = icmp ne i32 %205, %206
br i1 %207, label %208, label %232
208: ; preds = %200
%209 = load i64, i64* %21
%210 = icmp eq i64 %209, -1
br i1 %210, label %211, label %219
211: ; preds = %208
%212 = load i64, i64* %20
%213 = load i32, i32* %23
%214 = sext i32 %213 to i64
%215 = sub nsw i64 %212, %214
%216 = load i32, i32* %10
%217 = sext i32 %216 to i64
%218 = add nsw i64 %215, %217
store i64 %218, i64* %21
br label %219
219: ; preds = %211, %208
%220 = load i32, i32* %15
%221 = icmp ne i32 %220, 0
br i1 %221, label %222, label %231
222: ; preds = %219
%223 = load i64, i64* %20
%224 = load i32, i32* %23
%225 = sext i32 %224 to i64
%226 = sub nsw i64 %223, %225
%227 = load i32, i32* %10
%228 = sext i32 %227 to i64
%229 = add nsw i64 %226, %228
%230 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.14, i64 0, i64 0), i64 %229)
br label %231
231: ; preds = %222, %219
br label %247
232: ; preds = %200
%233 = load i64, i64* %21
%234 = icmp ne i64 %233, -1
br i1 %234, label %235, label %246
235: ; preds = %232
%236 = load i64, i64* %20
%237 = load i32, i32* %23
%238 = sext i32 %237 to i64
%239 = sub nsw i64 %236, %238
%240 = load i32, i32* %10
%241 = sext i32 %240 to i64
%242 = add nsw i64 %239, %241
store i64 %242, i64* %22
%243 = load i64, i64* %21
%244 = load i64, i64* %22
%245 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.15, i64 0, i64 0), i64 %243, i64 %244)
store i64 -1, i64* %21
br label %246
246: ; preds = %235, %232
br label %247
247: ; preds = %246, %231
br label %248
248: ; preds = %247
%249 = load i32, i32* %10
%250 = add nsw i32 %249, 4
store i32 %250, i32* %10
br label %197
251: ; preds = %197
br label %155
252: ; preds = %155
%253 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.16, i64 0, i64 0))
%254 = load i32, i32* %9
%255 = call i32 @close(i32 %254)
%256 = call i32 @time(i32* %8)
%257 = load i32, i32* %8
%258 = load i32, i32* %7
%259 = call double @difftime(i32 %257, i32 %258)
store double %259, double* %19
%260 = load i64, i64* %20
%261 = load double, double* %19
%262 = fptosi double %261 to i32
%263 = load i64, i64* %20
%264 = sitofp i64 %263 to double
%265 = fdiv double %264, 0x4130000000000000
%266 = load double, double* %19
%267 = fdiv double %265, %266
%268 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.17, i64 0, i64 0), i64 %260, i32 %262, double %267)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"--print-range\00"
@.str.1 = [35 x i8] c"Usage: ./%s [--print-range] device\00"
@O_WRONLY = global i32 0
@.str.2 = [23 x i8] c"Failed to open device!\00"
@BLKGETSIZE64 = global i32 0
@.str.3 = [26 x i8] c"Failed to get device size\00"
@.str.4 = [19 x i8] c"Device size: %lld\0A\00"
@.str.5 = [2 x i8] c".\00"
@stdout = global i32 0
@.str.6 = [27 x i8] c"\0AFailed to write to device\00"
@.str.7 = [26 x i8] c"\0AFailed to write full int\00"
@.str.9 = [44 x i8] c"Wrote %lld bytes in %d seconds (%.2f MB/s)\0A\00"
@O_RDONLY = global i32 0
@.str.10 = [22 x i8] c"Failed to open device\00"
@.str.11 = [2 x i8] c",\00"
@.str.12 = [28 x i8] c"\0AFailed to read from device\00"
@.str.13 = [25 x i8] c"\0AFailed to read full int\00"
@.str.14 = [30 x i8] c"\0AFailed to validate byte %lld\00"
@.str.15 = [27 x i8] c"\0AFail at range: %lld-%lld\0A\00"
@.str.17 = [43 x i8] c"Read %lld bytes in %d seconds (%.2f MB/s)\0A\00"
@str = [28 x i8] c"\0AManaged to write all data!\00"
@str.18 = [36 x i8] c"\0AManaged to read all data correctly\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
%7 = alloca [5242880 x i8]
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = bitcast i64* %6 to i8*
%12 = getelementptr inbounds [5242880 x i8], [5242880 x i8]* %7, i64 0, i64 0
%13 = call i32 @time(i32* %3)
switch i32 %0, label %25 [
i32 3, label %14
i32 2, label %22
]
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strcmp(i8* dereferenceable(1) %16, i8* dereferenceable(14) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %14
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
br label %28
22: ; preds = %2
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
br label %28
25: ; preds = %14, %2
%26 = load i8*, i8** %1
%27 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %22, %25, %19
%29 = phi i8* [ %24, %22 ], [ undef, %25 ], [ %21, %19 ]
%30 = phi i1 [ false, %22 ], [ false, %25 ], [ true, %19 ]
%31 = load i32, i32* @O_WRONLY
%32 = call i32 @open(i8* %29, i32 %31)
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %34, %28
%37 = load i32, i32* @BLKGETSIZE64
%38 = call i32 @ioctl(i32 %32, i32 %37, i64* %6)
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %42
42: ; preds = %40, %36
%43 = load i64, i64* %6
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i64 %43)
%45 = call i32 @srand(i32 %13)
%46 = call i32 @time(i32* %4)
%47 = load i64, i64* %6
%48 = icmp sgt i64 %47, 0
br i1 %48, label %49, label %89
49: ; preds = %42
%50 = udiv i64 %47, 100
br label %51
51: ; preds = %49, %86
%52 = phi i64 [ %63, %86 ], [ %50, %49 ]
%53 = phi i64 [ %74, %86 ], [ 0, %49 ]
%54 = icmp sgt i64 %53, %52
br i1 %54, label %55, label %62
55: ; preds = %51
%56 = call i32 @putchar(i32 46)
%57 = load i32, i32* @stdout
%58 = call i32 @fflush(i32 %57)
%59 = load i64, i64* %6
%60 = sdiv i64 %59, 100
%61 = add nsw i64 %60, %52
br label %62
62: ; preds = %55, %51
%63 = phi i64 [ %61, %55 ], [ %52, %51 ]
br label %64
64: ; preds = %62, %64
%65 = phi i64 [ 0, %62 ], [ %69, %64 ]
%66 = call i32 (...) @rand()
%67 = getelementptr inbounds [5242880 x i8], [5242880 x i8]* %7, i64 0, i64 %65
%68 = bitcast i8* %67 to i32*
store i32 %66, i32* %68
%69 = add nuw nsw i64 %65, 4
%70 = icmp ult i64 %65, 5242876
br i1 %70, label %64, label %71
71: ; preds = %64
%72 = call i32 @write(i32 %32, i8* %12, i32 5242880)
%73 = sext i32 %72 to i64
%74 = add nsw i64 %53, %73
%75 = icmp slt i32 %72, 0
br i1 %75, label %76, label %78
76: ; preds = %71
%77 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
br label %78
78: ; preds = %76, %71
%79 = icmp eq i32 %72, 5242880
%80 = load i64, i64* %6
%81 = icmp eq i64 %74, %80
%82 = select i1 %79, i1 true, i1 %81
br i1 %82, label %86, label %83
83: ; preds = %78
%84 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%85 = load i64, i64* %6
br label %86
86: ; preds = %83, %78
%87 = phi i64 [ %85, %83 ], [ %80, %78 ]
%88 = icmp slt i64 %74, %87
br i1 %88, label %51, label %89
89: ; preds = %86, %42
%90 = phi i64 [ 0, %42 ], [ %74, %86 ]
%91 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%92 = call i32 @close(i32 %32)
%93 = call i32 (...) @sync()
%94 = call i32 @time(i32* %5)
%95 = load i32, i32* %5
%96 = load i32, i32* %4
%97 = call double @difftime(i32 %95, i32 %96)
%98 = fptosi double %97 to i32
%99 = sitofp i64 %90 to double
%100 = fmul double %99, 0x3EB0000000000000
%101 = fdiv double %100, %97
%102 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.9, i64 0, i64 0), i64 %90, i32 %98, double %101)
%103 = load i32, i32* @O_RDONLY
%104 = call i32 @open(i8* %29, i32 %103)
%105 = icmp slt i32 %104, 0
br i1 %105, label %106, label %108
106: ; preds = %89
%107 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0))
br label %108
108: ; preds = %106, %89
%109 = call i32 @srand(i32 %13)
%110 = call i32 @time(i32* %4)
%111 = load i64, i64* %6
%112 = icmp sgt i64 %111, 0
br i1 %112, label %113, label %170
113: ; preds = %108
%114 = udiv i64 %111, 100
br label %118
115: ; preds = %166
%116 = load i64, i64* %6
%117 = icmp slt i64 %136, %116
br i1 %117, label %118, label %170
118: ; preds = %113, %115
%119 = phi i64 [ %167, %115 ], [ -1, %113 ]
%120 = phi i64 [ %136, %115 ], [ 0, %113 ]
%121 = phi i64 [ %133, %115 ], [ %114, %113 ]
%122 = icmp sgt i64 %120, %121
br i1 %122, label %123, label %132
123: ; preds = %118
%124 = icmp eq i64 %119, -1
%125 = select i1 %124, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0)
%126 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %125)
%127 = load i32, i32* @stdout
%128 = call i32 @fflush(i32 %127)
%129 = load i64, i64* %6
%130 = sdiv i64 %129, 100
%131 = add nsw i64 %130, %121
br label %132
132: ; preds = %123, %118
%133 = phi i64 [ %131, %123 ], [ %121, %118 ]
%134 = call i32 @read(i32 %104, i8* %12, i32 5242880)
%135 = sext i32 %134 to i64
%136 = add nsw i64 %120, %135
%137 = icmp slt i32 %134, 0
br i1 %137, label %138, label %140
138: ; preds = %132
%139 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.12, i64 0, i64 0))
br label %140
140: ; preds = %138, %132
%141 = icmp eq i32 %134, 5242880
%142 = load i64, i64* %6
%143 = icmp eq i64 %136, %142
%144 = select i1 %141, i1 true, i1 %143
br i1 %144, label %147, label %145
145: ; preds = %140
%146 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0))
br label %147
147: ; preds = %145, %140
br label %148
148: ; preds = %147, %166
%149 = phi i64 [ %168, %166 ], [ 0, %147 ]
%150 = phi i64 [ %167, %166 ], [ %119, %147 ]
%151 = getelementptr inbounds [5242880 x i8], [5242880 x i8]* %7, i64 0, i64 %149
%152 = bitcast i8* %151 to i32*
%153 = load i32, i32* %152
%154 = call i32 (...) @rand()
%155 = icmp eq i32 %153, %154
%156 = icmp eq i64 %150, -1
br i1 %155, label %162, label %157
157: ; preds = %148
%158 = add nsw i64 %120, %149
%159 = select i1 %156, i64 %158, i64 %150
br i1 %30, label %166, label %160
160: ; preds = %157
%161 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.14, i64 0, i64 0), i64 %158)
br label %166
162: ; preds = %148
br i1 %156, label %166, label %163
163: ; preds = %162
%164 = add nsw i64 %120, %149
%165 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.15, i64 0, i64 0), i64 %150, i64 %164)
br label %166
166: ; preds = %160, %157, %163, %162
%167 = phi i64 [ %159, %160 ], [ %159, %157 ], [ -1, %163 ], [ -1, %162 ]
%168 = add nuw nsw i64 %149, 4
%169 = icmp ult i64 %149, 5242876
br i1 %169, label %148, label %115
170: ; preds = %115, %108
%171 = phi i64 [ 0, %108 ], [ %136, %115 ]
%172 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.18, i64 0, i64 0))
%173 = call i32 @close(i32 %104)
%174 = call i32 @time(i32* %5)
%175 = load i32, i32* %5
%176 = load i32, i32* %4
%177 = call double @difftime(i32 %175, i32 %176)
%178 = fptosi double %177 to i32
%179 = sitofp i64 %171 to double
%180 = fmul double %179, 0x3EB0000000000000
%181 = fdiv double %180, %177
%182 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.17, i64 0, i64 0), i64 %171, i32 %178, double %181)
ret i32 0
}