#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*/ values;
typedef int /*<<< orphan*/ value;
typedef int uint32_t;
struct timeval {
  int tv_sec;
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ SEEK_SET;
int atoi(char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, ...);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ lseek(int, int, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ read(int, int *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ write(int, int *, int);
int main(int argc, char **argv) {
  int fd, count, count0, usec;
  struct timeval tv1, tv2;
  if (argc != 2) {
    fprintf(stderr, "%s: use \"%s <count>\"\n", argv[0], argv[0]);
    exit(1);
  }
  count0 = count = atoi(argv[1]);
  if (!count) {
    fprintf(stderr, "%s: not a number \"%s\"\n", argv[0], argv[1]);
    exit(1);
  }
  fd = open("/dev/rawrabbit", O_RDWR);
  if (fd < 0) {
    fprintf(stderr, "%s: %s: %s\n", argv[0], "/dev/rawrabbit", strerror(errno));
    exit(1);
  }
  lseek(fd, ((4) << 28) | 0xa08, SEEK_SET);
  gettimeofday(&tv1, NULL);
  while (count--) {
    static uint32_t values[] = {0x0000, 0xf000};
    write(fd, values + (count & 1), sizeof(values[0]));
    lseek(fd, -sizeof(values[0]), SEEK_CUR);
  }
  gettimeofday(&tv2, NULL);
  usec = (tv2.tv_sec - tv1.tv_sec) * 1000 * 1000 + tv2.tv_usec - tv1.tv_usec;
  printf("%i writes in %i usecs\n", count0, usec);
  printf("%i writes per second\n", (int)(count0 * 1000LL * 1000LL / usec));
  count = count0;
  lseek(fd, ((4) << 28) | 0xa08, SEEK_SET);
  gettimeofday(&tv1, NULL);
  while (count--) {
    static uint32_t value;
    read(fd, &value, sizeof(value));
    lseek(fd, -sizeof(value), SEEK_CUR);
  }
  gettimeofday(&tv2, NULL);
  usec = (tv2.tv_sec - tv1.tv_sec) * 1000 * 1000 + tv2.tv_usec - tv1.tv_usec;
  printf("%i reads in %i usecs\n", count0, usec);
  printf("%i reads per second\n", (int)(count0 * 1000LL * 1000LL / usec));
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11ef <main+0x4f>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
lea    0xe22(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    123c <main+0x9c>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xdeb(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    0x2da5(%rip),%rax
mov    (%rax),%esi
lea    0xde1(%rip),%rdi
call   1090 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    12ac <main+0x10c>
mov    0x2d6b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    0x2d4c(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%rdx
mov    %rax,%r8
lea    0xda8(%rip),%rsi
lea    0xd92(%rip),%rcx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    0x2d0a(%rip),%rax
mov    (%rax),%edx
mov    $0x40000a08,%esi
call   1050 <lseek@plt>
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x18(%rbp)
cmp    $0x0,%eax
je     1321 <main+0x181>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%eax
and    $0x1,%eax
cltq
lea    0x2d7b(%rip),%rsi
shl    $0x2,%rax
add    %rax,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    -0x14(%rbp),%edi
mov    0x2cd0(%rip),%rax
mov    (%rax),%edx
mov    $0xfffffffc,%esi
call   1050 <lseek@plt>
jmp    12cf <main+0x12f>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
mov    -0x30(%rbp),%eax
sub    -0x28(%rbp),%eax
imul   $0x3e8,%eax,%eax
imul   $0x3e8,%eax,%eax
add    -0x2c(%rbp),%eax
sub    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xcf2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x1c(%rbp),%rax
imul   $0x3e8,%rax,%rax
imul   $0x3e8,%rax,%rax
movslq -0x20(%rbp),%rcx
cqto
idiv   %rcx
mov    %eax,%esi
lea    0xcde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2c28(%rip),%rax
mov    (%rax),%edx
mov    $0x40000a08,%esi
call   1050 <lseek@plt>
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x18(%rbp)
cmp    $0x0,%eax
je     13f4 <main+0x254>
mov    -0x14(%rbp),%edi
lea    0x2cc1(%rip),%rsi
mov    $0x4,%edx
call   1070 <read@plt>
mov    -0x14(%rbp),%edi
mov    0x2bfd(%rip),%rax
mov    (%rax),%edx
mov    $0xfffffffc,%esi
call   1050 <lseek@plt>
jmp    13b1 <main+0x211>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
mov    -0x30(%rbp),%eax
sub    -0x28(%rbp),%eax
imul   $0x3e8,%eax,%eax
imul   $0x3e8,%eax,%eax
add    -0x2c(%rbp),%eax
sub    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xc4c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x1c(%rbp),%rax
imul   $0x3e8,%rax,%rax
imul   $0x3e8,%rax,%rax
movslq -0x20(%rbp),%rcx
cqto
idiv   %rcx
mov    %eax,%esi
lea    0xc37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    11de <main+0x3e>
mov    0x8(%rbx),%rbp
mov    %rbp,%rdi
call   10a0 <atoi@plt>
test   %eax,%eax
jne    1205 <main+0x65>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe3d(%rip),%rsi
mov    %rbp,%rcx
jmp    11f4 <main+0x54>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rcx
lea    0xe0f(%rip),%rsi
mov    %rcx,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    %eax,%r15d
mov    0x2dd9(%rip),%rax
mov    (%rax),%esi
lea    0xe15(%rip),%rdi
call   1090 <open@plt>
test   %eax,%eax
jns    1262 <main+0xc2>
mov    0x2da8(%rip),%rax
mov    (%rax),%ebp
mov    (%rbx),%rbx
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xdfa(%rip),%rsi
lea    0xde4(%rip),%rcx
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%r8
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    %eax,%ebp
mov    0x2d55(%rip),%r13
mov    0x0(%r13),%edx
mov    %eax,%edi
mov    $0x40000a08,%esi
call   1050 <lseek@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
lea    -0x1(%r15),%ebx
lea    0x2dde(%rip),%r14
mov    0x2d47(%rip),%r12
nopl   0x0(%rax)
mov    %ebx,%eax
and    $0x1,%eax
lea    (%r14,%rax,4),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
call   1030 <write@plt>
mov    (%r12),%edx
mov    %ebp,%edi
mov    $0xfffffffc,%esi
call   1050 <lseek@plt>
add    $0xffffffff,%ebx
jb     12a0 <main+0x100>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    0x8(%rsp),%eax
sub    0x10(%rsp),%eax
imul   $0xf4240,%eax,%ebx
add    0xc(%rsp),%ebx
sub    0x14(%rsp),%ebx
lea    0xd55(%rip),%rdi
mov    %r15d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
movslq %r15d,%rax
imul   $0xf4240,%rax,%r14
movslq %ebx,%rcx
mov    %r14,%rax
or     %rcx,%rax
shr    $0x20,%rax
jne    1321 <main+0x181>
mov    %r14d,%eax
xor    %edx,%edx
div    %ebx
jmp    1329 <main+0x189>
mov    %r14,%rax
cqto
idiv   %rcx
lea    0xd2f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%r13),%edx
mov    %ebp,%edi
mov    $0x40000a08,%esi
call   1050 <lseek@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
lea    0x2d34(%rip),%r13
mov    %r15d,%ebx
nop
mov    %ebp,%edi
mov    %r13,%rsi
mov    $0x4,%edx
call   1070 <read@plt>
mov    (%r12),%edx
mov    %ebp,%edi
mov    $0xfffffffc,%esi
call   1050 <lseek@plt>
add    $0xffffffff,%ebx
jne    1360 <main+0x1c0>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    0x8(%rsp),%eax
sub    0x10(%rsp),%eax
imul   $0xf4240,%eax,%ebx
add    0xc(%rsp),%ebx
sub    0x14(%rsp),%ebx
lea    0xcc8(%rip),%rdi
mov    %r15d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
movslq %ebx,%rcx
mov    %r14,%rax
or     %rcx,%rax
shr    $0x20,%rax
jne    13d1 <main+0x231>
mov    %r14d,%eax
xor    %edx,%edx
div    %ebx
jmp    13d9 <main+0x239>
mov    %r14,%rax
cqto
idiv   %rcx
lea    0xcab(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@stderr = global i32 0
@.str = [22 x i8] c"%s: use \22%s <count>\22\0A\00"
@.str.1 = [23 x i8] c"%s: not a number \22%s\22\0A\00"
@.str.2 = [15 x i8] c"/dev/rawrabbit\00"
@O_RDWR = global i32 0
@.str.3 = [12 x i8] c"%s: %s: %s\0A\00"
@errno = global i32 0
@SEEK_SET = global i32 0
@main.values = internal global [2 x i32] [i32 0, i32 61440]
@SEEK_CUR = global i32 0
@.str.4 = [23 x i8] c"%i writes in %i usecs\0A\00"
@.str.5 = [22 x i8] c"%i writes per second\0A\00"
@main.value = internal global i32 0
@.str.6 = [22 x i8] c"%i reads in %i usecs\0A\00"
@.str.7 = [21 x i8] c"%i reads per second\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 %struct.timeval
%11 = alloca %struct.timeval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %24
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %18, i8* %21)
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %7
store i32 %28, i32* %8
%29 = load i32, i32* %7
%30 = icmp ne i32 %29, 0
br i1 %30, label %41, label %31
31: ; preds = %24
%32 = load i32, i32* @stderr
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 0
%35 = load i8*, i8** %34
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %35, i8* %38)
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %24
%42 = load i32, i32* @O_RDWR
%43 = call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %42)
store i32 %43, i32* %6
%44 = load i32, i32* %6
%45 = icmp slt i32 %44, 0
br i1 %45, label %46, label %55
46: ; preds = %41
%47 = load i32, i32* @stderr
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 0
%50 = load i8*, i8** %49
%51 = load i32, i32* @errno
%52 = call i8* @strerror(i32 %51)
%53 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %50, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %52)
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %41
%56 = load i32, i32* %6
%57 = load i32, i32* @SEEK_SET
%58 = call i32 @lseek(i32 %56, i32 1073744392, i32 %57)
%59 = call i32 @gettimeofday(%struct.timeval* %10, i32* null)
br label %60
60: ; preds = %64, %55
%61 = load i32, i32* %7
%62 = add nsw i32 %61, -1
store i32 %62, i32* %7
%63 = icmp ne i32 %61, 0
br i1 %63, label %64, label %74
64: ; preds = %60
%65 = load i32, i32* %6
%66 = load i32, i32* %7
%67 = and i32 %66, 1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.values, i64 0, i64 0), i64 %68
%70 = call i32 @write(i32 %65, i32* %69, i32 4)
%71 = load i32, i32* %6
%72 = load i32, i32* @SEEK_CUR
%73 = call i32 @lseek(i32 %71, i32 -4, i32 %72)
br label %60
74: ; preds = %60
%75 = call i32 @gettimeofday(%struct.timeval* %11, i32* null)
%76 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 0
%77 = load i32, i32* %76
%78 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 0
%79 = load i32, i32* %78
%80 = sub nsw i32 %77, %79
%81 = mul nsw i32 %80, 1000
%82 = mul nsw i32 %81, 1000
%83 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 1
%84 = load i32, i32* %83
%85 = add nsw i32 %82, %84
%86 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 1
%87 = load i32, i32* %86
%88 = sub nsw i32 %85, %87
store i32 %88, i32* %9
%89 = load i32, i32* %8
%90 = load i32, i32* %9
%91 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %89, i32 %90)
%92 = load i32, i32* %8
%93 = sext i32 %92 to i64
%94 = mul nsw i64 %93, 1000
%95 = mul nsw i64 %94, 1000
%96 = load i32, i32* %9
%97 = sext i32 %96 to i64
%98 = sdiv i64 %95, %97
%99 = trunc i64 %98 to i32
%100 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %99)
%101 = load i32, i32* %8
store i32 %101, i32* %7
%102 = load i32, i32* %6
%103 = load i32, i32* @SEEK_SET
%104 = call i32 @lseek(i32 %102, i32 1073744392, i32 %103)
%105 = call i32 @gettimeofday(%struct.timeval* %10, i32* null)
br label %106
106: ; preds = %110, %74
%107 = load i32, i32* %7
%108 = add nsw i32 %107, -1
store i32 %108, i32* %7
%109 = icmp ne i32 %107, 0
br i1 %109, label %110, label %116
110: ; preds = %106
%111 = load i32, i32* %6
%112 = call i32 @read(i32 %111, i32* @main.value, i32 4)
%113 = load i32, i32* %6
%114 = load i32, i32* @SEEK_CUR
%115 = call i32 @lseek(i32 %113, i32 -4, i32 %114)
br label %106
116: ; preds = %106
%117 = call i32 @gettimeofday(%struct.timeval* %11, i32* null)
%118 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 0
%119 = load i32, i32* %118
%120 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 0
%121 = load i32, i32* %120
%122 = sub nsw i32 %119, %121
%123 = mul nsw i32 %122, 1000
%124 = mul nsw i32 %123, 1000
%125 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 1
%126 = load i32, i32* %125
%127 = add nsw i32 %124, %126
%128 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 1
%129 = load i32, i32* %128
%130 = sub nsw i32 %127, %129
store i32 %130, i32* %9
%131 = load i32, i32* %8
%132 = load i32, i32* %9
%133 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %131, i32 %132)
%134 = load i32, i32* %8
%135 = sext i32 %134 to i64
%136 = mul nsw i64 %135, 1000
%137 = mul nsw i64 %136, 1000
%138 = load i32, i32* %9
%139 = sext i32 %138 to i64
%140 = sdiv i64 %137, %139
%141 = trunc i64 %140 to i32
%142 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %141)
%143 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@stderr = global i32 0
@.str = [22 x i8] c"%s: use \22%s <count>\22\0A\00"
@.str.1 = [23 x i8] c"%s: not a number \22%s\22\0A\00"
@.str.2 = [15 x i8] c"/dev/rawrabbit\00"
@O_RDWR = global i32 0
@.str.3 = [12 x i8] c"%s: %s: %s\0A\00"
@errno = global i32 0
@SEEK_SET = global i32 0
@main.values = internal global [2 x i32] [i32 0, i32 61440]
@SEEK_CUR = global i32 0
@.str.4 = [23 x i8] c"%i writes in %i usecs\0A\00"
@.str.5 = [22 x i8] c"%i writes per second\0A\00"
@main.value = internal global i32 0
@.str.6 = [22 x i8] c"%i reads in %i usecs\0A\00"
@.str.7 = [21 x i8] c"%i reads per second\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = bitcast %struct.timeval* %3 to i8*
%6 = bitcast %struct.timeval* %4 to i8*
%7 = icmp eq i32 %0, 2
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %10)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %13
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %1
%21 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %20, i8* %15)
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %13
%24 = load i32, i32* @O_RDWR
%25 = tail call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %34
27: ; preds = %23
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %1
%30 = load i32, i32* @errno
%31 = tail call i8* @strerror(i32 %30)
%32 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %29, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %31)
%33 = tail call i32 @exit(i32 1)
unreachable
34: ; preds = %23
%35 = load i32, i32* @SEEK_SET
%36 = tail call i32 @lseek(i32 %25, i32 1073744392, i32 %35)
%37 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
br label %38
38: ; preds = %34, %38
%39 = phi i32 [ %40, %38 ], [ %16, %34 ]
%40 = add nsw i32 %39, -1
%41 = and i32 %40, 1
%42 = zext i32 %41 to i64
%43 = getelementptr inbounds [2 x i32], [2 x i32]* @main.values, i64 0, i64 %42
%44 = tail call i32 @write(i32 %25, i32* %43, i32 4)
%45 = load i32, i32* @SEEK_CUR
%46 = tail call i32 @lseek(i32 %25, i32 -4, i32 %45)
%47 = icmp eq i32 %40, 0
br i1 %47, label %48, label %38
48: ; preds = %38
%49 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%50 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%51 = load i32, i32* %50
%52 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%53 = load i32, i32* %52
%54 = sub nsw i32 %51, %53
%55 = mul i32 %54, 1000000
%56 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%57 = load i32, i32* %56
%58 = add nsw i32 %55, %57
%59 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%60 = load i32, i32* %59
%61 = sub i32 %58, %60
%62 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %16, i32 %61)
%63 = sext i32 %16 to i64
%64 = mul nsw i64 %63, 1000000
%65 = sext i32 %61 to i64
%66 = sdiv i64 %64, %65
%67 = trunc i64 %66 to i32
%68 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %67)
%69 = load i32, i32* @SEEK_SET
%70 = tail call i32 @lseek(i32 %25, i32 1073744392, i32 %69)
%71 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
br label %72
72: ; preds = %48, %72
%73 = phi i32 [ %74, %72 ], [ %16, %48 ]
%74 = add nsw i32 %73, -1
%75 = tail call i32 @read(i32 %25, i32* @main.value, i32 4)
%76 = load i32, i32* @SEEK_CUR
%77 = tail call i32 @lseek(i32 %25, i32 -4, i32 %76)
%78 = icmp eq i32 %74, 0
br i1 %78, label %79, label %72
79: ; preds = %72
%80 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%81 = load i32, i32* %50
%82 = load i32, i32* %52
%83 = sub nsw i32 %81, %82
%84 = mul i32 %83, 1000000
%85 = load i32, i32* %56
%86 = add nsw i32 %84, %85
%87 = load i32, i32* %59
%88 = sub i32 %86, %87
%89 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %16, i32 %88)
%90 = sext i32 %88 to i64
%91 = sdiv i64 %64, %90
%92 = trunc i64 %91 to i32
%93 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %92)
%94 = tail call i32 @exit(i32 0)
unreachable
}