#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 {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int O_CREAT;
int O_RDWR;
int S_IRUSR;
int S_IWUSR;
void *atoi(char *);
scalar_t__ atoll(char *);
int /*<<< orphan*/ clear_cache();
char *ea_checked_malloc(long long);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ lfs_close(int);
int lfs_open(char *, int, int);
int /*<<< orphan*/ lfs_read(int, char *, long long, long long);
int lfs_write(int, char *, size_t, long long);
int /*<<< orphan*/ memset(char *, int, size_t);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ rand();
int /*<<< orphan*/ srand(int);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  printf("---------------------\n");
  if (argc != 5) {
    printf("correct usage: %s <path to datafile> <random I/O size in Bytes> "
           "<file size in Bytes> <iterations>\n NOTE: I/O size should be "
           "multiple of 512 bytes (one sector)\n",
           argv[0]);
    return -1;
  }
  size_t block_size = atoi(argv[2]);
  long long file_size = (long long)atoll(argv[3]);
  int iterations = atoi(argv[4]);
  int myfd = lfs_open(argv[1], O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
  if (myfd == -1) {
    printf("could not open/create the datafile! check the path and "
           "permissions. \n");
    return -1;
  }
  unsigned long long start;
  unsigned long long finish;
  unsigned long long seconds;
  struct timeval tv;
  char *fill_file;
  long long myrand;
  clear_cache();
  int rett = 0;
  size_t seq_io = 800 * 1024 * 1024;
  fill_file = ea_checked_malloc(seq_io);
  memset(fill_file, 4, seq_io);
  for (long long iii = 0; iii < file_size; iii += seq_io) {
    lfs_write(myfd, fill_file, seq_io, iii);
    if (iii + seq_io > file_size) {
      seq_io = file_size - iii;
    }
  }
  clear_cache();
  lfs_close(myfd);
  myfd = lfs_open(argv[1], O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
  gettimeofday(&tv, NULL);
  start = (unsigned long long)(tv.tv_sec) * 1000 +
          (unsigned long long)(tv.tv_usec) / 1000;
  srand(666);
  char *test_write;
  free(fill_file);
  test_write = ea_checked_malloc(block_size);
  memset(test_write, 3, block_size);
  rett = lfs_write(myfd, test_write, block_size, file_size);
  if (rett <= 0) {
    printf("Could not create the proper file size of %lld, %d\n", file_size,
           rett);
    return 0;
  }
  for (int i = 0; i < iterations; i++) {
    myrand = (((long long)rand() * block_size) % file_size);
    rett = lfs_write(myfd, test_write, block_size, myrand);
    if (rett <= 0) {
      printf("write transaction failed!!! lfs_write returned %d!!!\n", rett);
      return 0;
    }
  }
  clear_cache();
  free(test_write);
  lfs_close(myfd);
  gettimeofday(&tv, NULL);
  finish = (unsigned long long)(tv.tv_sec) * 1000 +
           (unsigned long long)(tv.tv_usec) / 1000;
  seconds = finish - start;
  printf("writes took %llu milli-seconds\n", seconds);
  printf(
      "write bandwidth: %llu MB/s\n",
      (((unsigned long long)block_size * iterations * 1000) / (1024 * 1024)) /
          seconds);
  printf("write IOPS: %llu\n",
         ((unsigned long long)iterations * 1000) / seconds);
  system("free -m | sed \"s/  */ /g\" | cut -d \" \" -f 7|tail -n 3");
  gettimeofday(&tv, NULL);
  start = (unsigned long long)(tv.tv_sec) * 1000 +
          (unsigned long long)(tv.tv_usec) / 1000;
  myfd = lfs_open(argv[1], O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
  char *test_read;
  srand(666);
  long long blocksize = 8192 * 102400;
  test_read = ea_checked_malloc(blocksize);
  for (long long pos = 0; pos < file_size; pos += blocksize) {
    lfs_read(myfd, test_read, blocksize, pos);
    if (pos + blocksize > file_size) {
      blocksize = file_size - pos;
    }
  }
  gettimeofday(&tv, NULL);
  finish = (unsigned long long)(tv.tv_sec) * 1000 +
           (unsigned long long)(tv.tv_usec) / 1000;
  seconds = finish - start;
  system("free -m | sed \"s/  */ /g\" | cut -d \" \" -f 7|tail -n 3");
  lfs_close(myfd);
  clear_cache();
  printf("read took %llu milli-seconds\n", seconds);
  printf("read bandwidth: %llu MB/s\n",
         (((unsigned long long)file_size * 1000) / (1024 * 1024)) / seconds);
  printf("read IOPS: %llu\n",
         ((unsigned long long)iterations * 1000) / seconds);
  system("free -m | sed \"s/  */ /g\" | cut -d \" \" -f 7|tail -n 3");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x5,-0x8(%rbp)
je     1242 <main+0x52>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1793 <main+0x5a3>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10f0 <atoi@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10b0 <atoll@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2d75(%rip),%rax
mov    (%rax),%esi
mov    0x2d54(%rip),%rax
or     (%rax),%esi
mov    0x2d33(%rip),%rax
mov    (%rax),%edx
mov    0x2d3a(%rip),%rax
or     (%rax),%edx
call   10c0 <lfs_open@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    12cc <main+0xdc>
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1793 <main+0x5a3>
mov    $0x0,%al
call   10a0 <clear_cache@plt>
movl   $0x0,-0x64(%rbp)
movq   $0x32000000,-0x70(%rbp)
32
mov    -0x70(%rbp),%rdi
call   10d0 <ea_checked_malloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x70(%rbp),%rdx
mov    $0x4,%esi
call   1080 <memset@plt>
movq   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    135f <main+0x16f>
mov    -0x28(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    -0x70(%rbp),%rdx
mov    -0x78(%rbp),%rcx
call   10e0 <lfs_write@plt>
mov    -0x78(%rbp),%rax
add    -0x70(%rbp),%rax
cmp    -0x20(%rbp),%rax
jbe    1349 <main+0x159>
mov    -0x20(%rbp),%rax
sub    -0x78(%rbp),%rax
mov    %rax,-0x70(%rbp)
jmp    134e <main+0x15e>
mov    -0x70(%rbp),%rax
add    -0x78(%rbp),%rax
mov    %rax,-0x78(%rbp)
jmp    1309 <main+0x119>
mov    $0x0,%al
call   10a0 <clear_cache@plt>
mov    -0x28(%rbp),%edi
call   1100 <lfs_close@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2c7b(%rip),%rax
mov    (%rax),%esi
mov    0x2c5a(%rip),%rax
or     (%rax),%esi
mov    0x2c39(%rip),%rax
mov    (%rax),%edx
mov    0x2c40(%rip),%rax
or     (%rax),%edx
call   10c0 <lfs_open@plt>
mov    %eax,-0x28(%rbp)
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <gettimeofday@plt>
imul   $0x3e8,-0x48(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x50(%rbp),%rax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    -0xa8(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    $0x29a,%edi
call   1090 <srand@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   10d0 <ea_checked_malloc@plt>
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x3,%esi
call   1080 <memset@plt>
mov    -0x28(%rbp),%edi
mov    -0x80(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   10e0 <lfs_write@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jg     1451 <main+0x261>
mov    -0x20(%rbp),%rsi
mov    -0x64(%rbp),%edx
lea    0xcbf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1793 <main+0x5a3>
movl   $0x0,-0x84(%rbp)
mov    -0x84(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    14d9 <main+0x2e9>
mov    $0x0,%al
call   1110 <rand@plt>
imul   -0x18(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x20(%rbp)
mov    %rdx,-0x60(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x80(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x60(%rbp),%rcx
call   10e0 <lfs_write@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jg     14c0 <main+0x2d0>
mov    -0x64(%rbp),%esi
lea    0xc83(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1793 <main+0x5a3>
jmp    14c5 <main+0x2d5>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    145b <main+0x26b>
mov    $0x0,%al
call   10a0 <clear_cache@plt>
mov    -0x80(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%edi
call   1100 <lfs_close@plt>
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <gettimeofday@plt>
imul   $0x3e8,-0x48(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x50(%rbp),%rax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    -0xb8(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
sub    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
lea    0xc23(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   %rcx,%rax
imul   $0x3e8,%rax,%rax
shr    $0x14,%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x40(%rbp)
mov    %rax,%rsi
lea    0xc13(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movslq -0x24(%rbp),%rax
imul   $0x3e8,%rax,%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x40(%rbp)
mov    %rax,%rsi
lea    0xc0b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xc0f(%rip),%rdi
call   1050 <system@plt>
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <gettimeofday@plt>
imul   $0x3e8,-0x48(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x50(%rbp),%rax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    -0xb0(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2a04(%rip),%rax
mov    (%rax),%esi
mov    0x29e3(%rip),%rax
or     (%rax),%esi
mov    0x29c2(%rip),%rax
mov    (%rax),%edx
mov    0x29c9(%rip),%rax
or     (%rax),%edx
call   10c0 <lfs_open@plt>
mov    %eax,-0x28(%rbp)
mov    $0x29a,%edi
call   1090 <srand@plt>
movq   $0x32000000,-0x98(%rbp)
mov    -0x98(%rbp),%rdi
call   10d0 <ea_checked_malloc@plt>
mov    %rax,-0x90(%rbp)
movq   $0x0,-0xa0(%rbp)
mov    -0xa0(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    16c3 <main+0x4d3>
mov    -0x28(%rbp),%edi
mov    -0x90(%rbp),%rsi
mov    -0x98(%rbp),%rdx
mov    -0xa0(%rbp),%rcx
call   1040 <lfs_read@plt>
mov    -0xa0(%rbp),%rax
add    -0x98(%rbp),%rax
cmp    -0x20(%rbp),%rax
jle    16a4 <main+0x4b4>
mov    -0x20(%rbp),%rax
sub    -0xa0(%rbp),%rax
mov    %rax,-0x98(%rbp)
jmp    16a9 <main+0x4b9>
mov    -0x98(%rbp),%rax
add    -0xa0(%rbp),%rax
mov    %rax,-0xa0(%rbp)
jmp    164c <main+0x45c>
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <gettimeofday@plt>
imul   $0x3e8,-0x48(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    -0x50(%rbp),%rax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    -0xc0(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
sub    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    0xaa3(%rip),%rdi
call   1050 <system@plt>
mov    -0x28(%rbp),%edi
call   1100 <lfs_close@plt>
mov    $0x0,%al
call   10a0 <clear_cache@plt>
mov    -0x40(%rbp),%rsi
lea    0xaba(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
imul   $0x3e8,-0x20(%rbp),%rax
shr    $0x14,%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x40(%rbp)
mov    %rax,%rsi
lea    0xab3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movslq -0x24(%rbp),%rax
imul   $0x3e8,%rax,%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x40(%rbp)
mov    %rax,%rsi
lea    0xaaa(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xa2d(%rip),%rdi
call   1050 <system@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
lea    0xfbd(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x5,%ebx
jne    14a7 <main+0x2a7>
mov    0x10(%rbp),%rdi
call   1100 <atoi@plt>
mov    %rax,%r15
mov    0x18(%rbp),%rdi
call   10c0 <atoll@plt>
mov    %rax,%r14
mov    0x20(%rbp),%rdi
call   1100 <atoi@plt>
mov    %rax,(%rsp)
mov    0x8(%rbp),%rdi
mov    0x2da0(%rip),%rax
mov    0x2d81(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d5e(%rip),%rax
mov    0x2d67(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
call   10d0 <lfs_open@plt>
cmp    $0xffffffff,%eax
je     14c3 <main+0x2c3>
mov    %eax,%r13d
mov    %rbp,0x20(%rsp)
xor    %eax,%eax
call   10b0 <clear_cache@plt>
mov    $0x32000000,%ebp
mov    $0x32000000,%edi
call   10e0 <ea_checked_malloc@plt>
mov    %rax,%r12
mov    $0x32000000,%edx
mov    %rax,%rdi
mov    $0x4,%esi
call   1090 <memset@plt>
test   %r14,%r14
jle    12ea <main+0xea>
xor    %ebx,%ebx
nopl   (%rax)
mov    %r13d,%edi
mov    %r12,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
call   10f0 <lfs_write@plt>
lea    (%rbx,%rbp,1),%rax
mov    %r14,%rcx
sub    %rbx,%rcx
cmp    %r14,%rax
cmova  %rcx,%rbp
add    %rbp,%rbx
cmp    %rbx,%r14
jg     12c0 <main+0xc0>
xor    %eax,%eax
call   10b0 <clear_cache@plt>
mov    %r13d,%edi
call   1110 <lfs_close@plt>
mov    0x2ce0(%rip),%rax
mov    (%rax),%esi
mov    0x2cef(%rip),%rax
or     (%rax),%esi
mov    0x20(%rsp),%rax
mov    0x8(%rax),%rdi
mov    0x2cbd(%rip),%rax
mov    (%rax),%edx
mov    0x2ca4(%rip),%rax
or     (%rax),%edx
call   10d0 <lfs_open@plt>
mov    %eax,%r13d
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1080 <gettimeofday@plt>
mov    0x8(%rsp),%rax
mov    0x10(%rsp),%rbx
shr    $0x3,%rax
movabs $0x20c49ba5e353f7cf,%rcx
9b c4 20
mul    %rcx
mov    %rdx,%rbp
mov    $0x29a,%edi
call   10a0 <srand@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   10e0 <ea_checked_malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    $0x3,%esi
mov    %r15,%rdx
call   1090 <memset@plt>
mov    %r13d,%edi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   10f0 <lfs_write@plt>
test   %eax,%eax
jle    14d9 <main+0x2d9>
mov    %rbx,0x18(%rsp)
mov    %rbp,%rbx
cmpl   $0x0,(%rsp)
jle    1412 <main+0x212>
mov    (%rsp),%rax
mov    %eax,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1120 <rand@plt>
imul   %r15,%rax
mov    %rax,%rcx
or     %r14,%rcx
shr    $0x20,%rcx
je     13f0 <main+0x1f0>
xor    %edx,%edx
div    %r14
mov    %rdx,%rcx
jmp    13f7 <main+0x1f7>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %edx,%edx
div    %r14d
mov    %edx,%ecx
mov    %r13d,%edi
mov    %r12,%rsi
mov    %r15,%rdx
call   10f0 <lfs_write@plt>
test   %eax,%eax
jle    14f1 <main+0x2f1>
add    $0xffffffff,%ebp
jne    13c0 <main+0x1c0>
shr    $0x4,%rbx
xor    %eax,%eax
call   10b0 <clear_cache@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r13d,%edi
call   1110 <lfs_close@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1080 <gettimeofday@plt>
mov    0x8(%rsp),%rax
mov    0x10(%rsp),%rcx
sub    0x18(%rsp),%rcx
shr    $0x3,%rax
movabs $0x20c49ba5e353f7cf,%rdx
9b c4 20
mul    %rdx
shr    $0x4,%rdx
sub    %rbx,%rdx
imul   $0x3e8,%rcx,%rbp
add    %rdx,%rbp
lea    0xc98(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
movslq (%rsp),%rax
imul   $0x3e8,%rax,%rbx
imul   %rbx,%r15
shr    $0x14,%r15
mov    %r15,%rax
or     %rbp,%rax
shr    $0x20,%rax
je     1506 <main+0x306>
mov    %r15,%rax
xor    %edx,%edx
div    %rbp
mov    %rax,%rsi
jmp    150f <main+0x30f>
mov    0x0(%rbp),%rsi
lea    0xb4e(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%eax
jmp    16f9 <main+0x4f9>
lea    0xd23(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
jmp    16f9 <main+0x4f9>
lea    0xbc0(%rip),%rdi
mov    %r14,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <printf@plt>
jmp    16f7 <main+0x4f7>
lea    0xbdb(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    16f7 <main+0x4f7>
mov    %r15d,%eax
xor    %edx,%edx
div    %ebp
mov    %eax,%esi
lea    0xc13(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rax
or     %rbp,%rax
shr    $0x20,%rax
mov    %rbx,0x18(%rsp)
je     153b <main+0x33b>
mov    %rbx,%rax
xor    %edx,%edx
div    %rbp
mov    %rax,%rsi
jmp    1543 <main+0x343>
mov    %ebx,%eax
xor    %edx,%edx
div    %ebp
mov    %eax,%esi
mov    0x20(%rsp),%rbx
lea    0xbf6(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xbfa(%rip),%rdi
call   1060 <system@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1080 <gettimeofday@plt>
mov    0x8(%rsp),%rax
mov    0x10(%rsp),%rcx
mov    %rcx,(%rsp)
shr    $0x3,%rax
movabs $0x20c49ba5e353f7cf,%rcx
9b c4 20
mul    %rcx
mov    %rdx,%r15
shr    $0x4,%r15
mov    0x2a45(%rip),%rax
mov    (%rax),%esi
mov    0x2a54(%rip),%rax
or     (%rax),%esi
mov    0x8(%rbx),%rdi
mov    0x2a27(%rip),%rax
mov    (%rax),%edx
mov    0x2a0e(%rip),%rax
or     (%rax),%edx
call   10d0 <lfs_open@plt>
mov    %eax,%r13d
mov    $0x29a,%edi
call   10a0 <srand@plt>
mov    $0x32000000,%ebx
mov    $0x32000000,%edi
call   10e0 <ea_checked_malloc@plt>
test   %r14,%r14
jle    161a <main+0x41a>
mov    %rax,%rbp
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
call   1050 <lfs_read@plt>
lea    (%r12,%rbx,1),%rax
mov    %r14,%rcx
sub    %r12,%rcx
cmp    %r14,%rax
cmovg  %rcx,%rbx
add    %rbx,%r12
cmp    %r12,%r14
jg     15f0 <main+0x3f0>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1080 <gettimeofday@plt>
mov    0x8(%rsp),%rax
mov    0x10(%rsp),%rcx
sub    (%rsp),%rcx
shr    $0x3,%rax
movabs $0x20c49ba5e353f7cf,%rdx
9b c4 20
mul    %rdx
shr    $0x4,%rdx
sub    %r15,%rdx
imul   $0x3e8,%rcx,%rbx
add    %rdx,%rbx
lea    0xafa(%rip),%rdi
call   1060 <system@plt>
mov    %r13d,%edi
call   1110 <lfs_close@plt>
xor    %eax,%eax
call   10b0 <clear_cache@plt>
lea    0xb15(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
imul   $0x3e8,%r14,%rax
shr    $0x14,%rax
mov    %rax,%rcx
or     %rbx,%rcx
shr    $0x20,%rcx
je     16a3 <main+0x4a3>
xor    %edx,%edx
div    %rbx
mov    %rax,%rsi
jmp    16a9 <main+0x4a9>
xor    %edx,%edx
div    %ebx
mov    %eax,%esi
mov    0x18(%rsp),%rbp
lea    0xaf6(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbp,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     16d5 <main+0x4d5>
mov    %rbp,%rax
xor    %edx,%edx
div    %rbx
mov    %rax,%rsi
jmp    16dd <main+0x4dd>
mov    %ebp,%eax
xor    %edx,%edx
div    %ebx
mov    %eax,%esi
lea    0xae2(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xa65(%rip),%rdi
call   1060 <system@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@.str = [23 x i8] c"---------------------\0A\00"
@.str.1 = [160 x i8] c"correct usage: %s <path to datafile> <random I/O size in Bytes> <file size in Bytes> <iterations>\0A NOTE: I/O size should be multiple of 512 bytes (one sector)\0A\00"
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.2 = [70 x i8] c"could not open/create the datafile! check the path and permissions. \0A\00"
@.str.3 = [51 x i8] c"Could not create the proper file size of %lld, %d\0A\00"
@.str.4 = [54 x i8] c"write transaction failed!!! lfs_write returned %d!!!\0A\00"
@.str.5 = [32 x i8] c"writes took %llu milli-seconds\0A\00"
@.str.6 = [28 x i8] c"write bandwidth: %llu MB/s\0A\00"
@.str.7 = [18 x i8] c"write IOPS: %llu\0A\00"
@.str.8 = [54 x i8] c"free -m | sed \22s/ */ /g\22 | cut -d \22 \22 -f 7|tail -n 3\00"
@.str.9 = [30 x i8] c"read took %llu milli-seconds\0A\00"
@.str.10 = [27 x i8] c"read bandwidth: %llu MB/s\0A\00"
@.str.11 = [17 x i8] c"read IOPS: %llu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca %struct.timeval
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i32
%17 = alloca i64
%18 = alloca i64
%19 = alloca i8*
%20 = alloca i32
%21 = alloca i8*
%22 = alloca i64
%23 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%25 = load i32, i32* %4
%26 = icmp ne i32 %25, 5
br i1 %26, label %27, label %32
27: ; preds = %2
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([160 x i8], [160 x i8]* @.str.1, i64 0, i64 0), i8* %30)
store i32 -1, i32* %3
br label %269
32: ; preds = %2
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i8* @atoi(i8* %35)
%37 = ptrtoint i8* %36 to i64
store i64 %37, i64* %6
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 3
%40 = load i8*, i8** %39
%41 = call i64 @atoll(i8* %40)
store i64 %41, i64* %7
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 4
%44 = load i8*, i8** %43
%45 = call i8* @atoi(i8* %44)
%46 = ptrtoint i8* %45 to i32
store i32 %46, i32* %8
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = load i32, i32* @O_CREAT
%51 = load i32, i32* @O_RDWR
%52 = or i32 %50, %51
%53 = load i32, i32* @S_IRUSR
%54 = load i32, i32* @S_IWUSR
%55 = or i32 %53, %54
%56 = call i32 @lfs_open(i8* %49, i32 %52, i32 %55)
store i32 %56, i32* %9
%57 = load i32, i32* %9
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %61
59: ; preds = %32
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %269
61: ; preds = %32
%62 = call i32 (...) @clear_cache()
store i32 0, i32* %16
store i64 838860800, i64* %17
%63 = load i64, i64* %17
%64 = call i8* @ea_checked_malloc(i64 %63)
store i8* %64, i8** %14
%65 = load i8*, i8** %14
%66 = load i64, i64* %17
%67 = call i32 @memset(i8* %65, i32 4, i64 %66)
store i64 0, i64* %18
br label %68
68: ; preds = %88, %61
%69 = load i64, i64* %18
%70 = load i64, i64* %7
%71 = icmp slt i64 %69, %70
br i1 %71, label %72, label %92
72: ; preds = %68
%73 = load i32, i32* %9
%74 = load i8*, i8** %14
%75 = load i64, i64* %17
%76 = load i64, i64* %18
%77 = call i32 @lfs_write(i32 %73, i8* %74, i64 %75, i64 %76)
%78 = load i64, i64* %18
%79 = load i64, i64* %17
%80 = add i64 %78, %79
%81 = load i64, i64* %7
%82 = icmp ugt i64 %80, %81
br i1 %82, label %83, label %87
83: ; preds = %72
%84 = load i64, i64* %7
%85 = load i64, i64* %18
%86 = sub nsw i64 %84, %85
store i64 %86, i64* %17
br label %87
87: ; preds = %83, %72
br label %88
88: ; preds = %87
%89 = load i64, i64* %17
%90 = load i64, i64* %18
%91 = add i64 %90, %89
store i64 %91, i64* %18
br label %68
92: ; preds = %68
%93 = call i32 (...) @clear_cache()
%94 = load i32, i32* %9
%95 = call i32 @lfs_close(i32 %94)
%96 = load i8**, i8*** %5
%97 = getelementptr inbounds i8*, i8** %96, i64 1
%98 = load i8*, i8** %97
%99 = load i32, i32* @O_CREAT
%100 = load i32, i32* @O_RDWR
%101 = or i32 %99, %100
%102 = load i32, i32* @S_IRUSR
%103 = load i32, i32* @S_IWUSR
%104 = or i32 %102, %103
%105 = call i32 @lfs_open(i8* %98, i32 %101, i32 %104)
store i32 %105, i32* %9
%106 = call i32 @gettimeofday(%struct.timeval* %13, i32* null)
%107 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
%108 = load i64, i64* %107
%109 = mul i64 %108, 1000
%110 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
%111 = load i64, i64* %110
%112 = udiv i64 %111, 1000
%113 = add i64 %109, %112
store i64 %113, i64* %10
%114 = call i32 @srand(i32 666)
%115 = load i8*, i8** %14
%116 = call i32 @free(i8* %115)
%117 = load i64, i64* %6
%118 = call i8* @ea_checked_malloc(i64 %117)
store i8* %118, i8** %19
%119 = load i8*, i8** %19
%120 = load i64, i64* %6
%121 = call i32 @memset(i8* %119, i32 3, i64 %120)
%122 = load i32, i32* %9
%123 = load i8*, i8** %19
%124 = load i64, i64* %6
%125 = load i64, i64* %7
%126 = call i32 @lfs_write(i32 %122, i8* %123, i64 %124, i64 %125)
store i32 %126, i32* %16
%127 = load i32, i32* %16
%128 = icmp sle i32 %127, 0
br i1 %128, label %129, label %133
129: ; preds = %92
%130 = load i64, i64* %7
%131 = load i32, i32* %16
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i64 %130, i32 %131)
store i32 0, i32* %3
br label %269
133: ; preds = %92
store i32 0, i32* %20
br label %134
134: ; preds = %155, %133
%135 = load i32, i32* %20
%136 = load i32, i32* %8
%137 = icmp slt i32 %135, %136
br i1 %137, label %138, label %158
138: ; preds = %134
%139 = call i64 (...) @rand()
%140 = load i64, i64* %6
%141 = mul i64 %139, %140
%142 = load i64, i64* %7
%143 = urem i64 %141, %142
store i64 %143, i64* %15
%144 = load i32, i32* %9
%145 = load i8*, i8** %19
%146 = load i64, i64* %6
%147 = load i64, i64* %15
%148 = call i32 @lfs_write(i32 %144, i8* %145, i64 %146, i64 %147)
store i32 %148, i32* %16
%149 = load i32, i32* %16
%150 = icmp sle i32 %149, 0
br i1 %150, label %151, label %154
151: ; preds = %138
%152 = load i32, i32* %16
%153 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), i32 %152)
store i32 0, i32* %3
br label %269
154: ; preds = %138
br label %155
155: ; preds = %154
%156 = load i32, i32* %20
%157 = add nsw i32 %156, 1
store i32 %157, i32* %20
br label %134
158: ; preds = %134
%159 = call i32 (...) @clear_cache()
%160 = load i8*, i8** %19
%161 = call i32 @free(i8* %160)
%162 = load i32, i32* %9
%163 = call i32 @lfs_close(i32 %162)
%164 = call i32 @gettimeofday(%struct.timeval* %13, i32* null)
%165 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
%166 = load i64, i64* %165
%167 = mul i64 %166, 1000
%168 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
%169 = load i64, i64* %168
%170 = udiv i64 %169, 1000
%171 = add i64 %167, %170
store i64 %171, i64* %11
%172 = load i64, i64* %11
%173 = load i64, i64* %10
%174 = sub i64 %172, %173
store i64 %174, i64* %12
%175 = load i64, i64* %12
%176 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i64 %175)
%177 = load i64, i64* %6
%178 = load i32, i32* %8
%179 = sext i32 %178 to i64
%180 = mul i64 %177, %179
%181 = mul i64 %180, 1000
%182 = udiv i64 %181, 1048576
%183 = load i64, i64* %12
%184 = udiv i64 %182, %183
%185 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i64 %184)
%186 = load i32, i32* %8
%187 = sext i32 %186 to i64
%188 = mul i64 %187, 1000
%189 = load i64, i64* %12
%190 = udiv i64 %188, %189
%191 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i64 %190)
%192 = call i32 @system(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.8, i64 0, i64 0))
%193 = call i32 @gettimeofday(%struct.timeval* %13, i32* null)
%194 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
%195 = load i64, i64* %194
%196 = mul i64 %195, 1000
%197 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
%198 = load i64, i64* %197
%199 = udiv i64 %198, 1000
%200 = add i64 %196, %199
store i64 %200, i64* %10
%201 = load i8**, i8*** %5
%202 = getelementptr inbounds i8*, i8** %201, i64 1
%203 = load i8*, i8** %202
%204 = load i32, i32* @O_CREAT
%205 = load i32, i32* @O_RDWR
%206 = or i32 %204, %205
%207 = load i32, i32* @S_IRUSR
%208 = load i32, i32* @S_IWUSR
%209 = or i32 %207, %208
%210 = call i32 @lfs_open(i8* %203, i32 %206, i32 %209)
store i32 %210, i32* %9
%211 = call i32 @srand(i32 666)
store i64 838860800, i64* %22
%212 = load i64, i64* %22
%213 = call i8* @ea_checked_malloc(i64 %212)
store i8* %213, i8** %21
store i64 0, i64* %23
br label %214
214: ; preds = %234, %158
%215 = load i64, i64* %23
%216 = load i64, i64* %7
%217 = icmp slt i64 %215, %216
br i1 %217, label %218, label %238
218: ; preds = %214
%219 = load i32, i32* %9
%220 = load i8*, i8** %21
%221 = load i64, i64* %22
%222 = load i64, i64* %23
%223 = call i32 @lfs_read(i32 %219, i8* %220, i64 %221, i64 %222)
%224 = load i64, i64* %23
%225 = load i64, i64* %22
%226 = add nsw i64 %224, %225
%227 = load i64, i64* %7
%228 = icmp sgt i64 %226, %227
br i1 %228, label %229, label %233
229: ; preds = %218
%230 = load i64, i64* %7
%231 = load i64, i64* %23
%232 = sub nsw i64 %230, %231
store i64 %232, i64* %22
br label %233
233: ; preds = %229, %218
br label %234
234: ; preds = %233
%235 = load i64, i64* %22
%236 = load i64, i64* %23
%237 = add nsw i64 %236, %235
store i64 %237, i64* %23
br label %214
238: ; preds = %214
%239 = call i32 @gettimeofday(%struct.timeval* %13, i32* null)
%240 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
%241 = load i64, i64* %240
%242 = mul i64 %241, 1000
%243 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
%244 = load i64, i64* %243
%245 = udiv i64 %244, 1000
%246 = add i64 %242, %245
store i64 %246, i64* %11
%247 = load i64, i64* %11
%248 = load i64, i64* %10
%249 = sub i64 %247, %248
store i64 %249, i64* %12
%250 = call i32 @system(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.8, i64 0, i64 0))
%251 = load i32, i32* %9
%252 = call i32 @lfs_close(i32 %251)
%253 = call i32 (...) @clear_cache()
%254 = load i64, i64* %12
%255 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i64 %254)
%256 = load i64, i64* %7
%257 = mul i64 %256, 1000
%258 = udiv i64 %257, 1048576
%259 = load i64, i64* %12
%260 = udiv i64 %258, %259
%261 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i64 %260)
%262 = load i32, i32* %8
%263 = sext i32 %262 to i64
%264 = mul i64 %263, 1000
%265 = load i64, i64* %12
%266 = udiv i64 %264, %265
%267 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i64 %266)
%268 = call i32 @system(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %3
br label %269
269: ; preds = %238, %151, %129, %59, %27
%270 = load i32, i32* %3
ret i32 %270
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
@.str.1 = [160 x i8] c"correct usage: %s <path to datafile> <random I/O size in Bytes> <file size in Bytes> <iterations>\0A NOTE: I/O size should be multiple of 512 bytes (one sector)\0A\00"
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.3 = [51 x i8] c"Could not create the proper file size of %lld, %d\0A\00"
@.str.4 = [54 x i8] c"write transaction failed!!! lfs_write returned %d!!!\0A\00"
@.str.5 = [32 x i8] c"writes took %llu milli-seconds\0A\00"
@.str.6 = [28 x i8] c"write bandwidth: %llu MB/s\0A\00"
@.str.7 = [18 x i8] c"write IOPS: %llu\0A\00"
@.str.8 = [54 x i8] c"free -m | sed \22s/ */ /g\22 | cut -d \22 \22 -f 7|tail -n 3\00"
@.str.9 = [30 x i8] c"read took %llu milli-seconds\0A\00"
@.str.10 = [27 x i8] c"read bandwidth: %llu MB/s\0A\00"
@.str.11 = [17 x i8] c"read IOPS: %llu\0A\00"
@str = [22 x i8] c"---------------------\00"
@str.12 = [69 x i8] c"could not open/create the datafile! check the path and permissions. \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timeval
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%5 = icmp eq i32 %0, 5
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([160 x i8], [160 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %157
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i8* @atoi(i8* %11)
%13 = ptrtoint i8* %12 to i64
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
%16 = tail call i64 @atoll(i8* %15)
%17 = getelementptr inbounds i8*, i8** %1, i64 4
%18 = load i8*, i8** %17
%19 = tail call i8* @atoi(i8* %18)
%20 = ptrtoint i8* %19 to i64
%21 = trunc i64 %20 to i32
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = load i32, i32* @O_CREAT
%25 = load i32, i32* @O_RDWR
%26 = or i32 %25, %24
%27 = load i32, i32* @S_IRUSR
%28 = load i32, i32* @S_IWUSR
%29 = or i32 %28, %27
%30 = tail call i32 @lfs_open(i8* %23, i32 %26, i32 %29)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %34
32: ; preds = %9
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @str.12, i64 0, i64 0))
br label %157
34: ; preds = %9
%35 = bitcast %struct.timeval* %3 to i8*
%36 = tail call i32 (...) @clear_cache()
%37 = tail call i8* @ea_checked_malloc(i64 838860800)
%38 = tail call i32 @memset(i8* %37, i32 4, i64 838860800)
%39 = icmp sgt i64 %16, 0
br i1 %39, label %65, label %40
40: ; preds = %65, %34
%41 = tail call i32 (...) @clear_cache()
%42 = tail call i32 @lfs_close(i32 %30)
%43 = load i8*, i8** %22
%44 = load i32, i32* @O_CREAT
%45 = load i32, i32* @O_RDWR
%46 = or i32 %45, %44
%47 = load i32, i32* @S_IRUSR
%48 = load i32, i32* @S_IWUSR
%49 = or i32 %48, %47
%50 = tail call i32 @lfs_open(i8* %43, i32 %46, i32 %49)
%51 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%52 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%53 = load i64, i64* %52
%54 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%55 = load i64, i64* %54
%56 = udiv i64 %55, 1000
%57 = tail call i32 @srand(i32 666)
%58 = tail call i32 @free(i8* %37)
%59 = tail call i8* @ea_checked_malloc(i64 %13)
%60 = tail call i32 @memset(i8* %59, i32 3, i64 %13)
%61 = tail call i32 @lfs_write(i32 %50, i8* %59, i64 %13, i64 %16)
%62 = icmp slt i32 %61, 1
br i1 %62, label %75, label %63
63: ; preds = %40
%64 = icmp sgt i32 %21, 0
br i1 %64, label %79, label %89
65: ; preds = %34, %65
%66 = phi i64 [ %73, %65 ], [ 0, %34 ]
%67 = phi i64 [ %72, %65 ], [ 838860800, %34 ]
%68 = tail call i32 @lfs_write(i32 %30, i8* %37, i64 %67, i64 %66)
%69 = add i64 %66, %67
%70 = icmp ugt i64 %69, %16
%71 = sub nsw i64 %16, %66
%72 = select i1 %70, i64 %71, i64 %67
%73 = add i64 %72, %66
%74 = icmp sgt i64 %16, %73
br i1 %74, label %65, label %40
75: ; preds = %40
%76 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i64 %16, i32 %61)
br label %156
77: ; preds = %79
%78 = icmp eq i32 %86, %21
br i1 %78, label %89, label %79
79: ; preds = %63, %77
%80 = phi i32 [ %86, %77 ], [ 0, %63 ]
%81 = tail call i64 (...) @rand()
%82 = mul i64 %81, %13
%83 = urem i64 %82, %16
%84 = tail call i32 @lfs_write(i32 %50, i8* %59, i64 %13, i64 %83)
%85 = icmp slt i32 %84, 1
%86 = add nuw nsw i32 %80, 1
br i1 %85, label %87, label %77
87: ; preds = %79
%88 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), i32 %84)
br label %156
89: ; preds = %77, %63
%90 = tail call i32 (...) @clear_cache()
%91 = tail call i32 @free(i8* %59)
%92 = tail call i32 @lfs_close(i32 %50)
%93 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%94 = load i64, i64* %52
%95 = load i64, i64* %54
%96 = udiv i64 %95, 1000
%97 = sub i64 %94, %53
%98 = mul i64 %97, 1000
%99 = sub nsw i64 %96, %56
%100 = add i64 %99, %98
%101 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i64 %100)
%102 = shl i64 %20, 32
%103 = ashr exact i64 %102, 32
%104 = mul nsw i64 %103, 1000
%105 = mul i64 %104, %13
%106 = lshr i64 %105, 20
%107 = udiv i64 %106, %100
%108 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i64 %107)
%109 = udiv i64 %104, %100
%110 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i64 %109)
%111 = tail call i32 @system(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.8, i64 0, i64 0))
%112 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%113 = load i64, i64* %52
%114 = load i64, i64* %54
%115 = udiv i64 %114, 1000
%116 = load i8*, i8** %22
%117 = load i32, i32* @O_CREAT
%118 = load i32, i32* @O_RDWR
%119 = or i32 %118, %117
%120 = load i32, i32* @S_IRUSR
%121 = load i32, i32* @S_IWUSR
%122 = or i32 %121, %120
%123 = tail call i32 @lfs_open(i8* %116, i32 %119, i32 %122)
%124 = tail call i32 @srand(i32 666)
%125 = tail call i8* @ea_checked_malloc(i64 838860800)
br i1 %39, label %146, label %126
126: ; preds = %146, %89
%127 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%128 = load i64, i64* %52
%129 = load i64, i64* %54
%130 = udiv i64 %129, 1000
%131 = sub i64 %128, %113
%132 = mul i64 %131, 1000
%133 = sub nsw i64 %130, %115
%134 = add i64 %133, %132
%135 = tail call i32 @system(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.8, i64 0, i64 0))
%136 = tail call i32 @lfs_close(i32 %123)
%137 = tail call i32 (...) @clear_cache()
%138 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i64 %134)
%139 = mul i64 %16, 1000
%140 = lshr i64 %139, 20
%141 = udiv i64 %140, %134
%142 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), i64 %141)
%143 = udiv i64 %104, %134
%144 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i64 %143)
%145 = tail call i32 @system(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.8, i64 0, i64 0))
br label %156
146: ; preds = %89, %146
%147 = phi i64 [ %154, %146 ], [ 0, %89 ]
%148 = phi i64 [ %153, %146 ], [ 838860800, %89 ]
%149 = tail call i32 @lfs_read(i32 %123, i8* %125, i64 %148, i64 %147)
%150 = add nsw i64 %147, %148
%151 = icmp sgt i64 %150, %16
%152 = sub nsw i64 %16, %147
%153 = select i1 %151, i64 %152, i64 %148
%154 = add nsw i64 %153, %147
%155 = icmp sgt i64 %16, %154
br i1 %155, label %146, label %126
156: ; preds = %87, %126, %75
br label %157
157: ; preds = %32, %156, %6
%158 = phi i32 [ -1, %6 ], [ -1, %32 ], [ 0, %156 ]
ret i32 %158
}