#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 {
  double tv_sec;
  double tv_usec;
};
typedef int ssize_t;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ SEEK_SET;
int close(int);
scalar_t__ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int fsync(int);
int generate_random_address(int);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int lseek(int, int, int /*<<< orphan*/);
scalar_t__ malloc(int);
int open(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ print_global_performance(double, int, int);
int /*<<< orphan*/ printf(char *, double, ...);
int /*<<< orphan*/ srand(unsigned int);
int system(char *);
scalar_t__ time(int /*<<< orphan*/ *);
int write(int, char *, int);
int measure_random_synchrounous_write(const char *testfile_name,
                                      int request_size, int requests_number,
                                      int limit) {
  ssize_t bytes_written, local_request_size, local_requests_number,
      total_size = 0;
  int i, j, testfile_descriptor;
  char *write_buffer;
  struct timeval start_timer;
  struct timeval stop_timer;
  double time_elapsed, total_time_elapsed = 0;
  int generated_offset, actual_offset;
  if ((local_request_size = request_size * 1024 * sizeof(char)) <= 0)
    local_request_size = 64 * 1024 * sizeof(char);
  if ((local_requests_number = requests_number) <= 0)
    local_requests_number = 50;
  testfile_descriptor = open(testfile_name, O_WRONLY);
  if (testfile_descriptor < 0) {
    perror("open");
    return (EXIT_FAILURE);
  }
  write_buffer = (char *)malloc(local_request_size);
  if (write_buffer == NULL) {
    perror("malloc");
    close(testfile_descriptor);
    return (EXIT_FAILURE);
  }
  for (i = 0; i < local_requests_number; i++) {
    generated_offset =
        generate_random_address((limit * 1024) - local_request_size);
    if (generated_offset < 0) {
      perror("generate_random_address");
      free(write_buffer);
      close(testfile_descriptor);
      return (EXIT_FAILURE);
    }
    actual_offset = lseek(testfile_descriptor, generated_offset, SEEK_SET);
    if (actual_offset < 0) {
      perror("lseek");
      free(write_buffer);
      close(testfile_descriptor);
      return (EXIT_FAILURE);
    }
    srand((unsigned int)time(NULL));
    for (j = 0; j < local_request_size; j++)
      write_buffer[j] = 'C';
    gettimeofday(&start_timer, NULL);
    bytes_written =
        write(testfile_descriptor, write_buffer, local_request_size);
    gettimeofday(&stop_timer, NULL);
    if (bytes_written > 0) {
      time_elapsed = (stop_timer.tv_sec - start_timer.tv_sec) * 1000.0;
      time_elapsed += (stop_timer.tv_usec - start_timer.tv_usec) / 1000.0;
      total_time_elapsed += time_elapsed;
      total_size += bytes_written;
      printf("%d\t%f\t%d\n", i, time_elapsed, generated_offset);
    } else {
      perror("write");
      break;
    }
  }
  gettimeofday(&start_timer, NULL);
  if (fflush(NULL) != 0) {
    perror("fflush");
    close(testfile_descriptor);
    free(write_buffer);
    return EXIT_FAILURE;
  }
  gettimeofday(&stop_timer, NULL);
  time_elapsed = (stop_timer.tv_sec - start_timer.tv_sec) * 1000.0;
  time_elapsed += (stop_timer.tv_usec - start_timer.tv_usec) / 1000.0;
  printf("#fflush %f\n", time_elapsed);
  total_time_elapsed += time_elapsed;
  gettimeofday(&start_timer, NULL);
  if (fsync(testfile_descriptor) == -1) {
    perror("fsync");
    close(testfile_descriptor);
    free(write_buffer);
    return EXIT_FAILURE;
  }
  gettimeofday(&stop_timer, NULL);
  time_elapsed = (stop_timer.tv_sec - start_timer.tv_sec) * 1000.0;
  time_elapsed += (stop_timer.tv_usec - start_timer.tv_usec) / 1000.0;
  printf("#fsync %f\n", time_elapsed);
  total_time_elapsed += time_elapsed;
  gettimeofday(&start_timer, NULL);
  if (close(testfile_descriptor) == -1) {
    perror("close");
    free(write_buffer);
    return EXIT_FAILURE;
  }
  gettimeofday(&stop_timer, NULL);
  time_elapsed = (stop_timer.tv_sec - start_timer.tv_sec) * 1000.0;
  time_elapsed += (stop_timer.tv_usec - start_timer.tv_usec) / 1000.0;
  printf("#close %f\n", time_elapsed);
  total_time_elapsed += time_elapsed;
  gettimeofday(&start_timer, NULL);
  if (system("umount /mnt/flash") == -1) {
    perror("system");
    free(write_buffer);
    return EXIT_FAILURE;
  }
  gettimeofday(&stop_timer, NULL);
  time_elapsed = (stop_timer.tv_sec - start_timer.tv_sec) * 1000.0;
  time_elapsed += (stop_timer.tv_usec - start_timer.tv_usec) / 1000.0;
  printf("#umount %f\n", time_elapsed);
  total_time_elapsed += time_elapsed;
  printf("#total_size %d Bytes\n", (int)total_size);
  printf("#total_time_elapsed %f ms\n", total_time_elapsed);
  print_global_performance(total_time_elapsed, total_size, request_size);
  free(write_buffer);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<measure_random_synchrounous_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x2c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x14(%rbp),%eax
shl    $0xa,%eax
cltq
shl    $0x0,%rax
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jg     1246 <measure_random_synchrounous_write+0x46>
movl   $0x10000,-0x24(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jg     125c <measure_random_synchrounous_write+0x5c>
movl   $0x32,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2d59(%rip),%rax
mov    (%rax),%esi
call   1100 <open@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jge    1298 <measure_random_synchrounous_write+0x98>
lea    0xd86(%rip),%rdi
call   1110 <perror@plt>
mov    0x2d4a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    17a2 <measure_random_synchrounous_write+0x5a2>
mov    -0x24(%rbp),%edi
call   10d0 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    12d4 <measure_random_synchrounous_write+0xd4>
lea    0xd57(%rip),%rdi
call   1110 <perror@plt>
mov    -0x38(%rbp),%edi
call   10a0 <close@plt>
mov    0x2d0e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    17a2 <measure_random_synchrounous_write+0x5a2>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1489 <measure_random_synchrounous_write+0x289>
mov    -0x1c(%rbp),%edi
shl    $0xa,%edi
sub    -0x24(%rbp),%edi
call   1070 <generate_random_address@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
jge    1330 <measure_random_synchrounous_write+0x130>
lea    0xd0b(%rip),%rdi
call   1110 <perror@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%edi
call   10a0 <close@plt>
mov    0x2cb2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    17a2 <measure_random_synchrounous_write+0x5a2>
mov    -0x38(%rbp),%edi
mov    -0x74(%rbp),%esi
mov    0x2ca3(%rip),%rax
mov    (%rax),%edx
call   1080 <lseek@plt>
mov    %eax,-0x78(%rbp)
cmpl   $0x0,-0x78(%rbp)
jge    137f <measure_random_synchrounous_write+0x17f>
lea    0xcd4(%rip),%rdi
call   1110 <perror@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%edi
call   10a0 <close@plt>
mov    0x2c63(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    17a2 <measure_random_synchrounous_write+0x5a2>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <time@plt>
mov    %eax,%edi
call   10b0 <srand@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    13bc <measure_random_synchrounous_write+0x1bc>
mov    -0x40(%rbp),%rax
movslq -0x34(%rbp),%rcx
movb   $0x43,(%rax,%rcx,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1396 <measure_random_synchrounous_write+0x196>
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
mov    -0x38(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1040 <write@plt>
mov    %eax,-0x20(%rbp)
lea    -0x60(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
cmpl   $0x0,-0x20(%rbp)
jle    1465 <measure_random_synchrounous_write+0x265>
movsd  -0x60(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
movsd  0xbfc(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  0xbe1(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
addsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x20(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cvtsi2sdl -0x30(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
mov    -0x74(%rbp),%esi
lea    0xbd9(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
jmp    1476 <measure_random_synchrounous_write+0x276>
lea    0xbd0(%rip),%rdi
call   1110 <perror@plt>
jmp    1489 <measure_random_synchrounous_write+0x289>
jmp    147b <measure_random_synchrounous_write+0x27b>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    12db <measure_random_synchrounous_write+0xdb>
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10e0 <fflush@plt>
cmp    $0x0,%rax
je     14d7 <measure_random_synchrounous_write+0x2d7>
lea    0xb92(%rip),%rdi
call   1110 <perror@plt>
mov    -0x38(%rbp),%edi
call   10a0 <close@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    0x2b0b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    17a2 <measure_random_synchrounous_write+0x5a2>
lea    -0x60(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
movsd  -0x60(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
movsd  0xb0a(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  0xaef(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
lea    0xb1e(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  -0x68(%rbp),%xmm0
addsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
mov    -0x38(%rbp),%edi
call   10f0 <fsync@plt>
cmp    $0xffffffff,%eax
jne    158d <measure_random_synchrounous_write+0x38d>
lea    0xaef(%rip),%rdi
call   1110 <perror@plt>
mov    -0x38(%rbp),%edi
call   10a0 <close@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    0x2a55(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    17a2 <measure_random_synchrounous_write+0x5a2>
lea    -0x60(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
movsd  -0x60(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
movsd  0xa54(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  0xa39(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
lea    0xa7a(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  -0x68(%rbp),%xmm0
addsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
mov    -0x38(%rbp),%edi
call   10a0 <close@plt>
cmp    $0xffffffff,%eax
jne    163b <measure_random_synchrounous_write+0x43b>
lea    0xa4a(%rip),%rdi
call   1110 <perror@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    0x29a7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    17a2 <measure_random_synchrounous_write+0x5a2>
lea    -0x60(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
movsd  -0x60(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
movsd  0x9a6(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  0x98b(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
lea    0x9dd(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  -0x68(%rbp),%xmm0
addsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
lea    0x9be(%rip),%rdi
call   1050 <system@plt>
cmp    $0xffffffff,%eax
jne    16ed <measure_random_synchrounous_write+0x4ed>
lea    0x9bb(%rip),%rdi
call   1110 <perror@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    0x28f5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    17a2 <measure_random_synchrounous_write+0x5a2>
lea    -0x60(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
movsd  -0x60(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
movsd  0x8f4(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  0x8d9(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
lea    0x94f(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  -0x68(%rbp),%xmm0
addsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
cvtsi2sdl -0x2c(%rbp),%xmm0
lea    0x939(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  -0x70(%rbp),%xmm0
lea    0x93c(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  -0x70(%rbp),%xmm0
mov    -0x2c(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1120 <print_global_performance@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    0x2833(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<measure_random_synchrounous_write>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %ecx,%ebp
mov    %esi,%ebx
mov    %esi,%eax
shl    $0xa,%eax
test   %esi,%esi
mov    $0x10000,%r13d
cmovg  %eax,%r13d
test   %edx,%edx
mov    $0x32,%eax
cmovg  %edx,%eax
mov    %eax,0x38(%rsp)
mov    0x2d78(%rip),%rax
mov    (%rax),%esi
call   1110 <open@plt>
mov    %eax,0x8(%rsp)
test   %eax,%eax
js     15b9 <measure_random_synchrounous_write+0x3a9>
mov    %r13d,%edi
call   10e0 <malloc@plt>
test   %rax,%rax
je     15ca <measure_random_synchrounous_write+0x3ba>
mov    %rax,%r14
mov    %ebx,0x4c(%rsp)
shl    $0xa,%ebp
sub    %r13d,%ebp
mov    %ebp,0x40(%rsp)
mov    %r13d,%eax
mov    %rax,0x50(%rsp)
xor    %ebp,%ebp
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x30(%rsp)
xor    %r12d,%r12d
mov    0x8(%rsp),%ebx
nopl   0x0(%rax,%rax,1)
mov    0x40(%rsp),%edi
call   1070 <generate_random_address@plt>
test   %eax,%eax
js     15dc <measure_random_synchrounous_write+0x3cc>
mov    %eax,%r15d
mov    0x2d25(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    %r15d,%esi
call   1080 <lseek@plt>
test   %eax,%eax
js     15e5 <measure_random_synchrounous_write+0x3d5>
xor    %edi,%edi
call   10d0 <time@plt>
mov    %eax,%edi
call   10c0 <srand@plt>
test   %r13d,%r13d
jle    12f4 <measure_random_synchrounous_write+0xe4>
mov    %r14,%rdi
mov    $0x43,%esi
mov    0x50(%rsp),%rdx
call   10a0 <memset@plt>
lea    0x20(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
mov    %ebx,%edi
mov    %r14,%rbx
mov    %r14,%rsi
mov    %r13d,%edx
call   1040 <write@plt>
mov    %eax,%r14d
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
test   %r14d,%r14d
jle    1602 <measure_random_synchrounous_write+0x3f2>
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
subsd  0x20(%rsp),%xmm0
movsd  0xcbe(%rip),%xmm2
mulsd  %xmm2,%xmm0
subsd  0x28(%rsp),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0x30(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x30(%rsp)
add    %r14d,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
lea    0xcbc(%rip),%rdi
mov    %r15d,%esi
mov    $0x2,%al
call   1060 <printf@plt>
add    $0x1,%r12d
cmp    %r12d,0x38(%rsp)
mov    %rbx,%r14
mov    0x8(%rsp),%ebx
jne    12a0 <measure_random_synchrounous_write+0x90>
lea    0x20(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
xor    %edi,%edi
call   10f0 <fflush@plt>
test   %rax,%rax
jne    161a <measure_random_synchrounous_write+0x40a>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
movsd  0x10(%rsp),%xmm2
movsd  0x18(%rsp),%xmm0
subsd  0x20(%rsp),%xmm2
movsd  0xc28(%rip),%xmm1
mulsd  %xmm1,%xmm2
subsd  0x28(%rsp),%xmm0
divsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
lea    0xc58(%rip),%rdi
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%al
call   1060 <printf@plt>
lea    0x20(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
mov    %ebx,%edi
call   1100 <fsync@plt>
cmp    $0xffffffff,%eax
je     1623 <measure_random_synchrounous_write+0x413>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
movsd  0x10(%rsp),%xmm2
movsd  0x18(%rsp),%xmm0
subsd  0x20(%rsp),%xmm2
movsd  0xbc0(%rip),%xmm1
mulsd  %xmm1,%xmm2
subsd  0x28(%rsp),%xmm0
divsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
lea    0xc02(%rip),%rdi
movsd  %xmm0,0x40(%rsp)
mov    $0x1,%al
call   1060 <printf@plt>
lea    0x20(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
mov    %ebx,%edi
call   10b0 <close@plt>
cmp    $0xffffffff,%eax
je     1638 <measure_random_synchrounous_write+0x428>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
movsd  0x10(%rsp),%xmm2
movsd  0x18(%rsp),%xmm0
subsd  0x20(%rsp),%xmm2
movsd  0xb58(%rip),%xmm1
mulsd  %xmm1,%xmm2
subsd  0x28(%rsp),%xmm0
divsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
lea    0xbab(%rip),%rdi
movsd  %xmm0,0x38(%rsp)
mov    $0x1,%al
call   1060 <printf@plt>
lea    0x20(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
lea    0xb96(%rip),%rdi
call   1050 <system@plt>
cmp    $0xffffffff,%eax
je     1641 <measure_random_synchrounous_write+0x431>
movsd  0x30(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
addsd  0x40(%rsp),%xmm0
addsd  0x38(%rsp),%xmm0
movsd  %xmm0,0x30(%rsp)
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
movsd  0x10(%rsp),%xmm2
movsd  0x18(%rsp),%xmm0
subsd  0x20(%rsp),%xmm2
movsd  0xacd(%rip),%xmm1
mulsd  %xmm1,%xmm2
subsd  0x28(%rsp),%xmm0
divsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xb3e(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  0x8(%rsp),%xmm0
addsd  0x30(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
lea    0xb23(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
lea    0xb2b(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1060 <printf@plt>
movsd  0x8(%rsp),%xmm0
mov    %ebp,%edi
mov    0x4c(%rsp),%esi
call   1130 <print_global_performance@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x2a1c(%rip),%rax
jmp    165c <measure_random_synchrounous_write+0x44c>
lea    0xa48(%rip),%rdi
call   1120 <perror@plt>
jmp    1655 <measure_random_synchrounous_write+0x445>
lea    0xa3c(%rip),%rdi
call   1120 <perror@plt>
mov    0x8(%rsp),%edi
jmp    15fb <measure_random_synchrounous_write+0x3eb>
lea    0xa31(%rip),%rdi
jmp    15ec <measure_random_synchrounous_write+0x3dc>
lea    0xa40(%rip),%rdi
call   1120 <perror@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebx,%edi
call   10b0 <close@plt>
jmp    1655 <measure_random_synchrounous_write+0x445>
lea    0xa33(%rip),%rdi
call   1120 <perror@plt>
mov    %rbx,%r14
mov    0x8(%rsp),%ebx
jmp    1396 <measure_random_synchrounous_write+0x186>
lea    0xa21(%rip),%rdi
jmp    162a <measure_random_synchrounous_write+0x41a>
lea    0xa2b(%rip),%rdi
call   1120 <perror@plt>
mov    %ebx,%edi
call   10b0 <close@plt>
jmp    164d <measure_random_synchrounous_write+0x43d>
lea    0xa27(%rip),%rdi
jmp    1648 <measure_random_synchrounous_write+0x438>
lea    0xa41(%rip),%rdi
call   1120 <perror@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x297c(%rip),%rax
mov    (%rax),%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { double, double }
@O_WRONLY = global i32 0
@.str = [5 x i8] c"open\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [7 x i8] c"malloc\00"
@.str.2 = [24 x i8] c"generate_random_address\00"
@SEEK_SET = global i32 0
@.str.3 = [6 x i8] c"lseek\00"
@.str.4 = [10 x i8] c"%d\09%f\09%d\0A\00"
@.str.5 = [6 x i8] c"write\00"
@.str.6 = [7 x i8] c"fflush\00"
@.str.7 = [12 x i8] c"#fflush %f\0A\00"
@.str.8 = [6 x i8] c"fsync\00"
@.str.9 = [11 x i8] c"#fsync %f\0A\00"
@.str.10 = [6 x i8] c"close\00"
@.str.11 = [11 x i8] c"#close %f\0A\00"
@.str.12 = [18 x i8] c"umount /mnt/flash\00"
@.str.13 = [7 x i8] c"system\00"
@.str.14 = [12 x i8] c"#umount %f\0A\00"
@.str.15 = [22 x i8] c"#total_size %d Bytes\0A\00"
@.str.16 = [27 x i8] c"#total_time_elapsed %f ms\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @measure_random_synchrounous_write(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i8*
%18 = alloca %struct.timeval
%19 = alloca %struct.timeval
%20 = alloca double
%21 = alloca double
%22 = alloca i32
%23 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 0, i32* %13
store double 0.000000e+00, double* %21
%24 = load i32, i32* %7
%25 = mul nsw i32 %24, 1024
%26 = sext i32 %25 to i64
%27 = mul i64 %26, 1
%28 = trunc i64 %27 to i32
store i32 %28, i32* %11
%29 = icmp sle i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %4
store i32 65536, i32* %11
br label %31
31: ; preds = %30, %4
%32 = load i32, i32* %8
store i32 %32, i32* %12
%33 = icmp sle i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %31
store i32 50, i32* %12
br label %35
35: ; preds = %34, %31
%36 = load i8*, i8** %6
%37 = load i32, i32* @O_WRONLY
%38 = call i32 @open(i8* %36, i32 %37)
store i32 %38, i32* %16
%39 = load i32, i32* %16
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %35
%42 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%43 = load i32, i32* @EXIT_FAILURE
store i32 %43, i32* %5
br label %281
44: ; preds = %35
%45 = load i32, i32* %11
%46 = call i64 @malloc(i32 %45)
%47 = inttoptr i64 %46 to i8*
store i8* %47, i8** %17
%48 = load i8*, i8** %17
%49 = icmp eq i8* %48, null
br i1 %49, label %50, label %55
50: ; preds = %44
%51 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%52 = load i32, i32* %16
%53 = call i32 @close(i32 %52)
%54 = load i32, i32* @EXIT_FAILURE
store i32 %54, i32* %5
br label %281
55: ; preds = %44
store i32 0, i32* %14
br label %56
56: ; preds = %143, %55
%57 = load i32, i32* %14
%58 = load i32, i32* %12
%59 = icmp slt i32 %57, %58
br i1 %59, label %60, label %146
60: ; preds = %56
%61 = load i32, i32* %9
%62 = mul nsw i32 %61, 1024
%63 = load i32, i32* %11
%64 = sub nsw i32 %62, %63
%65 = call i32 @generate_random_address(i32 %64)
store i32 %65, i32* %22
%66 = load i32, i32* %22
%67 = icmp slt i32 %66, 0
br i1 %67, label %68, label %75
68: ; preds = %60
%69 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%70 = load i8*, i8** %17
%71 = call i32 @free(i8* %70)
%72 = load i32, i32* %16
%73 = call i32 @close(i32 %72)
%74 = load i32, i32* @EXIT_FAILURE
store i32 %74, i32* %5
br label %281
75: ; preds = %60
%76 = load i32, i32* %16
%77 = load i32, i32* %22
%78 = load i32, i32* @SEEK_SET
%79 = call i32 @lseek(i32 %76, i32 %77, i32 %78)
store i32 %79, i32* %23
%80 = load i32, i32* %23
%81 = icmp slt i32 %80, 0
br i1 %81, label %82, label %89
82: ; preds = %75
%83 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%84 = load i8*, i8** %17
%85 = call i32 @free(i8* %84)
%86 = load i32, i32* %16
%87 = call i32 @close(i32 %86)
%88 = load i32, i32* @EXIT_FAILURE
store i32 %88, i32* %5
br label %281
89: ; preds = %75
%90 = call i64 @time(i32* null)
%91 = trunc i64 %90 to i32
%92 = call i32 @srand(i32 %91)
store i32 0, i32* %15
br label %93
93: ; preds = %102, %89
%94 = load i32, i32* %15
%95 = load i32, i32* %11
%96 = icmp slt i32 %94, %95
br i1 %96, label %97, label %105
97: ; preds = %93
%98 = load i8*, i8** %17
%99 = load i32, i32* %15
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i8, i8* %98, i64 %100
store i8 67, i8* %101
br label %102
102: ; preds = %97
%103 = load i32, i32* %15
%104 = add nsw i32 %103, 1
store i32 %104, i32* %15
br label %93
105: ; preds = %93
%106 = call i32 @gettimeofday(%struct.timeval* %18, i32* null)
%107 = load i32, i32* %16
%108 = load i8*, i8** %17
%109 = load i32, i32* %11
%110 = call i32 @write(i32 %107, i8* %108, i32 %109)
store i32 %110, i32* %10
%111 = call i32 @gettimeofday(%struct.timeval* %19, i32* null)
%112 = load i32, i32* %10
%113 = icmp sgt i32 %112, 0
br i1 %113, label %114, label %140
114: ; preds = %105
%115 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 0
%116 = load double, double* %115
%117 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 0
%118 = load double, double* %117
%119 = fsub double %116, %118
%120 = fmul double %119, 1.000000e+03
store double %120, double* %20
%121 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 1
%122 = load double, double* %121
%123 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 1
%124 = load double, double* %123
%125 = fsub double %122, %124
%126 = fdiv double %125, 1.000000e+03
%127 = load double, double* %20
%128 = fadd double %127, %126
store double %128, double* %20
%129 = load double, double* %20
%130 = load double, double* %21
%131 = fadd double %130, %129
store double %131, double* %21
%132 = load i32, i32* %10
%133 = load i32, i32* %13
%134 = add nsw i32 %133, %132
store i32 %134, i32* %13
%135 = load i32, i32* %14
%136 = sitofp i32 %135 to double
%137 = load double, double* %20
%138 = load i32, i32* %22
%139 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), double %136, double %137, i32 %138)
br label %142
140: ; preds = %105
%141 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %146
142: ; preds = %114
br label %143
143: ; preds = %142
%144 = load i32, i32* %14
%145 = add nsw i32 %144, 1
store i32 %145, i32* %14
br label %56
146: ; preds = %140, %56
%147 = call i32 @gettimeofday(%struct.timeval* %18, i32* null)
%148 = call i64 @fflush(i32* null)
%149 = icmp ne i64 %148, 0
br i1 %149, label %150, label %157
150: ; preds = %146
%151 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%152 = load i32, i32* %16
%153 = call i32 @close(i32 %152)
%154 = load i8*, i8** %17
%155 = call i32 @free(i8* %154)
%156 = load i32, i32* @EXIT_FAILURE
store i32 %156, i32* %5
br label %281
157: ; preds = %146
%158 = call i32 @gettimeofday(%struct.timeval* %19, i32* null)
%159 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 0
%160 = load double, double* %159
%161 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 0
%162 = load double, double* %161
%163 = fsub double %160, %162
%164 = fmul double %163, 1.000000e+03
store double %164, double* %20
%165 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 1
%166 = load double, double* %165
%167 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 1
%168 = load double, double* %167
%169 = fsub double %166, %168
%170 = fdiv double %169, 1.000000e+03
%171 = load double, double* %20
%172 = fadd double %171, %170
store double %172, double* %20
%173 = load double, double* %20
%174 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), double %173)
%175 = load double, double* %20
%176 = load double, double* %21
%177 = fadd double %176, %175
store double %177, double* %21
%178 = call i32 @gettimeofday(%struct.timeval* %18, i32* null)
%179 = load i32, i32* %16
%180 = call i32 @fsync(i32 %179)
%181 = icmp eq i32 %180, -1
br i1 %181, label %182, label %189
182: ; preds = %157
%183 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%184 = load i32, i32* %16
%185 = call i32 @close(i32 %184)
%186 = load i8*, i8** %17
%187 = call i32 @free(i8* %186)
%188 = load i32, i32* @EXIT_FAILURE
store i32 %188, i32* %5
br label %281
189: ; preds = %157
%190 = call i32 @gettimeofday(%struct.timeval* %19, i32* null)
%191 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 0
%192 = load double, double* %191
%193 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 0
%194 = load double, double* %193
%195 = fsub double %192, %194
%196 = fmul double %195, 1.000000e+03
store double %196, double* %20
%197 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 1
%198 = load double, double* %197
%199 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 1
%200 = load double, double* %199
%201 = fsub double %198, %200
%202 = fdiv double %201, 1.000000e+03
%203 = load double, double* %20
%204 = fadd double %203, %202
store double %204, double* %20
%205 = load double, double* %20
%206 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), double %205)
%207 = load double, double* %20
%208 = load double, double* %21
%209 = fadd double %208, %207
store double %209, double* %21
%210 = call i32 @gettimeofday(%struct.timeval* %18, i32* null)
%211 = load i32, i32* %16
%212 = call i32 @close(i32 %211)
%213 = icmp eq i32 %212, -1
br i1 %213, label %214, label %219
214: ; preds = %189
%215 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%216 = load i8*, i8** %17
%217 = call i32 @free(i8* %216)
%218 = load i32, i32* @EXIT_FAILURE
store i32 %218, i32* %5
br label %281
219: ; preds = %189
%220 = call i32 @gettimeofday(%struct.timeval* %19, i32* null)
%221 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 0
%222 = load double, double* %221
%223 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 0
%224 = load double, double* %223
%225 = fsub double %222, %224
%226 = fmul double %225, 1.000000e+03
store double %226, double* %20
%227 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 1
%228 = load double, double* %227
%229 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 1
%230 = load double, double* %229
%231 = fsub double %228, %230
%232 = fdiv double %231, 1.000000e+03
%233 = load double, double* %20
%234 = fadd double %233, %232
store double %234, double* %20
%235 = load double, double* %20
%236 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), double %235)
%237 = load double, double* %20
%238 = load double, double* %21
%239 = fadd double %238, %237
store double %239, double* %21
%240 = call i32 @gettimeofday(%struct.timeval* %18, i32* null)
%241 = call i32 @system(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0))
%242 = icmp eq i32 %241, -1
br i1 %242, label %243, label %248
243: ; preds = %219
%244 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0))
%245 = load i8*, i8** %17
%246 = call i32 @free(i8* %245)
%247 = load i32, i32* @EXIT_FAILURE
store i32 %247, i32* %5
br label %281
248: ; preds = %219
%249 = call i32 @gettimeofday(%struct.timeval* %19, i32* null)
%250 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 0
%251 = load double, double* %250
%252 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 0
%253 = load double, double* %252
%254 = fsub double %251, %253
%255 = fmul double %254, 1.000000e+03
store double %255, double* %20
%256 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 1
%257 = load double, double* %256
%258 = getelementptr inbounds %struct.timeval, %struct.timeval* %18, i32 0, i32 1
%259 = load double, double* %258
%260 = fsub double %257, %259
%261 = fdiv double %260, 1.000000e+03
%262 = load double, double* %20
%263 = fadd double %262, %261
store double %263, double* %20
%264 = load double, double* %20
%265 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0), double %264)
%266 = load double, double* %20
%267 = load double, double* %21
%268 = fadd double %267, %266
store double %268, double* %21
%269 = load i32, i32* %13
%270 = sitofp i32 %269 to double
%271 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.15, i64 0, i64 0), double %270)
%272 = load double, double* %21
%273 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.16, i64 0, i64 0), double %272)
%274 = load double, double* %21
%275 = load i32, i32* %13
%276 = load i32, i32* %7
%277 = call i32 @print_global_performance(double %274, i32 %275, i32 %276)
%278 = load i8*, i8** %17
%279 = call i32 @free(i8* %278)
%280 = load i32, i32* @EXIT_SUCCESS
store i32 %280, i32* %5
br label %281
281: ; preds = %248, %243, %214, %182, %150, %82, %68, %50, %41
%282 = load i32, i32* %5
ret i32 %282
}

LLVM IR (-O2):
%struct.timeval = type { double, double }
@O_WRONLY = global i32 0
@.str = [5 x i8] c"open\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [7 x i8] c"malloc\00"
@.str.2 = [24 x i8] c"generate_random_address\00"
@SEEK_SET = global i32 0
@.str.3 = [6 x i8] c"lseek\00"
@.str.4 = [10 x i8] c"%d\09%f\09%d\0A\00"
@.str.5 = [6 x i8] c"write\00"
@.str.6 = [7 x i8] c"fflush\00"
@.str.7 = [12 x i8] c"#fflush %f\0A\00"
@.str.8 = [6 x i8] c"fsync\00"
@.str.9 = [11 x i8] c"#fsync %f\0A\00"
@.str.10 = [6 x i8] c"close\00"
@.str.11 = [11 x i8] c"#close %f\0A\00"
@.str.12 = [18 x i8] c"umount /mnt/flash\00"
@.str.13 = [7 x i8] c"system\00"
@.str.14 = [12 x i8] c"#umount %f\0A\00"
@.str.15 = [22 x i8] c"#total_size %d Bytes\0A\00"
@.str.16 = [27 x i8] c"#total_time_elapsed %f ms\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @measure_random_synchrounous_write(i8* nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca %struct.timeval
%6 = alloca %struct.timeval
%7 = bitcast %struct.timeval* %5 to i8*
%8 = bitcast %struct.timeval* %6 to i8*
%9 = shl nsw i32 %1, 10
%10 = icmp slt i32 %1, 1
%11 = select i1 %10, i32 65536, i32 %9
%12 = icmp slt i32 %2, 1
%13 = select i1 %12, i32 50, i32 %2
%14 = load i32, i32* @O_WRONLY
%15 = tail call i32 @open(i8* %0, i32 %14)
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %4
%18 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %171
19: ; preds = %4
%20 = tail call i64 @malloc(i32 %11)
%21 = inttoptr i64 %20 to i8*
%22 = icmp eq i64 %20, 0
br i1 %22, label %32, label %23
23: ; preds = %19
%24 = shl nsw i32 %3, 10
%25 = sub nsw i32 %24, %11
%26 = icmp sgt i32 %11, 0
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
%28 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
%29 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
%30 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
%31 = zext i32 %11 to i64
br label %35
32: ; preds = %19
%33 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%34 = tail call i32 @close(i32 %15)
br label %171
35: ; preds = %23, %63
%36 = phi double [ 0.000000e+00, %23 ], [ %73, %63 ]
%37 = phi i32 [ 0, %23 ], [ %74, %63 ]
%38 = phi i32 [ 0, %23 ], [ %77, %63 ]
%39 = tail call i32 @generate_random_address(i32 %25)
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %35
%42 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%43 = tail call i32 @free(i8* %21)
%44 = tail call i32 @close(i32 %15)
br label %171
45: ; preds = %35
%46 = load i32, i32* @SEEK_SET
%47 = tail call i32 @lseek(i32 %15, i32 %39, i32 %46)
%48 = icmp slt i32 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %45
%50 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%51 = tail call i32 @free(i8* %21)
%52 = tail call i32 @close(i32 %15)
br label %171
53: ; preds = %45
%54 = tail call i64 @time(i32* null)
%55 = trunc i64 %54 to i32
%56 = tail call i32 @srand(i32 %55)
br i1 %26, label %57, label %58
57: ; preds = %53
br label %58
58: ; preds = %57, %53
%59 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%60 = tail call i32 @write(i32 %15, i8* %21, i32 %11)
%61 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%62 = icmp sgt i32 %60, 0
br i1 %62, label %63, label %79
63: ; preds = %58
%64 = load double, double* %27
%65 = load double, double* %28
%66 = fsub double %64, %65
%67 = fmul double %66, 1.000000e+03
%68 = load double, double* %29
%69 = load double, double* %30
%70 = fsub double %68, %69
%71 = fdiv double %70, 1.000000e+03
%72 = fadd double %67, %71
%73 = fadd double %36, %72
%74 = add nsw i32 %60, %37
%75 = sitofp i32 %38 to double
%76 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), double %75, double %72, i32 %39)
%77 = add nuw nsw i32 %38, 1
%78 = icmp eq i32 %77, %13
br i1 %78, label %81, label %35
79: ; preds = %58
%80 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %81
81: ; preds = %63, %79
%82 = phi i32 [ %37, %79 ], [ %74, %63 ]
%83 = phi double [ %36, %79 ], [ %73, %63 ]
%84 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%85 = tail call i64 @fflush(i32* null)
%86 = icmp eq i64 %85, 0
br i1 %86, label %91, label %87
87: ; preds = %81
%88 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%89 = tail call i32 @close(i32 %15)
%90 = tail call i32 @free(i8* %21)
br label %171
91: ; preds = %81
%92 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%93 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
%94 = load double, double* %93
%95 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
%96 = load double, double* %95
%97 = fsub double %94, %96
%98 = fmul double %97, 1.000000e+03
%99 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
%100 = load double, double* %99
%101 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
%102 = load double, double* %101
%103 = fsub double %100, %102
%104 = fdiv double %103, 1.000000e+03
%105 = fadd double %98, %104
%106 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), double %105)
%107 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%108 = tail call i32 @fsync(i32 %15)
%109 = icmp eq i32 %108, -1
br i1 %109, label %110, label %114
110: ; preds = %91
%111 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%112 = tail call i32 @close(i32 %15)
%113 = tail call i32 @free(i8* %21)
br label %171
114: ; preds = %91
%115 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%116 = load double, double* %93
%117 = load double, double* %95
%118 = fsub double %116, %117
%119 = fmul double %118, 1.000000e+03
%120 = load double, double* %99
%121 = load double, double* %101
%122 = fsub double %120, %121
%123 = fdiv double %122, 1.000000e+03
%124 = fadd double %119, %123
%125 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), double %124)
%126 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%127 = tail call i32 @close(i32 %15)
%128 = icmp eq i32 %127, -1
br i1 %128, label %129, label %132
129: ; preds = %114
%130 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%131 = tail call i32 @free(i8* %21)
br label %171
132: ; preds = %114
%133 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%134 = load double, double* %93
%135 = load double, double* %95
%136 = fsub double %134, %135
%137 = fmul double %136, 1.000000e+03
%138 = load double, double* %99
%139 = load double, double* %101
%140 = fsub double %138, %139
%141 = fdiv double %140, 1.000000e+03
%142 = fadd double %137, %141
%143 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), double %142)
%144 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%145 = tail call i32 @system(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0))
%146 = icmp eq i32 %145, -1
br i1 %146, label %147, label %150
147: ; preds = %132
%148 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0))
%149 = tail call i32 @free(i8* %21)
br label %171
150: ; preds = %132
%151 = fadd double %83, %105
%152 = fadd double %151, %124
%153 = fadd double %152, %142
%154 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%155 = load double, double* %93
%156 = load double, double* %95
%157 = fsub double %155, %156
%158 = fmul double %157, 1.000000e+03
%159 = load double, double* %99
%160 = load double, double* %101
%161 = fsub double %159, %160
%162 = fdiv double %161, 1.000000e+03
%163 = fadd double %158, %162
%164 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.14, i64 0, i64 0), double %163)
%165 = fadd double %153, %163
%166 = sitofp i32 %82 to double
%167 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.15, i64 0, i64 0), double %166)
%168 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.16, i64 0, i64 0), double %165)
%169 = tail call i32 @print_global_performance(double %165, i32 %82, i32 %1)
%170 = tail call i32 @free(i8* %21)
br label %171
171: ; preds = %150, %147, %129, %110, %87, %49, %41, %32, %17
%172 = phi i32* [ @EXIT_FAILURE, %17 ], [ @EXIT_FAILURE, %32 ], [ @EXIT_FAILURE, %41 ], [ @EXIT_FAILURE, %49 ], [ @EXIT_FAILURE, %87 ], [ @EXIT_FAILURE, %110 ], [ @EXIT_FAILURE, %129 ], [ @EXIT_FAILURE, %147 ], [ @EXIT_SUCCESS, %150 ]
%173 = load i32, i32* %172
ret i32 %173
}