#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 */
struct timeval {
  int tv_sec;
};
typedef int /*<<< orphan*/ seed;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int O_RDONLY;
int O_RDWR;
int O_SYNC;
int /*<<< orphan*/ SEEK_SET;
int atol(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
scalar_t__ lseek64(int, unsigned long long, int /*<<< orphan*/);
int open(char *, int);
int optind;
int /*<<< orphan*/ printf(char *, int);
unsigned long long rand();
int read(int, ...);
int /*<<< orphan*/ srand(unsigned int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ timersub(struct timeval *, struct timeval *,
                            struct timeval *);
int /*<<< orphan*/ usage();
int write(int, char *, int);
int main(int argc, char *argv[]) {
  unsigned long long max_blocks;
  int fd, fd2, write_mode = 0, iops = 0;
  struct timeval start, end, res;
  unsigned int seed;
  char buf[4096] = {0};
  int c;
  int o_sync = 0;
  while ((c = getopt(argc, argv, "+rwo")) != -1) {
    switch (c) {
    case '?':
    default:
      usage();
      break;
    case 'r':
      break;
    case 'w':
      write_mode = 1;
      break;
    case 'o':
      o_sync = O_SYNC;
      break;
    }
  }
  if (o_sync && !write_mode) {
    o_sync = 0;
  }
  if ((argc - optind) != 2) {
    usage();
  }
  max_blocks = atol(argv[optind]) * ((1024 * 1024) / 4096);
  if ((fd = open(argv[optind + 1], O_RDWR | o_sync)) < 0) {
    fprintf(stderr, "Cannot open block device %s\n", argv[optind + 1]);
    exit(1);
  }
  fd2 = open("/dev/urandom", O_RDONLY);
  if (fd2 < 0) {
    fprintf(stderr, "Cannot open /dev/urandom\n");
  }
  if (read(fd2, &seed, sizeof(seed)) != sizeof(seed)) {
    fprintf(stderr, "Cannot read /dev/urandom\n");
  }
  close(fd2);
  srand(seed);
  res.tv_sec = 0;
  gettimeofday(&start, 0);
  while (res.tv_sec < 10) {
    if (lseek64(fd, (rand() % max_blocks) * 4096, SEEK_SET) < 0) {
      fprintf(stderr, "lseek64 failed\n");
    }
    if (write_mode) {
      if (write(fd, buf, sizeof(buf)) != sizeof(buf)) {
        fprintf(stderr, "Short write\n");
      }
    } else {
      if (read(fd, buf, sizeof(buf)) != sizeof(buf)) {
        fprintf(stderr, "Short read\n");
      }
    }
    iops++;
    gettimeofday(&end, 0);
    timersub(&end, &start, &res);
  }
  close(fd);
  gettimeofday(&end, 0);
  timersub(&end, &start, &res);
  printf("%d iops/sec\n", iops / (int)res.tv_sec);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1060,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
lea    -0x1050(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1060 <memset@plt>
movl   $0x0,-0x1058(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdae(%rip),%rdx
call   10e0 <getopt@plt>
mov    %eax,-0x1054(%rbp)
cmp    $0xffffffff,%eax
je     12f2 <main+0xf2>
mov    -0x1054(%rbp),%eax
mov    %eax,-0x105c(%rbp)
sub    $0x3f,%eax
je     12bc <main+0xbc>
jmp    1280 <main+0x80>
mov    -0x105c(%rbp),%eax
sub    $0x6f,%eax
je     12de <main+0xde>
jmp    1294 <main+0x94>
mov    -0x105c(%rbp),%eax
sub    $0x72,%eax
je     12cd <main+0xcd>
jmp    12a8 <main+0xa8>
mov    -0x105c(%rbp),%eax
sub    $0x77,%eax
je     12d2 <main+0xd2>
jmp    12c1 <main+0xc1>
jmp    12c1 <main+0xc1>
mov    $0x0,%al
call   10b0 <usage@plt>
jmp    12ed <main+0xed>
jmp    12ed <main+0xed>
movl   $0x1,-0x24(%rbp)
jmp    12ed <main+0xed>
mov    0x2cfb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1058(%rbp)
jmp    1244 <main+0x44>
cmpl   $0x0,-0x1058(%rbp)
je     1313 <main+0x113>
cmpl   $0x0,-0x24(%rbp)
jne    1313 <main+0x113>
movl   $0x0,-0x1058(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2cb3(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x2,%eax
je     132f <main+0x12f>
mov    $0x0,%al
call   10b0 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x2c96(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
call   10c0 <atol@plt>
shl    $0x8,%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2c76(%rip),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2c7b(%rip),%rax
mov    (%rax),%esi
or     -0x1058(%rbp),%esi
call   10d0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    13be <main+0x1be>
mov    0x2c33(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x2c36(%rip),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xc58(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x2c13(%rip),%rax
mov    (%rax),%esi
lea    0xc54(%rip),%rdi
call   10d0 <open@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    13f7 <main+0x1f7>
mov    0x2bd9(%rip),%rax
mov    (%rax),%edi
lea    0xc3f(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x20(%rbp),%edi
lea    -0x44(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1080 <read@plt>
cltq
cmp    $0x4,%rax
je     142d <main+0x22d>
mov    0x2ba3(%rip),%rax
mov    (%rax),%edi
lea    0xc23(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x20(%rbp),%edi
call   1070 <close@plt>
mov    -0x44(%rbp),%edi
call   1090 <srand@plt>
movl   $0x0,-0x40(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
cmpl   $0xa,-0x40(%rbp)
jge    155f <main+0x35f>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x1060(%rbp)
mov    $0x0,%al
call   1120 <rand@plt>
mov    -0x1060(%rbp),%edi
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
mov    %rdx,%rsi
shl    $0xc,%rsi
mov    0x2b33(%rip),%rax
mov    (%rax),%edx
call   1100 <lseek64@plt>
cmp    $0x0,%rax
jge    14ad <main+0x2ad>
mov    0x2b23(%rip),%rax
mov    (%rax),%edi
lea    0xbbd(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
cmpl   $0x0,-0x24(%rbp)
je     14f5 <main+0x2f5>
mov    -0x1c(%rbp),%edi
lea    -0x1050(%rbp),%rsi
mov    $0x1000,%edx
call   1030 <write@plt>
cltq
cmp    $0x1000,%rax
je     14f0 <main+0x2f0>
mov    0x2ae0(%rip),%rax
mov    (%rax),%edi
lea    0xb8a(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    1535 <main+0x335>
mov    -0x1c(%rbp),%edi
lea    -0x1050(%rbp),%rsi
mov    $0x1000,%edx
mov    $0x0,%al
call   1080 <read@plt>
cltq
cmp    $0x1000,%rax
je     1530 <main+0x330>
mov    0x2aa0(%rip),%rax
mov    (%rax),%edi
lea    0xb57(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    1535 <main+0x335>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
lea    -0x38(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1110 <timersub@plt>
jmp    144f <main+0x24f>
mov    -0x1c(%rbp),%edi
call   1070 <close@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
lea    -0x38(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1110 <timersub@plt>
mov    -0x28(%rbp),%eax
cltd
idivl  -0x40(%rbp)
mov    %eax,%esi
lea    0xaf9(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   10f0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1028,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x20(%rsp),%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   1060 <memset@plt>
lea    0xdd2(%rip),%r14
mov    0x2dab(%rip),%r12
movl   $0x0,0xc(%rsp)
xor    %r15d,%r15d
jmp    125c <main+0x5c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x77,%eax
je     128c <main+0x8c>
xor    %eax,%eax
call   10b0 <usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10e0 <getopt@plt>
cmp    $0x71,%eax
jle    1280 <main+0x80>
cmp    $0x72,%eax
je     125c <main+0x5c>
jmp    1250 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0x6f,%eax
je     1294 <main+0x94>
cmp    $0xffffffff,%eax
jne    1255 <main+0x55>
jmp    129a <main+0x9a>
mov    $0x1,%al
mov    %eax,0xc(%rsp)
jmp    125c <main+0x5c>
mov    (%r12),%r15d
jmp    125c <main+0x5c>
xor    %r14d,%r14d
testb  $0x1,0xc(%rsp)
cmovne %r15d,%r14d
test   %r15d,%r15d
cmove  %r15d,%r14d
mov    0x2d1c(%rip),%r15
mov    (%r15),%eax
sub    %eax,%ebp
cmp    $0x2,%ebp
je     12c8 <main+0xc8>
xor    %eax,%eax
call   10b0 <usage@plt>
mov    (%r15),%eax
movslq %eax,%rbp
mov    (%rbx,%rbp,8),%rdi
call   10c0 <atol@plt>
mov    %eax,0x8(%rsp)
mov    0x8(%rbx,%rbp,8),%rdi
mov    0x2d04(%rip),%rax
or     (%rax),%r14d
mov    %r14d,%esi
call   10d0 <open@plt>
test   %eax,%eax
jns    131c <main+0x11c>
mov    0x2cc6(%rip),%rax
mov    (%rax),%edi
movslq (%r15),%rax
mov    0x8(%rbx,%rax,8),%rdx
lea    0xcfa(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    %eax,%ebp
mov    0x2cb3(%rip),%rax
mov    (%rax),%esi
lea    0xcf4(%rip),%rdi
call   10d0 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1350 <main+0x150>
mov    0x2c80(%rip),%rax
mov    (%rax),%edi
lea    0xce6(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
shll   $0x8,0x8(%rsp)
lea    0x1c(%rsp),%rsi
mov    $0x4,%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1080 <read@plt>
cmp    $0x4,%eax
je     1384 <main+0x184>
mov    0x2c4c(%rip),%rax
mov    (%rax),%edi
lea    0xccc(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
movslq 0x8(%rsp),%r15
mov    %ebx,%edi
call   1070 <close@plt>
mov    0x1c(%rsp),%edi
call   1090 <srand@plt>
movl   $0x0,(%rsp)
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
lea    0x20(%rsp),%r13
lea    0x18(%rsp),%r12
mov    %rsp,%r14
xor    %ebx,%ebx
jmp    13e7 <main+0x1e7>
nopl   (%rax)
add    $0x1,%ebx
mov    %r12,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    %r12,%rdi
lea    0x10(%rsp),%rsi
mov    %r14,%rdx
call   1110 <timersub@plt>
cmpl   $0xa,(%rsp)
jge    14b6 <main+0x2b6>
xor    %eax,%eax
call   1120 <rand@plt>
mov    %rax,%rcx
or     %r15,%rcx
shr    $0x20,%rcx
je     1410 <main+0x210>
xor    %edx,%edx
div    %r15
mov    %rdx,%rsi
jmp    1418 <main+0x218>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %edx,%edx
divl   0x8(%rsp)
mov    %edx,%esi
shl    $0xc,%rsi
mov    0x2b95(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
call   1100 <lseek64@plt>
test   %rax,%rax
js     1460 <main+0x260>
testb  $0x1,0xc(%rsp)
je     147e <main+0x27e>
mov    %ebp,%edi
mov    %r13,%rsi
mov    $0x1000,%edx
call   1030 <write@plt>
lea    0xc25(%rip),%rsi
cmp    $0x1000,%eax
je     13c0 <main+0x1c0>
jmp    14a1 <main+0x2a1>
nopl   0x0(%rax,%rax,1)
mov    0x2b59(%rip),%rax
mov    (%rax),%edi
lea    0xbf3(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
testb  $0x1,0xc(%rsp)
jne    1438 <main+0x238>
mov    $0x1000,%edx
mov    %ebp,%edi
mov    %r13,%rsi
xor    %eax,%eax
call   1080 <read@plt>
lea    0xbea(%rip),%rsi
cmp    $0x1000,%eax
je     13c0 <main+0x1c0>
mov    0x2b18(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    13c0 <main+0x1c0>
mov    %ebp,%edi
call   1070 <close@plt>
lea    0x18(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
lea    0x10(%rsp),%rsi
mov    %rsp,%rdx
mov    %rbp,%rdi
call   1110 <timersub@plt>
mov    %ebx,%eax
cltd
idivl  (%rsp)
lea    0xba3(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %edi,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i32 }
@.str = [5 x i8] c"+rwo\00"
@O_SYNC = global i32 0
@optind = global i32 0
@O_RDWR = global i32 0
@stderr = global i32 0
@.str.1 = [29 x i8] c"Cannot open block device %s\0A\00"
@.str.2 = [13 x i8] c"/dev/urandom\00"
@O_RDONLY = global i32 0
@.str.3 = [26 x i8] c"Cannot open /dev/urandom\0A\00"
@.str.4 = [26 x i8] c"Cannot read /dev/urandom\0A\00"
@SEEK_SET = global i32 0
@.str.5 = [16 x i8] c"lseek64 failed\0A\00"
@.str.6 = [13 x i8] c"Short write\0A\00"
@.str.7 = [12 x i8] c"Short read\0A\00"
@.str.8 = [13 x i8] c"%d iops/sec\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.timeval
%12 = alloca %struct.timeval
%13 = alloca %struct.timeval
%14 = alloca i32
%15 = alloca [4096 x i8]
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
store i32 0, i32* %10
%18 = bitcast [4096 x i8]* %15 to i8*
store i32 0, i32* %17
br label %19
19: ; preds = %33, %2
%20 = load i32, i32* %4
%21 = load i8**, i8*** %5
%22 = call i32 @getopt(i32 %20, i8** %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %22, i32* %16
%23 = icmp ne i32 %22, -1
br i1 %23, label %24, label %34
24: ; preds = %19
%25 = load i32, i32* %16
switch i32 %25, label %27 [
i32 63, label %26
i32 114, label %29
i32 119, label %30
i32 111, label %31
]
26: ; preds = %24
br label %27
27: ; preds = %24, %26
%28 = call i32 (...) @usage()
br label %33
29: ; preds = %24
br label %33
30: ; preds = %24
store i32 1, i32* %9
br label %33
31: ; preds = %24
%32 = load i32, i32* @O_SYNC
store i32 %32, i32* %17
br label %33
33: ; preds = %31, %30, %29, %27
br label %19
34: ; preds = %19
%35 = load i32, i32* %17
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %34
%38 = load i32, i32* %9
%39 = icmp ne i32 %38, 0
br i1 %39, label %41, label %40
40: ; preds = %37
store i32 0, i32* %17
br label %41
41: ; preds = %40, %37, %34
%42 = load i32, i32* %4
%43 = load i32, i32* @optind
%44 = sub nsw i32 %42, %43
%45 = icmp ne i32 %44, 2
br i1 %45, label %46, label %48
46: ; preds = %41
%47 = call i32 (...) @usage()
br label %48
48: ; preds = %46, %41
%49 = load i8**, i8*** %5
%50 = load i32, i32* @optind
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %49, i64 %51
%53 = load i8*, i8** %52
%54 = call i32 @atol(i8* %53)
%55 = mul nsw i32 %54, 256
%56 = sext i32 %55 to i64
store i64 %56, i64* %6
%57 = load i8**, i8*** %5
%58 = load i32, i32* @optind
%59 = add nsw i32 %58, 1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8*, i8** %57, i64 %60
%62 = load i8*, i8** %61
%63 = load i32, i32* @O_RDWR
%64 = load i32, i32* %17
%65 = or i32 %63, %64
%66 = call i32 @open(i8* %62, i32 %65)
store i32 %66, i32* %7
%67 = icmp slt i32 %66, 0
br i1 %67, label %68, label %78
68: ; preds = %48
%69 = load i32, i32* @stderr
%70 = load i8**, i8*** %5
%71 = load i32, i32* @optind
%72 = add nsw i32 %71, 1
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8*, i8** %70, i64 %73
%75 = load i8*, i8** %74
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %75)
%77 = call i32 @exit(i32 1)
unreachable
78: ; preds = %48
%79 = load i32, i32* @O_RDONLY
%80 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %79)
store i32 %80, i32* %8
%81 = load i32, i32* %8
%82 = icmp slt i32 %81, 0
br i1 %82, label %83, label %86
83: ; preds = %78
%84 = load i32, i32* @stderr
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %86
86: ; preds = %83, %78
%87 = load i32, i32* %8
%88 = call i32 (i32, ...) @read(i32 %87, i32* %14, i64 4)
%89 = sext i32 %88 to i64
%90 = icmp ne i64 %89, 4
br i1 %90, label %91, label %94
91: ; preds = %86
%92 = load i32, i32* @stderr
%93 = call i32 (i32, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %94
94: ; preds = %91, %86
%95 = load i32, i32* %8
%96 = call i32 @close(i32 %95)
%97 = load i32, i32* %14
%98 = call i32 @srand(i32 %97)
%99 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
store i32 0, i32* %99
%100 = call i32 @gettimeofday(%struct.timeval* %11, i32 0)
br label %101
101: ; preds = %140, %94
%102 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
%103 = load i32, i32* %102
%104 = icmp slt i32 %103, 10
br i1 %104, label %105, label %145
105: ; preds = %101
%106 = load i32, i32* %7
%107 = call i64 (...) @rand()
%108 = load i64, i64* %6
%109 = urem i64 %107, %108
%110 = mul i64 %109, 4096
%111 = load i32, i32* @SEEK_SET
%112 = call i64 @lseek64(i32 %106, i64 %110, i32 %111)
%113 = icmp slt i64 %112, 0
br i1 %113, label %114, label %117
114: ; preds = %105
%115 = load i32, i32* @stderr
%116 = call i32 (i32, i8*, ...) @fprintf(i32 %115, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
br label %117
117: ; preds = %114, %105
%118 = load i32, i32* %9
%119 = icmp ne i32 %118, 0
br i1 %119, label %120, label %130
120: ; preds = %117
%121 = load i32, i32* %7
%122 = getelementptr inbounds [4096 x i8], [4096 x i8]* %15, i64 0, i64 0
%123 = call i32 @write(i32 %121, i8* %122, i32 4096)
%124 = sext i32 %123 to i64
%125 = icmp ne i64 %124, 4096
br i1 %125, label %126, label %129
126: ; preds = %120
%127 = load i32, i32* @stderr
%128 = call i32 (i32, i8*, ...) @fprintf(i32 %127, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
br label %129
129: ; preds = %126, %120
br label %140
130: ; preds = %117
%131 = load i32, i32* %7
%132 = getelementptr inbounds [4096 x i8], [4096 x i8]* %15, i64 0, i64 0
%133 = call i32 (i32, ...) @read(i32 %131, i8* %132, i64 4096)
%134 = sext i32 %133 to i64
%135 = icmp ne i64 %134, 4096
br i1 %135, label %136, label %139
136: ; preds = %130
%137 = load i32, i32* @stderr
%138 = call i32 (i32, i8*, ...) @fprintf(i32 %137, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
br label %139
139: ; preds = %136, %130
br label %140
140: ; preds = %139, %129
%141 = load i32, i32* %10
%142 = add nsw i32 %141, 1
store i32 %142, i32* %10
%143 = call i32 @gettimeofday(%struct.timeval* %12, i32 0)
%144 = call i32 @timersub(%struct.timeval* %12, %struct.timeval* %11, %struct.timeval* %13)
br label %101
145: ; preds = %101
%146 = load i32, i32* %7
%147 = call i32 @close(i32 %146)
%148 = call i32 @gettimeofday(%struct.timeval* %12, i32 0)
%149 = call i32 @timersub(%struct.timeval* %12, %struct.timeval* %11, %struct.timeval* %13)
%150 = load i32, i32* %10
%151 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
%152 = load i32, i32* %151
%153 = sdiv i32 %150, %152
%154 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %153)
%155 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@.str = [5 x i8] c"+rwo\00"
@O_SYNC = global i32 0
@optind = global i32 0
@O_RDWR = global i32 0
@stderr = global i32 0
@.str.1 = [29 x i8] c"Cannot open block device %s\0A\00"
@.str.2 = [13 x i8] c"/dev/urandom\00"
@O_RDONLY = global i32 0
@.str.3 = [26 x i8] c"Cannot open /dev/urandom\0A\00"
@.str.4 = [26 x i8] c"Cannot read /dev/urandom\0A\00"
@SEEK_SET = global i32 0
@.str.5 = [16 x i8] c"lseek64 failed\0A\00"
@.str.6 = [13 x i8] c"Short write\0A\00"
@.str.7 = [12 x i8] c"Short read\0A\00"
@.str.8 = [13 x i8] c"%d iops/sec\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = alloca %struct.timeval
%6 = alloca i32
%7 = alloca [4096 x i8]
%8 = bitcast %struct.timeval* %3 to i8*
%9 = bitcast %struct.timeval* %4 to i8*
%10 = bitcast %struct.timeval* %5 to i8*
%11 = bitcast i32* %6 to i8*
%12 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
br label %13
13: ; preds = %18, %2
%14 = phi i1 [ false, %2 ], [ true, %18 ]
%15 = phi i32 [ 0, %2 ], [ %17, %18 ]
br label %16
16: ; preds = %13, %23
%17 = phi i32 [ %15, %13 ], [ %24, %23 ]
br label %18
18: ; preds = %20, %16
%19 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %19, label %21 [
i32 -1, label %25
i32 111, label %23
i32 114, label %20
i32 119, label %13
]
20: ; preds = %18, %21
br label %18
21: ; preds = %18
%22 = tail call i32 (...) @usage()
br label %20
23: ; preds = %18
%24 = load i32, i32* @O_SYNC
br label %16
25: ; preds = %18
%26 = icmp eq i32 %17, 0
%27 = or i1 %26, %14
%28 = select i1 %27, i32 %17, i32 0
%29 = load i32, i32* @optind
%30 = sub nsw i32 %0, %29
%31 = icmp eq i32 %30, 2
br i1 %31, label %35, label %32
32: ; preds = %25
%33 = tail call i32 (...) @usage()
%34 = load i32, i32* @optind
br label %35
35: ; preds = %32, %25
%36 = phi i32 [ %34, %32 ], [ %29, %25 ]
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %1, i64 %37
%39 = load i8*, i8** %38
%40 = tail call i32 @atol(i8* %39)
%41 = shl nsw i32 %40, 8
%42 = sext i32 %41 to i64
%43 = add nsw i32 %36, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %1, i64 %44
%46 = load i8*, i8** %45
%47 = load i32, i32* @O_RDWR
%48 = or i32 %47, %28
%49 = tail call i32 @open(i8* %46, i32 %48)
%50 = icmp slt i32 %49, 0
br i1 %50, label %51, label %60
51: ; preds = %35
%52 = load i32, i32* @stderr
%53 = load i32, i32* @optind
%54 = add nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %1, i64 %55
%57 = load i8*, i8** %56
%58 = tail call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %57)
%59 = tail call i32 @exit(i32 1)
unreachable
60: ; preds = %35
%61 = load i32, i32* @O_RDONLY
%62 = tail call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %61)
%63 = icmp slt i32 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %60
%65 = load i32, i32* @stderr
%66 = tail call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %67
67: ; preds = %64, %60
%68 = call i32 (i32, ...) @read(i32 %62, i32* %6, i64 4)
%69 = icmp eq i32 %68, 4
br i1 %69, label %73, label %70
70: ; preds = %67
%71 = load i32, i32* @stderr
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %73
73: ; preds = %67, %70
%74 = call i32 @close(i32 %62)
%75 = load i32, i32* %6
%76 = call i32 @srand(i32 %75)
%77 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
store i32 0, i32* %77
%78 = call i32 @gettimeofday(%struct.timeval* %3, i32 0)
br label %79
79: ; preds = %73, %101
%80 = phi i32 [ %102, %101 ], [ 0, %73 ]
%81 = call i64 (...) @rand()
%82 = urem i64 %81, %42
%83 = shl i64 %82, 12
%84 = load i32, i32* @SEEK_SET
%85 = call i64 @lseek64(i32 %49, i64 %83, i32 %84)
%86 = icmp slt i64 %85, 0
br i1 %86, label %87, label %90
87: ; preds = %79
%88 = load i32, i32* @stderr
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
br label %90
90: ; preds = %87, %79
br i1 %14, label %91, label %94
91: ; preds = %90
%92 = call i32 @write(i32 %49, i8* %12, i32 4096)
%93 = icmp eq i32 %92, 4096
br i1 %93, label %101, label %97
94: ; preds = %90
%95 = call i32 (i32, ...) @read(i32 %49, i8* %12, i64 4096)
%96 = icmp eq i32 %95, 4096
br i1 %96, label %101, label %97
97: ; preds = %94, %91
%98 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), %91 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), %94 ]
%99 = load i32, i32* @stderr
%100 = call i32 (i32, i8*, ...) @fprintf(i32 %99, i8* %98)
br label %101
101: ; preds = %97, %94, %91
%102 = add nuw nsw i32 %80, 1
%103 = call i32 @gettimeofday(%struct.timeval* %4, i32 0)
%104 = call i32 @timersub(%struct.timeval* %4, %struct.timeval* %3, %struct.timeval* %5)
%105 = load i32, i32* %77
%106 = icmp slt i32 %105, 10
br i1 %106, label %79, label %107
107: ; preds = %101
%108 = call i32 @close(i32 %49)
%109 = call i32 @gettimeofday(%struct.timeval* %4, i32 0)
%110 = call i32 @timersub(%struct.timeval* %4, %struct.timeval* %3, %struct.timeval* %5)
%111 = load i32, i32* %77
%112 = sdiv i32 %102, %111
%113 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %112)
%114 = call i32 @exit(i32 0)
unreachable
}