#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct timeval {
  int dummy;
};

/* Variables and functions */
int O_CREAT;
int O_DSYNC;
int O_RDWR;
int /*<<< orphan*/ SEEK_SET;
int S_IRUSR;
int S_IWUSR;
int /*<<< orphan*/ assert(int);
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ die(char *);
int /*<<< orphan*/ fdatasync(int);
int /*<<< orphan*/ free(char *);
scalar_t__ fsync(int);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ malloc(int);
int open(char *, int, int, ...);
int /*<<< orphan*/ print_elapse(struct timeval, struct timeval);
int /*<<< orphan*/ printf(char *, ...);
char random();
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ unlink(char *);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  struct timeval start_t;
  struct timeval stop_t;
  int tmpfile, i, loops = 5000;
  char *full_buf = (char *)malloc(16 << 20), *buf;
  char *filename = "/var/tmp/test_fsync.out";
  if (argc > 2 && strcmp(argv[1], "-f") == 0) {
    filename = argv[2];
    argv += 2;
    argc -= 2;
  }
  if (argc > 1)
    loops = atoi(argv[1]);
  for (i = 0; i < 16 << 20; i++)
    full_buf[i] = random();
  if ((tmpfile = open(filename, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR, 0)) == -1)
    die("Cannot open output file.");
  if (write(tmpfile, full_buf, 16 << 20) != 16 << 20)
    die("write failed");
  if (fsync(tmpfile) != 0)
    die("fsync failed");
  close(tmpfile);
  buf = full_buf;
  if (((intptr_t)full_buf & (4096 - 1)) != 0) {
    buf = (void *)((intptr_t)full_buf & ~(4096 - 1)) + 4096;
  }
  printf("%p %p\n", full_buf, buf);
  assert(((intptr_t)buf & (4096 - 1)) == 0);
  assert(16 << 20 > (8 * 1024));
  printf("Simple 8k write timing:\n");
  gettimeofday(&start_t, NULL);
  for (i = 0; i < loops; i++) {
    if ((tmpfile = open(filename, O_RDWR, 0)) == -1)
      die("Cannot open output file.");
    if (write(tmpfile, buf, (8 * 1024)) != (8 * 1024))
      die("write failed");
    close(tmpfile);
  }
  gettimeofday(&stop_t, NULL);
  printf("\t%-30s", "write");
  print_elapse(start_t, stop_t);
  printf("\nCompare file sync methods using one 8k write:\n");
  if ((tmpfile = open(filename, O_RDWR | O_DSYNC, 0)) == -1)
    die("Cannot open output file.");
  gettimeofday(&start_t, NULL);
  for (i = 0; i < loops; i++) {
    if (write(tmpfile, buf, (8 * 1024)) != (8 * 1024))
      die("write failed");
    if (lseek(tmpfile, 0, SEEK_SET) == -1)
      die("seek failed");
  }
  gettimeofday(&stop_t, NULL);
  close(tmpfile);
  printf("\t%-30s", "open_datasync write");
  print_elapse(start_t, stop_t);
  printf("\t(open_sync unavailable)\n");
  if ((tmpfile = open(filename, O_RDWR, 0)) == -1)
    die("Cannot open output file.");
  gettimeofday(&start_t, NULL);
  for (i = 0; i < loops; i++) {
    if (write(tmpfile, buf, (8 * 1024)) != (8 * 1024))
      die("write failed");
    fdatasync(tmpfile);
    if (lseek(tmpfile, 0, SEEK_SET) == -1)
      die("seek failed");
  }
  gettimeofday(&stop_t, NULL);
  close(tmpfile);
  printf("\t%-30s", "write, fdatasync");
  print_elapse(start_t, stop_t);
  if ((tmpfile = open(filename, O_RDWR, 0)) == -1)
    die("Cannot open output file.");
  gettimeofday(&start_t, NULL);
  for (i = 0; i < loops; i++) {
    if (write(tmpfile, buf, (8 * 1024)) != (8 * 1024))
      die("write failed");
    if (fsync(tmpfile) != 0)
      die("fsync failed");
    if (lseek(tmpfile, 0, SEEK_SET) == -1)
      die("seek failed");
  }
  gettimeofday(&stop_t, NULL);
  close(tmpfile);
  printf("\t%-30s", "write, fsync");
  print_elapse(start_t, stop_t);
  printf("\nCompare file sync methods using two 8k writes:\n");
  if ((tmpfile = open(filename, O_RDWR | O_DSYNC, 0)) == -1)
    die("Cannot open output file.");
  gettimeofday(&start_t, NULL);
  for (i = 0; i < loops; i++) {
    if (write(tmpfile, buf, (8 * 1024)) != (8 * 1024))
      die("write failed");
    if (write(tmpfile, buf, (8 * 1024)) != (8 * 1024))
      die("write failed");
    if (lseek(tmpfile, 0, SEEK_SET) == -1)
      die("seek failed");
  }
  gettimeofday(&stop_t, NULL);
  close(tmpfile);
  printf("\t%-30s", "open_datasync write, write");
  print_elapse(start_t, stop_t);
  if ((tmpfile = open(filename, O_RDWR, 0)) == -1)
    die("Cannot open output file.");
  gettimeofday(&start_t, NULL);
  for (i = 0; i < loops; i++) {
    if (write(tmpfile, buf, (8 * 1024)) != (8 * 1024))
      die("write failed");
    if (write(tmpfile, buf, (8 * 1024)) != (8 * 1024))
      die("write failed");
    fdatasync(tmpfile);
    if (lseek(tmpfile, 0, SEEK_SET) == -1)
      die("seek failed");
  }
  gettimeofday(&stop_t, NULL);
  close(tmpfile);
  printf("\t%-30s", "write, write, fdatasync");
  print_elapse(start_t, stop_t);
  if ((tmpfile = open(filename, O_RDWR, 0)) == -1)
    die("Cannot open output file.");
  gettimeofday(&start_t, NULL);
  for (i = 0; i < loops; i++) {
    if (write(tmpfile, buf, (8 * 1024)) != (8 * 1024))
      die("write failed");
    if (write(tmpfile, buf, (8 * 1024)) != (8 * 1024))
      die("write failed");
    if (fsync(tmpfile) != 0)
      die("fsync failed");
    if (lseek(tmpfile, 0, SEEK_SET) == -1)
      die("seek failed");
  }
  gettimeofday(&stop_t, NULL);
  close(tmpfile);
  printf("\t%-30s", "write, write, fsync");
  print_elapse(start_t, stop_t);
  printf("\nCompare open_sync sizes:\n");
  printf("\t(open_sync unavailable)\n");
  printf("\nCompare fsync times on write() and new file descriptors (if the "
         "times\n");
  printf("are similar, fsync() can sync data written on a different "
         "descriptor):\n");
  gettimeofday(&start_t, NULL);
  for (i = 0; i < loops; i++) {
    if ((tmpfile = open(filename, O_RDWR, 0)) == -1)
      die("Cannot open output file.");
    if (write(tmpfile, buf, (8 * 1024)) != (8 * 1024))
      die("write failed");
    if (fsync(tmpfile) != 0)
      die("fsync failed");
    close(tmpfile);
    if ((tmpfile = open(filename, O_RDWR, 0)) == -1)
      die("Cannot open output file.");
    close(tmpfile);
  }
  gettimeofday(&stop_t, NULL);
  printf("\t%-30s", "write, fsync, close");
  print_elapse(start_t, stop_t);
  gettimeofday(&start_t, NULL);
  for (i = 0; i < loops; i++) {
    if ((tmpfile = open(filename, O_RDWR, 0)) == -1)
      die("Cannot open output file.");
    if (write(tmpfile, buf, (8 * 1024)) != (8 * 1024))
      die("write failed");
    close(tmpfile);
    if ((tmpfile = open(filename, O_RDWR, 0)) == -1)
      die("Cannot open output file.");
    if (fsync(tmpfile) != 0)
      die("fsync failed");
    close(tmpfile);
  }
  gettimeofday(&stop_t, NULL);
  printf("\t%-30s", "write, close, fsync");
  print_elapse(start_t, stop_t);
  free(full_buf);
  unlink(filename);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1388,-0x2c(%rbp)
mov    $0x1000000,%edi
call   10f0 <malloc@plt>
mov    %rax,-0x38(%rbp)
lea    0xdbe(%rip),%rax
mov    %rax,-0x48(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    128f <main+0x7f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdb9(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    128f <main+0x7f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    12a9 <main+0x99>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1130 <atoi@plt>
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x1000000,-0x28(%rbp)
jge    12df <main+0xcf>
mov    $0x0,%al
call   10e0 <random@plt>
mov    %al,%dl
mov    -0x38(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    12b0 <main+0xa0>
mov    -0x48(%rbp),%rdi
mov    0x2cf6(%rip),%rax
mov    (%rax),%esi
mov    0x2d05(%rip),%rax
or     (%rax),%esi
mov    0x2cbc(%rip),%rax
mov    (%rax),%edx
mov    0x2cd3(%rip),%rax
or     (%rax),%edx
xor    %ecx,%ecx
mov    $0x0,%al
call   1110 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    1328 <main+0x118>
lea    0xcf8(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    $0x1000000,%edx
call   1060 <write@plt>
cmp    $0x1000000,%eax
je     1350 <main+0x140>
lea    0xce9(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
call   1100 <fsync@plt>
cmp    $0x0,%rax
je     136e <main+0x15e>
lea    0xcd8(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
call   10a0 <close@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
and    $0xfff,%rax
cmp    $0x0,%rax
je     13a6 <main+0x196>
mov    -0x38(%rbp),%rax
and    $0xfffffffffffff000,%rax
add    $0x1000,%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
lea    0xc99(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x40(%rbp),%rax
and    $0xfff,%rax
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10c0 <assert@plt>
mov    $0x1,%edi
call   10c0 <assert@plt>
lea    0xc6d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    147b <main+0x26b>
mov    -0x48(%rbp),%rdi
mov    0x2bc6(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
mov    $0x0,%al
call   1110 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    143d <main+0x22d>
lea    0xbe3(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    $0x2000,%edx
call   1060 <write@plt>
cmp    $0x2000,%eax
je     1465 <main+0x255>
lea    0xbd4(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
call   10a0 <close@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1403 <main+0x1f3>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
lea    0xbdf(%rip),%rdi
lea    0xc8f(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%esi
call   10d0 <print_elapse@plt>
lea    0xbc6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x48(%rbp),%rdi
mov    0x2b1f(%rip),%rax
mov    (%rax),%esi
mov    0x2afe(%rip),%rax
or     (%rax),%esi
xor    %edx,%edx
mov    $0x0,%al
call   1110 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    14ed <main+0x2dd>
lea    0xb33(%rip),%rdi
call   1120 <die@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1570 <main+0x360>
mov    -0x24(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    $0x2000,%edx
call   1060 <write@plt>
cmp    $0x2000,%eax
je     1535 <main+0x325>
lea    0xb04(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
mov    0x2a81(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <lseek@plt>
cmp    $0xffffffff,%eax
jne    155d <main+0x34d>
lea    0xb4d(%rip),%rdi
call   1120 <die@plt>
jmp    1562 <main+0x352>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1501 <main+0x2f1>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
mov    -0x24(%rbp),%edi
call   10a0 <close@plt>
lea    0xae2(%rip),%rdi
lea    0xb1e(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%esi
call   10d0 <print_elapse@plt>
lea    0xb19(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x48(%rbp),%rdi
mov    0x2a22(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
mov    $0x0,%al
call   1110 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    15e1 <main+0x3d1>
lea    0xa3f(%rip),%rdi
call   1120 <die@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    166c <main+0x45c>
mov    -0x24(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    $0x2000,%edx
call   1060 <write@plt>
cmp    $0x2000,%eax
je     1629 <main+0x419>
lea    0xa10(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
call   1040 <fdatasync@plt>
mov    -0x24(%rbp),%edi
mov    0x2985(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <lseek@plt>
cmp    $0xffffffff,%eax
jne    1659 <main+0x449>
lea    0xa51(%rip),%rdi
call   1120 <die@plt>
jmp    165e <main+0x44e>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    15f5 <main+0x3e5>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
mov    -0x24(%rbp),%edi
call   10a0 <close@plt>
lea    0x9e6(%rip),%rdi
lea    0xaa3(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%esi
call   10d0 <print_elapse@plt>
mov    -0x48(%rbp),%rdi
mov    0x2934(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
mov    $0x0,%al
call   1110 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    16cf <main+0x4bf>
lea    0x951(%rip),%rdi
call   1120 <die@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1770 <main+0x560>
mov    -0x24(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    $0x2000,%edx
call   1060 <write@plt>
cmp    $0x2000,%eax
je     1717 <main+0x507>
lea    0x922(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
call   1100 <fsync@plt>
cmp    $0x0,%rax
je     1735 <main+0x525>
lea    0x911(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
mov    0x2881(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <lseek@plt>
cmp    $0xffffffff,%eax
jne    175d <main+0x54d>
lea    0x94d(%rip),%rdi
call   1120 <die@plt>
jmp    1762 <main+0x552>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    16e3 <main+0x4d3>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
mov    -0x24(%rbp),%edi
call   10a0 <close@plt>
lea    0x8e2(%rip),%rdi
lea    0x9b7(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%esi
call   10d0 <print_elapse@plt>
lea    0x933(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x48(%rbp),%rdi
mov    0x2822(%rip),%rax
mov    (%rax),%esi
mov    0x2801(%rip),%rax
or     (%rax),%esi
xor    %edx,%edx
mov    $0x0,%al
call   1110 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    17ea <main+0x5da>
lea    0x836(%rip),%rdi
call   1120 <die@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1895 <main+0x685>
mov    -0x24(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    $0x2000,%edx
call   1060 <write@plt>
cmp    $0x2000,%eax
je     1832 <main+0x622>
lea    0x807(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    $0x2000,%edx
call   1060 <write@plt>
cmp    $0x2000,%eax
je     185a <main+0x64a>
lea    0x7df(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
mov    0x275c(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <lseek@plt>
cmp    $0xffffffff,%eax
jne    1882 <main+0x672>
lea    0x828(%rip),%rdi
call   1120 <die@plt>
jmp    1887 <main+0x677>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    17fe <main+0x5ee>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
mov    -0x24(%rbp),%edi
call   10a0 <close@plt>
lea    0x7bd(%rip),%rdi
lea    0x858(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%esi
call   10d0 <print_elapse@plt>
mov    -0x48(%rbp),%rdi
mov    0x270b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
mov    $0x0,%al
call   1110 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    18f8 <main+0x6e8>
lea    0x728(%rip),%rdi
call   1120 <die@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    19ab <main+0x79b>
mov    -0x24(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    $0x2000,%edx
call   1060 <write@plt>
cmp    $0x2000,%eax
je     1940 <main+0x730>
lea    0x6f9(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    $0x2000,%edx
call   1060 <write@plt>
cmp    $0x2000,%eax
je     1968 <main+0x758>
lea    0x6d1(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
call   1040 <fdatasync@plt>
mov    -0x24(%rbp),%edi
mov    0x2646(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <lseek@plt>
cmp    $0xffffffff,%eax
jne    1998 <main+0x788>
lea    0x712(%rip),%rdi
call   1120 <die@plt>
jmp    199d <main+0x78d>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    190c <main+0x6fc>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
mov    -0x24(%rbp),%edi
call   10a0 <close@plt>
lea    0x6a7(%rip),%rdi
lea    0x75d(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%esi
call   10d0 <print_elapse@plt>
mov    -0x48(%rbp),%rdi
mov    0x25f5(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
mov    $0x0,%al
call   1110 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    1a0e <main+0x7fe>
lea    0x612(%rip),%rdi
call   1120 <die@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1ad7 <main+0x8c7>
mov    -0x24(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    $0x2000,%edx
call   1060 <write@plt>
cmp    $0x2000,%eax
je     1a56 <main+0x846>
lea    0x5e3(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    $0x2000,%edx
call   1060 <write@plt>
cmp    $0x2000,%eax
je     1a7e <main+0x86e>
lea    0x5bb(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
call   1100 <fsync@plt>
cmp    $0x0,%rax
je     1a9c <main+0x88c>
lea    0x5aa(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
mov    0x251a(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <lseek@plt>
cmp    $0xffffffff,%eax
jne    1ac4 <main+0x8b4>
lea    0x5e6(%rip),%rdi
call   1120 <die@plt>
jmp    1ac9 <main+0x8b9>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1a22 <main+0x812>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
mov    -0x24(%rbp),%edi
call   10a0 <close@plt>
lea    0x57b(%rip),%rdi
lea    0x649(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%esi
call   10d0 <print_elapse@plt>
lea    0x644(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0x5a4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0x643(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0x67d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1c24 <main+0xa14>
mov    -0x48(%rbp),%rdi
mov    0x2471(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
mov    $0x0,%al
call   1110 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    1b92 <main+0x982>
lea    0x48e(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    $0x2000,%edx
call   1060 <write@plt>
cmp    $0x2000,%eax
je     1bba <main+0x9aa>
lea    0x47f(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
call   1100 <fsync@plt>
cmp    $0x0,%rax
je     1bd8 <main+0x9c8>
lea    0x46e(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
call   10a0 <close@plt>
mov    -0x48(%rbp),%rdi
mov    0x23f5(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
mov    $0x0,%al
call   1110 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    1c0e <main+0x9fe>
lea    0x412(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
call   10a0 <close@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1b58 <main+0x948>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
lea    0x436(%rip),%rdi
lea    0x5c3(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%esi
call   10d0 <print_elapse@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1d31 <main+0xb21>
mov    -0x48(%rbp),%rdi
mov    0x2364(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
mov    $0x0,%al
call   1110 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    1c9f <main+0xa8f>
lea    0x381(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    $0x2000,%edx
call   1060 <write@plt>
cmp    $0x2000,%eax
je     1cc7 <main+0xab7>
lea    0x372(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
call   10a0 <close@plt>
mov    -0x48(%rbp),%rdi
mov    0x2306(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
mov    $0x0,%al
call   1110 <open@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    1cfd <main+0xaed>
lea    0x323(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
call   1100 <fsync@plt>
cmp    $0x0,%rax
je     1d1b <main+0xb0b>
lea    0x32b(%rip),%rdi
call   1120 <die@plt>
mov    -0x24(%rbp),%edi
call   10a0 <close@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1c65 <main+0xa55>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <gettimeofday@plt>
lea    0x329(%rip),%rdi
lea    0x4ca(%rip),%rsi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%esi
call   10d0 <print_elapse@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1050 <unlink@plt>
xor    %eax,%eax
add    $0x50,%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,%r14
mov    %edi,%ebx
mov    $0x1000000,%edi
call   1100 <malloc@plt>
mov    %rax,%rbp
cmp    $0x3,%ebx
jl     1263 <main+0x43>
mov    0x8(%r14),%rdi
lea    0xdc8(%rip),%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     126c <main+0x4c>
lea    0xd9f(%rip),%r12
jmp    1282 <main+0x62>
lea    0xd96(%rip),%r12
jmp    1277 <main+0x57>
mov    0x10(%r14),%r12
add    $0x10,%r14
add    $0xfffffffe,%ebx
mov    $0x1388,%r15d
cmp    $0x2,%ebx
jl     128e <main+0x6e>
mov    0x8(%r14),%rdi
call   1140 <atoi@plt>
mov    %eax,%r15d
xor    %ebx,%ebx
xor    %eax,%eax
call   10f0 <random@plt>
mov    %al,0x0(%rbp,%rbx,1)
add    $0x1,%rbx
cmp    $0x1000000,%rbx
jne    1290 <main+0x70>
mov    0x2d31(%rip),%rcx
mov    0x2d42(%rip),%rax
mov    (%rax),%esi
or     (%rcx),%esi
mov    0x2cf7(%rip),%rax
mov    0x2d10(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    %r12,%rdi
xor    %ecx,%ecx
xor    %eax,%eax
call   1120 <open@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    12eb <main+0xcb>
lea    0xd35(%rip),%rdi
call   1130 <die@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x1000000,%edx
call   1070 <write@plt>
cmp    $0x1000000,%eax
je     130d <main+0xed>
lea    0xd2c(%rip),%rdi
call   1130 <die@plt>
mov    %ebx,%edi
call   1110 <fsync@plt>
test   %rax,%rax
je     1325 <main+0x105>
lea    0xd21(%rip),%rdi
call   1130 <die@plt>
mov    %ebx,%edi
call   10b0 <close@plt>
mov    %rbp,%r13
and    $0xfffffffffffff000,%r13
add    $0x1000,%r13
test   $0xfff,%ebp
cmove  %rbp,%r13
lea    0xd00(%rip),%rdi
mov    %rbp,0x20(%rsp)
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1080 <printf@plt>
xor    %edi,%edi
test   $0xfff,%r13d
sete   %dil
call   10d0 <assert@plt>
mov    $0x1,%edi
call   10d0 <assert@plt>
lea    0xd68(%rip),%rdi
call   1060 <puts@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
mov    %r15d,0x14(%rsp)
test   %r15d,%r15d
jle    1410 <main+0x1f0>
lea    0xc76(%rip),%r14
lea    0xc88(%rip),%r15
mov    0x14(%rsp),%ebx
jmp    13cc <main+0x1ac>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edi
call   10b0 <close@plt>
add    $0xffffffff,%ebx
je     1410 <main+0x1f0>
mov    0x2c0d(%rip),%rax
mov    (%rax),%esi
mov    %r12,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1120 <open@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    13f0 <main+0x1d0>
mov    %r14,%rdi
call   1130 <die@plt>
mov    %ebp,%edi
mov    %r13,%rsi
mov    $0x2000,%edx
call   1070 <write@plt>
cmp    $0x2000,%eax
je     13c0 <main+0x1a0>
mov    %r15,%rdi
call   1130 <die@plt>
jmp    13c0 <main+0x1a0>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
lea    0xc32(%rip),%rdi
lea    0xc67(%rip),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x10(%rsp),%edi
mov    0x8(%rsp),%esi
call   10e0 <print_elapse@plt>
lea    0xcbe(%rip),%rdi
call   1060 <puts@plt>
mov    0x2b77(%rip),%rax
mov    (%rax),%esi
mov    0x2b86(%rip),%rax
or     (%rax),%esi
mov    %r12,0x18(%rsp)
mov    %r12,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1120 <open@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    1480 <main+0x260>
lea    0xba0(%rip),%rdi
call   1130 <die@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
cmpl   $0x0,0x14(%rsp)
jle    14fd <main+0x2dd>
mov    0x2b26(%rip),%r12
lea    0xbbb(%rip),%r14
lea    0xb8c(%rip),%r15
mov    0x14(%rsp),%ebx
jmp    14c7 <main+0x2a7>
xchg   %ax,%ax
mov    (%r12),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1090 <lseek@plt>
cmp    $0xffffffff,%eax
je     14f0 <main+0x2d0>
add    $0xffffffff,%ebx
je     14fd <main+0x2dd>
mov    %ebp,%edi
mov    %r13,%rsi
mov    $0x2000,%edx
call   1070 <write@plt>
cmp    $0x2000,%eax
je     14b0 <main+0x290>
mov    %r15,%rdi
call   1130 <die@plt>
jmp    14b0 <main+0x290>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1130 <die@plt>
add    $0xffffffff,%ebx
jne    14c7 <main+0x2a7>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
mov    %ebp,%edi
call   10b0 <close@plt>
lea    0xb3e(%rip),%rdi
lea    0xb4a(%rip),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x10(%rsp),%edi
mov    0x8(%rsp),%esi
call   10e0 <print_elapse@plt>
lea    0xc43(%rip),%rdi
call   1060 <puts@plt>
mov    0x2a9b(%rip),%rax
mov    (%rax),%esi
mov    0x18(%rsp),%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1120 <open@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    1568 <main+0x348>
lea    0xab8(%rip),%rdi
call   1130 <die@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
cmpl   $0x0,0x14(%rsp)
jle    15ed <main+0x3cd>
mov    0x2a3e(%rip),%r12
lea    0xad3(%rip),%r14
lea    0xaa4(%rip),%r15
mov    0x14(%rsp),%ebx
jmp    15be <main+0x39e>
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1040 <fdatasync@plt>
mov    (%r12),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1090 <lseek@plt>
cmp    $0xffffffff,%eax
je     15e0 <main+0x3c0>
add    $0xffffffff,%ebx
je     15ed <main+0x3cd>
mov    %ebp,%edi
mov    %r13,%rsi
mov    $0x2000,%edx
call   1070 <write@plt>
cmp    $0x2000,%eax
je     15a0 <main+0x380>
mov    %r15,%rdi
call   1130 <die@plt>
jmp    15a0 <main+0x380>
xchg   %ax,%ax
mov    %r14,%rdi
call   1130 <die@plt>
add    $0xffffffff,%ebx
jne    15be <main+0x39e>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
mov    %ebp,%edi
call   10b0 <close@plt>
lea    0xa4e(%rip),%rdi
lea    0xa90(%rip),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x10(%rsp),%edi
mov    0x8(%rsp),%esi
call   10e0 <print_elapse@plt>
mov    0x29b7(%rip),%rax
mov    (%rax),%esi
mov    0x18(%rsp),%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1120 <open@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    164c <main+0x42c>
lea    0x9d4(%rip),%rdi
call   1130 <die@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
cmpl   $0x0,0x14(%rsp)
jle    16d7 <main+0x4b7>
mov    0x295a(%rip),%r12
lea    0x9d4(%rip),%r15
lea    0x9c0(%rip),%r14
mov    0x14(%rsp),%ebx
jmp    1685 <main+0x465>
nopw   0x0(%rax,%rax,1)
add    $0xffffffff,%ebx
je     16d7 <main+0x4b7>
mov    %ebp,%edi
mov    %r13,%rsi
mov    $0x2000,%edx
call   1070 <write@plt>
cmp    $0x2000,%eax
je     16a3 <main+0x483>
mov    %r14,%rdi
call   1130 <die@plt>
mov    %ebp,%edi
call   1110 <fsync@plt>
test   %rax,%rax
je     16b7 <main+0x497>
mov    %r15,%rdi
call   1130 <die@plt>
mov    (%r12),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1090 <lseek@plt>
cmp    $0xffffffff,%eax
jne    1680 <main+0x460>
lea    0x98c(%rip),%rdi
call   1130 <die@plt>
jmp    1680 <main+0x460>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
mov    %ebp,%edi
call   10b0 <close@plt>
lea    0x964(%rip),%rdi
lea    0x9be(%rip),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x10(%rsp),%edi
mov    0x8(%rsp),%esi
call   10e0 <print_elapse@plt>
lea    0xa1f(%rip),%rdi
call   1060 <puts@plt>
mov    0x28a9(%rip),%rax
mov    (%rax),%esi
mov    0x28b8(%rip),%rax
or     (%rax),%esi
mov    0x18(%rsp),%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1120 <open@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    174b <main+0x52b>
lea    0x8d5(%rip),%rdi
call   1130 <die@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
cmpl   $0x0,0x14(%rsp)
jle    17ed <main+0x5cd>
mov    0x2857(%rip),%r15
lea    0x8ec(%rip),%r14
lea    0x8bd(%rip),%r12
mov    0x14(%rsp),%ebx
jmp    1796 <main+0x576>
nopl   (%rax)
mov    (%r15),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1090 <lseek@plt>
cmp    $0xffffffff,%eax
je     17e0 <main+0x5c0>
add    $0xffffffff,%ebx
je     17ed <main+0x5cd>
mov    %ebp,%edi
mov    %r13,%rsi
mov    $0x2000,%edx
call   1070 <write@plt>
cmp    $0x2000,%eax
je     17b4 <main+0x594>
mov    %r12,%rdi
call   1130 <die@plt>
mov    %ebp,%edi
mov    %r13,%rsi
mov    $0x2000,%edx
call   1070 <write@plt>
cmp    $0x2000,%eax
je     1780 <main+0x560>
mov    %r12,%rdi
call   1130 <die@plt>
jmp    1780 <main+0x560>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1130 <die@plt>
add    $0xffffffff,%ebx
jne    1796 <main+0x576>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
mov    %ebp,%edi
call   10b0 <close@plt>
lea    0x84e(%rip),%rdi
lea    0x86e(%rip),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x10(%rsp),%edi
mov    0x8(%rsp),%esi
call   10e0 <print_elapse@plt>
mov    0x27b7(%rip),%rax
mov    (%rax),%esi
mov    0x18(%rsp),%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1120 <open@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    184c <main+0x62c>
lea    0x7d4(%rip),%rdi
call   1130 <die@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
cmpl   $0x0,0x14(%rsp)
jle    18ed <main+0x6cd>
mov    0x2756(%rip),%r15
lea    0x7eb(%rip),%r14
lea    0x7bc(%rip),%r12
mov    0x14(%rsp),%ebx
jmp    189d <main+0x67d>
xchg   %ax,%ax
mov    %ebp,%edi
call   1040 <fdatasync@plt>
mov    (%r15),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1090 <lseek@plt>
cmp    $0xffffffff,%eax
je     18e0 <main+0x6c0>
add    $0xffffffff,%ebx
je     18ed <main+0x6cd>
mov    %ebp,%edi
mov    %r13,%rsi
mov    $0x2000,%edx
call   1070 <write@plt>
cmp    $0x2000,%eax
je     18bb <main+0x69b>
mov    %r12,%rdi
call   1130 <die@plt>
mov    %ebp,%edi
mov    %r13,%rsi
mov    $0x2000,%edx
call   1070 <write@plt>
cmp    $0x2000,%eax
je     1880 <main+0x660>
mov    %r12,%rdi
call   1130 <die@plt>
jmp    1880 <main+0x660>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1130 <die@plt>
add    $0xffffffff,%ebx
jne    189d <main+0x67d>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
mov    %ebp,%edi
call   10b0 <close@plt>
lea    0x74e(%rip),%rdi
lea    0x789(%rip),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x10(%rsp),%edi
mov    0x8(%rsp),%esi
call   10e0 <print_elapse@plt>
mov    0x26b7(%rip),%rax
mov    (%rax),%esi
mov    0x18(%rsp),%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1120 <open@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    194c <main+0x72c>
lea    0x6d4(%rip),%rdi
call   1130 <die@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
cmpl   $0x0,0x14(%rsp)
jle    19f6 <main+0x7d6>
mov    0x2656(%rip),%r12
lea    0x6d0(%rip),%rbx
lea    0x6bc(%rip),%r14
mov    0x14(%rsp),%r15d
jmp    1986 <main+0x766>
nop
add    $0xffffffff,%r15d
je     19f6 <main+0x7d6>
mov    %ebp,%edi
mov    %r13,%rsi
mov    $0x2000,%edx
call   1070 <write@plt>
cmp    $0x2000,%eax
je     19a4 <main+0x784>
mov    %r14,%rdi
call   1130 <die@plt>
mov    %ebp,%edi
mov    %r13,%rsi
mov    $0x2000,%edx
call   1070 <write@plt>
cmp    $0x2000,%eax
je     19c2 <main+0x7a2>
mov    %r14,%rdi
call   1130 <die@plt>
mov    %ebp,%edi
call   1110 <fsync@plt>
test   %rax,%rax
je     19d6 <main+0x7b6>
mov    %rbx,%rdi
call   1130 <die@plt>
mov    (%r12),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1090 <lseek@plt>
cmp    $0xffffffff,%eax
jne    1980 <main+0x760>
lea    0x66d(%rip),%rdi
call   1130 <die@plt>
jmp    1980 <main+0x760>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
mov    %ebp,%edi
call   10b0 <close@plt>
lea    0x645(%rip),%rdi
lea    0x698(%rip),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x10(%rsp),%edi
mov    0x8(%rsp),%esi
call   10e0 <print_elapse@plt>
lea    0x730(%rip),%rdi
call   1060 <puts@plt>
lea    0x73e(%rip),%rdi
call   1060 <puts@plt>
lea    0x74b(%rip),%rdi
call   1060 <puts@plt>
lea    0x786(%rip),%rdi
call   1060 <puts@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
mov    0x14(%rsp),%r12d
test   %r12d,%r12d
jle    1c37 <main+0xa17>
lea    0x59f(%rip),%rbx
mov    0x20(%rsp),%r15
jmp    1aa1 <main+0x881>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%edi
call   10b0 <close@plt>
add    $0xffffffff,%r12d
je     1b3b <main+0x91b>
mov    0x2538(%rip),%rax
mov    (%rax),%esi
mov    0x18(%rsp),%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1120 <open@plt>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
jne    1ac8 <main+0x8a8>
mov    %rbx,%rdi
call   1130 <die@plt>
mov    %r14d,%edi
mov    %r13,%rsi
mov    $0x2000,%edx
call   1070 <write@plt>
cmp    $0x2000,%eax
je     1aeb <main+0x8cb>
lea    0x54e(%rip),%rdi
call   1130 <die@plt>
mov    %r14d,%edi
call   1110 <fsync@plt>
test   %rax,%rax
je     1b04 <main+0x8e4>
lea    0x542(%rip),%rdi
call   1130 <die@plt>
mov    %r14d,%edi
call   10b0 <close@plt>
mov    0x24cd(%rip),%rax
mov    (%rax),%esi
mov    0x18(%rsp),%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1120 <open@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    1a90 <main+0x870>
mov    %rbx,%rdi
call   1130 <die@plt>
jmp    1a90 <main+0x870>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
lea    0x507(%rip),%rdi
lea    0x56e(%rip),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x10(%rsp),%edi
mov    0x8(%rsp),%esi
call   10e0 <print_elapse@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
cmpl   $0x0,0x14(%rsp)
mov    0x18(%rsp),%rbx
jle    1c7b <main+0xa5b>
lea    0x48f(%rip),%r12
jmp    1ba2 <main+0x982>
xchg   %ax,%ax
mov    %ebp,%edi
call   10b0 <close@plt>
addl   $0xffffffff,0x14(%rsp)
je     1c7b <main+0xa5b>
mov    0x2437(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1120 <open@plt>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
jne    1bc7 <main+0x9a7>
mov    %r12,%rdi
call   1130 <die@plt>
mov    %r14d,%edi
mov    %r13,%rsi
mov    $0x2000,%edx
call   1070 <write@plt>
cmp    $0x2000,%eax
je     1bea <main+0x9ca>
lea    0x44f(%rip),%rdi
call   1130 <die@plt>
mov    %r14d,%edi
call   10b0 <close@plt>
mov    0x23e7(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1120 <open@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    1c16 <main+0x9f6>
mov    %r12,%rdi
call   1130 <die@plt>
mov    %ebp,%edi
call   1110 <fsync@plt>
test   %rax,%rax
je     1b90 <main+0x970>
lea    0x414(%rip),%rdi
call   1130 <die@plt>
jmp    1b90 <main+0x970>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
lea    0x40b(%rip),%rdi
lea    0x472(%rip),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x10(%rsp),%edi
mov    0x8(%rsp),%esi
call   10e0 <print_elapse@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
mov    0x20(%rsp),%r15
mov    0x18(%rsp),%rbx
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
lea    0x3c7(%rip),%rdi
lea    0x442(%rip),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x10(%rsp),%edi
mov    0x8(%rsp),%esi
call   10e0 <print_elapse@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1050 <unlink@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 { i32 }
@.str = [24 x i8] c"/var/tmp/test_fsync.out\00"
@.str.1 = [3 x i8] c"-f\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.2 = [25 x i8] c"Cannot open output file.\00"
@.str.3 = [13 x i8] c"write failed\00"
@.str.4 = [13 x i8] c"fsync failed\00"
@.str.5 = [7 x i8] c"%p %p\0A\00"
@.str.6 = [25 x i8] c"Simple 8k write timing:\0A\00"
@.str.7 = [7 x i8] c"\09%-30s\00"
@.str.8 = [6 x i8] c"write\00"
@.str.9 = [48 x i8] c"\0ACompare file sync methods using one 8k write:\0A\00"
@O_DSYNC = global i32 0
@SEEK_SET = global i32 0
@.str.10 = [12 x i8] c"seek failed\00"
@.str.11 = [20 x i8] c"open_datasync write\00"
@.str.12 = [26 x i8] c"\09(open_sync unavailable)\0A\00"
@.str.13 = [17 x i8] c"write, fdatasync\00"
@.str.14 = [13 x i8] c"write, fsync\00"
@.str.15 = [49 x i8] c"\0ACompare file sync methods using two 8k writes:\0A\00"
@.str.16 = [27 x i8] c"open_datasync write, write\00"
@.str.17 = [24 x i8] c"write, write, fdatasync\00"
@.str.18 = [20 x i8] c"write, write, fsync\00"
@.str.19 = [27 x i8] c"\0ACompare open_sync sizes:\0A\00"
@.str.20 = [72 x i8] c"\0ACompare fsync times on write() and new file descriptors (if the times\0A\00"
@.str.21 = [72 x i8] c"are similar, fsync() can sync data written on a different descriptor):\0A\00"
@.str.22 = [20 x i8] c"write, fsync, close\00"
@.str.23 = [20 x i8] c"write, close, fsync\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 5000, i32* %10
%14 = call i64 @malloc(i32 16777216)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %11
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8** %13
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 2
br i1 %17, label %18, label %32
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %18
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
store i8* %27, i8** %13
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
store i8** %29, i8*** %5
%30 = load i32, i32* %4
%31 = sub nsw i32 %30, 2
store i32 %31, i32* %4
br label %32
32: ; preds = %24, %18, %2
%33 = load i32, i32* %4
%34 = icmp sgt i32 %33, 1
br i1 %34, label %35, label %40
35: ; preds = %32
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 @atoi(i8* %38)
store i32 %39, i32* %10
br label %40
40: ; preds = %35, %32
store i32 0, i32* %9
br label %41
41: ; preds = %50, %40
%42 = load i32, i32* %9
%43 = icmp slt i32 %42, 16777216
br i1 %43, label %44, label %53
44: ; preds = %41
%45 = call signext i8 (...) @random()
%46 = load i8*, i8** %11
%47 = load i32, i32* %9
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
store i8 %45, i8* %49
br label %50
50: ; preds = %44
%51 = load i32, i32* %9
%52 = add nsw i32 %51, 1
store i32 %52, i32* %9
br label %41
53: ; preds = %41
%54 = load i8*, i8** %13
%55 = load i32, i32* @O_RDWR
%56 = load i32, i32* @O_CREAT
%57 = or i32 %55, %56
%58 = load i32, i32* @S_IRUSR
%59 = load i32, i32* @S_IWUSR
%60 = or i32 %58, %59
%61 = call i32 (i8*, i32, i32, ...) @open(i8* %54, i32 %57, i32 %60, i32 0)
store i32 %61, i32* %8
%62 = icmp eq i32 %61, -1
br i1 %62, label %63, label %65
63: ; preds = %53
%64 = call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %65
65: ; preds = %63, %53
%66 = load i32, i32* %8
%67 = load i8*, i8** %11
%68 = call i32 @write(i32 %66, i8* %67, i32 16777216)
%69 = icmp ne i32 %68, 16777216
br i1 %69, label %70, label %72
70: ; preds = %65
%71 = call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %72
72: ; preds = %70, %65
%73 = load i32, i32* %8
%74 = call i64 @fsync(i32 %73)
%75 = icmp ne i64 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %72
%77 = call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %78
78: ; preds = %76, %72
%79 = load i32, i32* %8
%80 = call i32 @close(i32 %79)
%81 = load i8*, i8** %11
store i8* %81, i8** %12
%82 = load i8*, i8** %11
%83 = ptrtoint i8* %82 to i64
%84 = and i64 %83, 4095
%85 = icmp ne i64 %84, 0
br i1 %85, label %86, label %92
86: ; preds = %78
%87 = load i8*, i8** %11
%88 = ptrtoint i8* %87 to i64
%89 = and i64 %88, -4096
%90 = inttoptr i64 %89 to i8*
%91 = getelementptr i8, i8* %90, i64 4096
store i8* %91, i8** %12
br label %92
92: ; preds = %86, %78
%93 = load i8*, i8** %11
%94 = load i8*, i8** %12
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %93, i8* %94)
%96 = load i8*, i8** %12
%97 = ptrtoint i8* %96 to i64
%98 = and i64 %97, 4095
%99 = icmp eq i64 %98, 0
%100 = zext i1 %99 to i32
%101 = call i32 @assert(i32 %100)
%102 = call i32 @assert(i32 1)
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%104 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
store i32 0, i32* %9
br label %105
105: ; preds = %126, %92
%106 = load i32, i32* %9
%107 = load i32, i32* %10
%108 = icmp slt i32 %106, %107
br i1 %108, label %109, label %129
109: ; preds = %105
%110 = load i8*, i8** %13
%111 = load i32, i32* @O_RDWR
%112 = call i32 (i8*, i32, i32, ...) @open(i8* %110, i32 %111, i32 0)
store i32 %112, i32* %8
%113 = icmp eq i32 %112, -1
br i1 %113, label %114, label %116
114: ; preds = %109
%115 = call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %116
116: ; preds = %114, %109
%117 = load i32, i32* %8
%118 = load i8*, i8** %12
%119 = call i32 @write(i32 %117, i8* %118, i32 8192)
%120 = icmp ne i32 %119, 8192
br i1 %120, label %121, label %123
121: ; preds = %116
%122 = call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %123
123: ; preds = %121, %116
%124 = load i32, i32* %8
%125 = call i32 @close(i32 %124)
br label %126
126: ; preds = %123
%127 = load i32, i32* %9
%128 = add nsw i32 %127, 1
store i32 %128, i32* %9
br label %105
129: ; preds = %105
%130 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%132 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%133 = load i32, i32* %132
%134 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%135 = load i32, i32* %134
%136 = call i32 @print_elapse(i32 %133, i32 %135)
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.9, i64 0, i64 0))
%138 = load i8*, i8** %13
%139 = load i32, i32* @O_RDWR
%140 = load i32, i32* @O_DSYNC
%141 = or i32 %139, %140
%142 = call i32 (i8*, i32, i32, ...) @open(i8* %138, i32 %141, i32 0)
store i32 %142, i32* %8
%143 = icmp eq i32 %142, -1
br i1 %143, label %144, label %146
144: ; preds = %129
%145 = call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %146
146: ; preds = %144, %129
%147 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
store i32 0, i32* %9
br label %148
148: ; preds = %167, %146
%149 = load i32, i32* %9
%150 = load i32, i32* %10
%151 = icmp slt i32 %149, %150
br i1 %151, label %152, label %170
152: ; preds = %148
%153 = load i32, i32* %8
%154 = load i8*, i8** %12
%155 = call i32 @write(i32 %153, i8* %154, i32 8192)
%156 = icmp ne i32 %155, 8192
br i1 %156, label %157, label %159
157: ; preds = %152
%158 = call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %159
159: ; preds = %157, %152
%160 = load i32, i32* %8
%161 = load i32, i32* @SEEK_SET
%162 = call i32 @lseek(i32 %160, i32 0, i32 %161)
%163 = icmp eq i32 %162, -1
br i1 %163, label %164, label %166
164: ; preds = %159
%165 = call i32 @die(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %166
166: ; preds = %164, %159
br label %167
167: ; preds = %166
%168 = load i32, i32* %9
%169 = add nsw i32 %168, 1
store i32 %169, i32* %9
br label %148
170: ; preds = %148
%171 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%172 = load i32, i32* %8
%173 = call i32 @close(i32 %172)
%174 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0))
%175 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%176 = load i32, i32* %175
%177 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%178 = load i32, i32* %177
%179 = call i32 @print_elapse(i32 %176, i32 %178)
%180 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0))
%181 = load i8*, i8** %13
%182 = load i32, i32* @O_RDWR
%183 = call i32 (i8*, i32, i32, ...) @open(i8* %181, i32 %182, i32 0)
store i32 %183, i32* %8
%184 = icmp eq i32 %183, -1
br i1 %184, label %185, label %187
185: ; preds = %170
%186 = call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %187
187: ; preds = %185, %170
%188 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
store i32 0, i32* %9
br label %189
189: ; preds = %210, %187
%190 = load i32, i32* %9
%191 = load i32, i32* %10
%192 = icmp slt i32 %190, %191
br i1 %192, label %193, label %213
193: ; preds = %189
%194 = load i32, i32* %8
%195 = load i8*, i8** %12
%196 = call i32 @write(i32 %194, i8* %195, i32 8192)
%197 = icmp ne i32 %196, 8192
br i1 %197, label %198, label %200
198: ; preds = %193
%199 = call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %200
200: ; preds = %198, %193
%201 = load i32, i32* %8
%202 = call i32 @fdatasync(i32 %201)
%203 = load i32, i32* %8
%204 = load i32, i32* @SEEK_SET
%205 = call i32 @lseek(i32 %203, i32 0, i32 %204)
%206 = icmp eq i32 %205, -1
br i1 %206, label %207, label %209
207: ; preds = %200
%208 = call i32 @die(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %209
209: ; preds = %207, %200
br label %210
210: ; preds = %209
%211 = load i32, i32* %9
%212 = add nsw i32 %211, 1
store i32 %212, i32* %9
br label %189
213: ; preds = %189
%214 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%215 = load i32, i32* %8
%216 = call i32 @close(i32 %215)
%217 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0))
%218 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%219 = load i32, i32* %218
%220 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%221 = load i32, i32* %220
%222 = call i32 @print_elapse(i32 %219, i32 %221)
%223 = load i8*, i8** %13
%224 = load i32, i32* @O_RDWR
%225 = call i32 (i8*, i32, i32, ...) @open(i8* %223, i32 %224, i32 0)
store i32 %225, i32* %8
%226 = icmp eq i32 %225, -1
br i1 %226, label %227, label %229
227: ; preds = %213
%228 = call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %229
229: ; preds = %227, %213
%230 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
store i32 0, i32* %9
br label %231
231: ; preds = %256, %229
%232 = load i32, i32* %9
%233 = load i32, i32* %10
%234 = icmp slt i32 %232, %233
br i1 %234, label %235, label %259
235: ; preds = %231
%236 = load i32, i32* %8
%237 = load i8*, i8** %12
%238 = call i32 @write(i32 %236, i8* %237, i32 8192)
%239 = icmp ne i32 %238, 8192
br i1 %239, label %240, label %242
240: ; preds = %235
%241 = call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %242
242: ; preds = %240, %235
%243 = load i32, i32* %8
%244 = call i64 @fsync(i32 %243)
%245 = icmp ne i64 %244, 0
br i1 %245, label %246, label %248
246: ; preds = %242
%247 = call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %248
248: ; preds = %246, %242
%249 = load i32, i32* %8
%250 = load i32, i32* @SEEK_SET
%251 = call i32 @lseek(i32 %249, i32 0, i32 %250)
%252 = icmp eq i32 %251, -1
br i1 %252, label %253, label %255
253: ; preds = %248
%254 = call i32 @die(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %255
255: ; preds = %253, %248
br label %256
256: ; preds = %255
%257 = load i32, i32* %9
%258 = add nsw i32 %257, 1
store i32 %258, i32* %9
br label %231
259: ; preds = %231
%260 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%261 = load i32, i32* %8
%262 = call i32 @close(i32 %261)
%263 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0))
%264 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%265 = load i32, i32* %264
%266 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%267 = load i32, i32* %266
%268 = call i32 @print_elapse(i32 %265, i32 %267)
%269 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.15, i64 0, i64 0))
%270 = load i8*, i8** %13
%271 = load i32, i32* @O_RDWR
%272 = load i32, i32* @O_DSYNC
%273 = or i32 %271, %272
%274 = call i32 (i8*, i32, i32, ...) @open(i8* %270, i32 %273, i32 0)
store i32 %274, i32* %8
%275 = icmp eq i32 %274, -1
br i1 %275, label %276, label %278
276: ; preds = %259
%277 = call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %278
278: ; preds = %276, %259
%279 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
store i32 0, i32* %9
br label %280
280: ; preds = %306, %278
%281 = load i32, i32* %9
%282 = load i32, i32* %10
%283 = icmp slt i32 %281, %282
br i1 %283, label %284, label %309
284: ; preds = %280
%285 = load i32, i32* %8
%286 = load i8*, i8** %12
%287 = call i32 @write(i32 %285, i8* %286, i32 8192)
%288 = icmp ne i32 %287, 8192
br i1 %288, label %289, label %291
289: ; preds = %284
%290 = call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %291
291: ; preds = %289, %284
%292 = load i32, i32* %8
%293 = load i8*, i8** %12
%294 = call i32 @write(i32 %292, i8* %293, i32 8192)
%295 = icmp ne i32 %294, 8192
br i1 %295, label %296, label %298
296: ; preds = %291
%297 = call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %298
298: ; preds = %296, %291
%299 = load i32, i32* %8
%300 = load i32, i32* @SEEK_SET
%301 = call i32 @lseek(i32 %299, i32 0, i32 %300)
%302 = icmp eq i32 %301, -1
br i1 %302, label %303, label %305
303: ; preds = %298
%304 = call i32 @die(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %305
305: ; preds = %303, %298
br label %306
306: ; preds = %305
%307 = load i32, i32* %9
%308 = add nsw i32 %307, 1
store i32 %308, i32* %9
br label %280
309: ; preds = %280
%310 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%311 = load i32, i32* %8
%312 = call i32 @close(i32 %311)
%313 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.16, i64 0, i64 0))
%314 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%315 = load i32, i32* %314
%316 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%317 = load i32, i32* %316
%318 = call i32 @print_elapse(i32 %315, i32 %317)
%319 = load i8*, i8** %13
%320 = load i32, i32* @O_RDWR
%321 = call i32 (i8*, i32, i32, ...) @open(i8* %319, i32 %320, i32 0)
store i32 %321, i32* %8
%322 = icmp eq i32 %321, -1
br i1 %322, label %323, label %325
323: ; preds = %309
%324 = call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %325
325: ; preds = %323, %309
%326 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
store i32 0, i32* %9
br label %327
327: ; preds = %355, %325
%328 = load i32, i32* %9
%329 = load i32, i32* %10
%330 = icmp slt i32 %328, %329
br i1 %330, label %331, label %358
331: ; preds = %327
%332 = load i32, i32* %8
%333 = load i8*, i8** %12
%334 = call i32 @write(i32 %332, i8* %333, i32 8192)
%335 = icmp ne i32 %334, 8192
br i1 %335, label %336, label %338
336: ; preds = %331
%337 = call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %338
338: ; preds = %336, %331
%339 = load i32, i32* %8
%340 = load i8*, i8** %12
%341 = call i32 @write(i32 %339, i8* %340, i32 8192)
%342 = icmp ne i32 %341, 8192
br i1 %342, label %343, label %345
343: ; preds = %338
%344 = call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %345
345: ; preds = %343, %338
%346 = load i32, i32* %8
%347 = call i32 @fdatasync(i32 %346)
%348 = load i32, i32* %8
%349 = load i32, i32* @SEEK_SET
%350 = call i32 @lseek(i32 %348, i32 0, i32 %349)
%351 = icmp eq i32 %350, -1
br i1 %351, label %352, label %354
352: ; preds = %345
%353 = call i32 @die(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %354
354: ; preds = %352, %345
br label %355
355: ; preds = %354
%356 = load i32, i32* %9
%357 = add nsw i32 %356, 1
store i32 %357, i32* %9
br label %327
358: ; preds = %327
%359 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%360 = load i32, i32* %8
%361 = call i32 @close(i32 %360)
%362 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.17, i64 0, i64 0))
%363 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%364 = load i32, i32* %363
%365 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%366 = load i32, i32* %365
%367 = call i32 @print_elapse(i32 %364, i32 %366)
%368 = load i8*, i8** %13
%369 = load i32, i32* @O_RDWR
%370 = call i32 (i8*, i32, i32, ...) @open(i8* %368, i32 %369, i32 0)
store i32 %370, i32* %8
%371 = icmp eq i32 %370, -1
br i1 %371, label %372, label %374
372: ; preds = %358
%373 = call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %374
374: ; preds = %372, %358
%375 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
store i32 0, i32* %9
br label %376
376: ; preds = %408, %374
%377 = load i32, i32* %9
%378 = load i32, i32* %10
%379 = icmp slt i32 %377, %378
br i1 %379, label %380, label %411
380: ; preds = %376
%381 = load i32, i32* %8
%382 = load i8*, i8** %12
%383 = call i32 @write(i32 %381, i8* %382, i32 8192)
%384 = icmp ne i32 %383, 8192
br i1 %384, label %385, label %387
385: ; preds = %380
%386 = call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %387
387: ; preds = %385, %380
%388 = load i32, i32* %8
%389 = load i8*, i8** %12
%390 = call i32 @write(i32 %388, i8* %389, i32 8192)
%391 = icmp ne i32 %390, 8192
br i1 %391, label %392, label %394
392: ; preds = %387
%393 = call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %394
394: ; preds = %392, %387
%395 = load i32, i32* %8
%396 = call i64 @fsync(i32 %395)
%397 = icmp ne i64 %396, 0
br i1 %397, label %398, label %400
398: ; preds = %394
%399 = call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %400
400: ; preds = %398, %394
%401 = load i32, i32* %8
%402 = load i32, i32* @SEEK_SET
%403 = call i32 @lseek(i32 %401, i32 0, i32 %402)
%404 = icmp eq i32 %403, -1
br i1 %404, label %405, label %407
405: ; preds = %400
%406 = call i32 @die(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %407
407: ; preds = %405, %400
br label %408
408: ; preds = %407
%409 = load i32, i32* %9
%410 = add nsw i32 %409, 1
store i32 %410, i32* %9
br label %376
411: ; preds = %376
%412 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%413 = load i32, i32* %8
%414 = call i32 @close(i32 %413)
%415 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.18, i64 0, i64 0))
%416 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%417 = load i32, i32* %416
%418 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%419 = load i32, i32* %418
%420 = call i32 @print_elapse(i32 %417, i32 %419)
%421 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.19, i64 0, i64 0))
%422 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0))
%423 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.20, i64 0, i64 0))
%424 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.21, i64 0, i64 0))
%425 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
store i32 0, i32* %9
br label %426
426: ; preds = %462, %411
%427 = load i32, i32* %9
%428 = load i32, i32* %10
%429 = icmp slt i32 %427, %428
br i1 %429, label %430, label %465
430: ; preds = %426
%431 = load i8*, i8** %13
%432 = load i32, i32* @O_RDWR
%433 = call i32 (i8*, i32, i32, ...) @open(i8* %431, i32 %432, i32 0)
store i32 %433, i32* %8
%434 = icmp eq i32 %433, -1
br i1 %434, label %435, label %437
435: ; preds = %430
%436 = call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %437
437: ; preds = %435, %430
%438 = load i32, i32* %8
%439 = load i8*, i8** %12
%440 = call i32 @write(i32 %438, i8* %439, i32 8192)
%441 = icmp ne i32 %440, 8192
br i1 %441, label %442, label %444
442: ; preds = %437
%443 = call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %444
444: ; preds = %442, %437
%445 = load i32, i32* %8
%446 = call i64 @fsync(i32 %445)
%447 = icmp ne i64 %446, 0
br i1 %447, label %448, label %450
448: ; preds = %444
%449 = call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %450
450: ; preds = %448, %444
%451 = load i32, i32* %8
%452 = call i32 @close(i32 %451)
%453 = load i8*, i8** %13
%454 = load i32, i32* @O_RDWR
%455 = call i32 (i8*, i32, i32, ...) @open(i8* %453, i32 %454, i32 0)
store i32 %455, i32* %8
%456 = icmp eq i32 %455, -1
br i1 %456, label %457, label %459
457: ; preds = %450
%458 = call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %459
459: ; preds = %457, %450
%460 = load i32, i32* %8
%461 = call i32 @close(i32 %460)
br label %462
462: ; preds = %459
%463 = load i32, i32* %9
%464 = add nsw i32 %463, 1
store i32 %464, i32* %9
br label %426
465: ; preds = %426
%466 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%467 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.22, i64 0, i64 0))
%468 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%469 = load i32, i32* %468
%470 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%471 = load i32, i32* %470
%472 = call i32 @print_elapse(i32 %469, i32 %471)
%473 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
store i32 0, i32* %9
br label %474
474: ; preds = %510, %465
%475 = load i32, i32* %9
%476 = load i32, i32* %10
%477 = icmp slt i32 %475, %476
br i1 %477, label %478, label %513
478: ; preds = %474
%479 = load i8*, i8** %13
%480 = load i32, i32* @O_RDWR
%481 = call i32 (i8*, i32, i32, ...) @open(i8* %479, i32 %480, i32 0)
store i32 %481, i32* %8
%482 = icmp eq i32 %481, -1
br i1 %482, label %483, label %485
483: ; preds = %478
%484 = call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %485
485: ; preds = %483, %478
%486 = load i32, i32* %8
%487 = load i8*, i8** %12
%488 = call i32 @write(i32 %486, i8* %487, i32 8192)
%489 = icmp ne i32 %488, 8192
br i1 %489, label %490, label %492
490: ; preds = %485
%491 = call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %492
492: ; preds = %490, %485
%493 = load i32, i32* %8
%494 = call i32 @close(i32 %493)
%495 = load i8*, i8** %13
%496 = load i32, i32* @O_RDWR
%497 = call i32 (i8*, i32, i32, ...) @open(i8* %495, i32 %496, i32 0)
store i32 %497, i32* %8
%498 = icmp eq i32 %497, -1
br i1 %498, label %499, label %501
499: ; preds = %492
%500 = call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %501
501: ; preds = %499, %492
%502 = load i32, i32* %8
%503 = call i64 @fsync(i32 %502)
%504 = icmp ne i64 %503, 0
br i1 %504, label %505, label %507
505: ; preds = %501
%506 = call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %507
507: ; preds = %505, %501
%508 = load i32, i32* %8
%509 = call i32 @close(i32 %508)
br label %510
510: ; preds = %507
%511 = load i32, i32* %9
%512 = add nsw i32 %511, 1
store i32 %512, i32* %9
br label %474
513: ; preds = %474
%514 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%515 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.23, i64 0, i64 0))
%516 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%517 = load i32, i32* %516
%518 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%519 = load i32, i32* %518
%520 = call i32 @print_elapse(i32 %517, i32 %519)
%521 = load i8*, i8** %11
%522 = call i32 @free(i8* %521)
%523 = load i8*, i8** %13
%524 = call i32 @unlink(i8* %523)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@.str = [24 x i8] c"/var/tmp/test_fsync.out\00"
@.str.1 = [3 x i8] c"-f\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.2 = [25 x i8] c"Cannot open output file.\00"
@.str.3 = [13 x i8] c"write failed\00"
@.str.4 = [13 x i8] c"fsync failed\00"
@.str.5 = [7 x i8] c"%p %p\0A\00"
@.str.7 = [7 x i8] c"\09%-30s\00"
@.str.8 = [6 x i8] c"write\00"
@O_DSYNC = global i32 0
@SEEK_SET = global i32 0
@.str.10 = [12 x i8] c"seek failed\00"
@.str.11 = [20 x i8] c"open_datasync write\00"
@.str.13 = [17 x i8] c"write, fdatasync\00"
@.str.14 = [13 x i8] c"write, fsync\00"
@.str.16 = [27 x i8] c"open_datasync write, write\00"
@.str.17 = [24 x i8] c"write, write, fdatasync\00"
@.str.18 = [20 x i8] c"write, write, fsync\00"
@.str.22 = [20 x i8] c"write, fsync, close\00"
@.str.23 = [20 x i8] c"write, close, fsync\00"
@str = [24 x i8] c"Simple 8k write timing:\00"
@str.24 = [47 x i8] c"\0ACompare file sync methods using one 8k write:\00"
@str.26 = [48 x i8] c"\0ACompare file sync methods using two 8k writes:\00"
@str.27 = [26 x i8] c"\0ACompare open_sync sizes:\00"
@str.28 = [25 x i8] c"\09(open_sync unavailable)\00"
@str.29 = [71 x i8] c"\0ACompare fsync times on write() and new file descriptors (if the times\00"
@str.30 = [71 x i8] c"are similar, fsync() can sync data written on a different descriptor):\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 = tail call i64 @malloc(i32 16777216)
%8 = inttoptr i64 %7 to i8*
%9 = icmp sgt i32 %0, 2
br i1 %9, label %10, label %19
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %10
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = add nsw i32 %0, -2
br label %19
19: ; preds = %15, %2
%20 = phi i8** [ %16, %15 ], [ %1, %2 ]
%21 = phi i32 [ %18, %15 ], [ %0, %2 ]
%22 = phi i8* [ %17, %15 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), %2 ]
%23 = icmp sgt i32 %21, 1
br i1 %23, label %24, label %30
24: ; preds = %10, %19
%25 = phi i8* [ %22, %19 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), %10 ]
%26 = phi i8** [ %20, %19 ], [ %1, %10 ]
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = tail call i32 @atoi(i8* %28)
br label %30
30: ; preds = %24, %19
%31 = phi i8* [ %25, %24 ], [ %22, %19 ]
%32 = phi i32 [ %29, %24 ], [ 5000, %19 ]
br label %33
33: ; preds = %30, %33
%34 = phi i64 [ 0, %30 ], [ %37, %33 ]
%35 = tail call signext i8 (...) @random()
%36 = getelementptr inbounds i8, i8* %8, i64 %34
store i8 %35, i8* %36
%37 = add nuw nsw i64 %34, 1
%38 = icmp eq i64 %37, 16777216
br i1 %38, label %39, label %33
39: ; preds = %33
%40 = load i32, i32* @O_RDWR
%41 = load i32, i32* @O_CREAT
%42 = or i32 %41, %40
%43 = load i32, i32* @S_IRUSR
%44 = load i32, i32* @S_IWUSR
%45 = or i32 %44, %43
%46 = tail call i32 (i8*, i32, i32, ...) @open(i8* %31, i32 %42, i32 %45, i32 0)
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %50
48: ; preds = %39
%49 = tail call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %50
50: ; preds = %48, %39
%51 = tail call i32 @write(i32 %46, i8* %8, i32 16777216)
%52 = icmp eq i32 %51, 16777216
br i1 %52, label %55, label %53
53: ; preds = %50
%54 = tail call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %55
55: ; preds = %53, %50
%56 = tail call i64 @fsync(i32 %46)
%57 = icmp eq i64 %56, 0
br i1 %57, label %60, label %58
58: ; preds = %55
%59 = tail call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %60
60: ; preds = %58, %55
%61 = tail call i32 @close(i32 %46)
%62 = and i64 %7, 4095
%63 = icmp eq i64 %62, 0
%64 = and i64 %7, -4096
%65 = inttoptr i64 %64 to i8*
%66 = getelementptr i8, i8* %65, i64 4096
%67 = select i1 %63, i8* %8, i8* %66
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %8, i8* %67)
%69 = ptrtoint i8* %67 to i64
%70 = and i64 %69, 4095
%71 = icmp eq i64 %70, 0
%72 = zext i1 %71 to i32
%73 = tail call i32 @assert(i32 %72)
%74 = tail call i32 @assert(i32 1)
%75 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%76 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%77 = icmp sgt i32 %32, 0
br i1 %77, label %78, label %94
78: ; preds = %60, %90
%79 = phi i32 [ %92, %90 ], [ 0, %60 ]
%80 = load i32, i32* @O_RDWR
%81 = tail call i32 (i8*, i32, i32, ...) @open(i8* %31, i32 %80, i32 0)
%82 = icmp eq i32 %81, -1
br i1 %82, label %83, label %85
83: ; preds = %78
%84 = tail call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %85
85: ; preds = %83, %78
%86 = tail call i32 @write(i32 %81, i8* %67, i32 8192)
%87 = icmp eq i32 %86, 8192
br i1 %87, label %90, label %88
88: ; preds = %85
%89 = tail call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %90
90: ; preds = %88, %85
%91 = tail call i32 @close(i32 %81)
%92 = add nuw nsw i32 %79, 1
%93 = icmp eq i32 %92, %32
br i1 %93, label %94, label %78
94: ; preds = %90, %60
%95 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%96 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%97 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%98 = load i32, i32* %97
%99 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%100 = load i32, i32* %99
%101 = tail call i32 @print_elapse(i32 %98, i32 %100)
%102 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.24, i64 0, i64 0))
%103 = load i32, i32* @O_RDWR
%104 = load i32, i32* @O_DSYNC
%105 = or i32 %104, %103
%106 = tail call i32 (i8*, i32, i32, ...) @open(i8* %31, i32 %105, i32 0)
%107 = icmp eq i32 %106, -1
br i1 %107, label %108, label %110
108: ; preds = %94
%109 = tail call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %110
110: ; preds = %108, %94
%111 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
br i1 %77, label %112, label %127
112: ; preds = %110, %124
%113 = phi i32 [ %125, %124 ], [ 0, %110 ]
%114 = tail call i32 @write(i32 %106, i8* %67, i32 8192)
%115 = icmp eq i32 %114, 8192
br i1 %115, label %118, label %116
116: ; preds = %112
%117 = tail call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %118
118: ; preds = %116, %112
%119 = load i32, i32* @SEEK_SET
%120 = tail call i32 @lseek(i32 %106, i32 0, i32 %119)
%121 = icmp eq i32 %120, -1
br i1 %121, label %122, label %124
122: ; preds = %118
%123 = tail call i32 @die(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %124
124: ; preds = %118, %122
%125 = add nuw nsw i32 %113, 1
%126 = icmp eq i32 %125, %32
br i1 %126, label %127, label %112
127: ; preds = %124, %110
%128 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%129 = tail call i32 @close(i32 %106)
%130 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0))
%131 = load i32, i32* %97
%132 = load i32, i32* %99
%133 = tail call i32 @print_elapse(i32 %131, i32 %132)
%134 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.28, i64 0, i64 0))
%135 = load i32, i32* @O_RDWR
%136 = tail call i32 (i8*, i32, i32, ...) @open(i8* %31, i32 %135, i32 0)
%137 = icmp eq i32 %136, -1
br i1 %137, label %138, label %140
138: ; preds = %127
%139 = tail call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %140
140: ; preds = %138, %127
%141 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
br i1 %77, label %142, label %158
142: ; preds = %140, %155
%143 = phi i32 [ %156, %155 ], [ 0, %140 ]
%144 = tail call i32 @write(i32 %136, i8* %67, i32 8192)
%145 = icmp eq i32 %144, 8192
br i1 %145, label %148, label %146
146: ; preds = %142
%147 = tail call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %148
148: ; preds = %146, %142
%149 = tail call i32 @fdatasync(i32 %136)
%150 = load i32, i32* @SEEK_SET
%151 = tail call i32 @lseek(i32 %136, i32 0, i32 %150)
%152 = icmp eq i32 %151, -1
br i1 %152, label %153, label %155
153: ; preds = %148
%154 = tail call i32 @die(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %155
155: ; preds = %148, %153
%156 = add nuw nsw i32 %143, 1
%157 = icmp eq i32 %156, %32
br i1 %157, label %158, label %142
158: ; preds = %155, %140
%159 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%160 = tail call i32 @close(i32 %136)
%161 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0))
%162 = load i32, i32* %97
%163 = load i32, i32* %99
%164 = tail call i32 @print_elapse(i32 %162, i32 %163)
%165 = load i32, i32* @O_RDWR
%166 = tail call i32 (i8*, i32, i32, ...) @open(i8* %31, i32 %165, i32 0)
%167 = icmp eq i32 %166, -1
br i1 %167, label %168, label %170
168: ; preds = %158
%169 = tail call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %170
170: ; preds = %168, %158
%171 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
br i1 %77, label %172, label %192
172: ; preds = %170, %189
%173 = phi i32 [ %190, %189 ], [ 0, %170 ]
%174 = tail call i32 @write(i32 %166, i8* %67, i32 8192)
%175 = icmp eq i32 %174, 8192
br i1 %175, label %178, label %176
176: ; preds = %172
%177 = tail call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %178
178: ; preds = %176, %172
%179 = tail call i64 @fsync(i32 %166)
%180 = icmp eq i64 %179, 0
br i1 %180, label %183, label %181
181: ; preds = %178
%182 = tail call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %183
183: ; preds = %181, %178
%184 = load i32, i32* @SEEK_SET
%185 = tail call i32 @lseek(i32 %166, i32 0, i32 %184)
%186 = icmp eq i32 %185, -1
br i1 %186, label %187, label %189
187: ; preds = %183
%188 = tail call i32 @die(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %189
189: ; preds = %183, %187
%190 = add nuw nsw i32 %173, 1
%191 = icmp eq i32 %190, %32
br i1 %191, label %192, label %172
192: ; preds = %189, %170
%193 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%194 = tail call i32 @close(i32 %166)
%195 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0))
%196 = load i32, i32* %97
%197 = load i32, i32* %99
%198 = tail call i32 @print_elapse(i32 %196, i32 %197)
%199 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.26, i64 0, i64 0))
%200 = load i32, i32* @O_RDWR
%201 = load i32, i32* @O_DSYNC
%202 = or i32 %201, %200
%203 = tail call i32 (i8*, i32, i32, ...) @open(i8* %31, i32 %202, i32 0)
%204 = icmp eq i32 %203, -1
br i1 %204, label %205, label %207
205: ; preds = %192
%206 = tail call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %207
207: ; preds = %205, %192
%208 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
br i1 %77, label %209, label %229
209: ; preds = %207, %226
%210 = phi i32 [ %227, %226 ], [ 0, %207 ]
%211 = tail call i32 @write(i32 %203, i8* %67, i32 8192)
%212 = icmp eq i32 %211, 8192
br i1 %212, label %215, label %213
213: ; preds = %209
%214 = tail call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %215
215: ; preds = %213, %209
%216 = tail call i32 @write(i32 %203, i8* %67, i32 8192)
%217 = icmp eq i32 %216, 8192
br i1 %217, label %220, label %218
218: ; preds = %215
%219 = tail call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %220
220: ; preds = %218, %215
%221 = load i32, i32* @SEEK_SET
%222 = tail call i32 @lseek(i32 %203, i32 0, i32 %221)
%223 = icmp eq i32 %222, -1
br i1 %223, label %224, label %226
224: ; preds = %220
%225 = tail call i32 @die(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %226
226: ; preds = %220, %224
%227 = add nuw nsw i32 %210, 1
%228 = icmp eq i32 %227, %32
br i1 %228, label %229, label %209
229: ; preds = %226, %207
%230 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%231 = tail call i32 @close(i32 %203)
%232 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.16, i64 0, i64 0))
%233 = load i32, i32* %97
%234 = load i32, i32* %99
%235 = tail call i32 @print_elapse(i32 %233, i32 %234)
%236 = load i32, i32* @O_RDWR
%237 = tail call i32 (i8*, i32, i32, ...) @open(i8* %31, i32 %236, i32 0)
%238 = icmp eq i32 %237, -1
br i1 %238, label %239, label %241
239: ; preds = %229
%240 = tail call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %241
241: ; preds = %239, %229
%242 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
br i1 %77, label %243, label %264
243: ; preds = %241, %261
%244 = phi i32 [ %262, %261 ], [ 0, %241 ]
%245 = tail call i32 @write(i32 %237, i8* %67, i32 8192)
%246 = icmp eq i32 %245, 8192
br i1 %246, label %249, label %247
247: ; preds = %243
%248 = tail call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %249
249: ; preds = %247, %243
%250 = tail call i32 @write(i32 %237, i8* %67, i32 8192)
%251 = icmp eq i32 %250, 8192
br i1 %251, label %254, label %252
252: ; preds = %249
%253 = tail call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %254
254: ; preds = %252, %249
%255 = tail call i32 @fdatasync(i32 %237)
%256 = load i32, i32* @SEEK_SET
%257 = tail call i32 @lseek(i32 %237, i32 0, i32 %256)
%258 = icmp eq i32 %257, -1
br i1 %258, label %259, label %261
259: ; preds = %254
%260 = tail call i32 @die(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %261
261: ; preds = %254, %259
%262 = add nuw nsw i32 %244, 1
%263 = icmp eq i32 %262, %32
br i1 %263, label %264, label %243
264: ; preds = %261, %241
%265 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%266 = tail call i32 @close(i32 %237)
%267 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.17, i64 0, i64 0))
%268 = load i32, i32* %97
%269 = load i32, i32* %99
%270 = tail call i32 @print_elapse(i32 %268, i32 %269)
%271 = load i32, i32* @O_RDWR
%272 = tail call i32 (i8*, i32, i32, ...) @open(i8* %31, i32 %271, i32 0)
%273 = icmp eq i32 %272, -1
br i1 %273, label %274, label %276
274: ; preds = %264
%275 = tail call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %276
276: ; preds = %274, %264
%277 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
br i1 %77, label %278, label %303
278: ; preds = %276, %300
%279 = phi i32 [ %301, %300 ], [ 0, %276 ]
%280 = tail call i32 @write(i32 %272, i8* %67, i32 8192)
%281 = icmp eq i32 %280, 8192
br i1 %281, label %284, label %282
282: ; preds = %278
%283 = tail call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %284
284: ; preds = %282, %278
%285 = tail call i32 @write(i32 %272, i8* %67, i32 8192)
%286 = icmp eq i32 %285, 8192
br i1 %286, label %289, label %287
287: ; preds = %284
%288 = tail call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %289
289: ; preds = %287, %284
%290 = tail call i64 @fsync(i32 %272)
%291 = icmp eq i64 %290, 0
br i1 %291, label %294, label %292
292: ; preds = %289
%293 = tail call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %294
294: ; preds = %292, %289
%295 = load i32, i32* @SEEK_SET
%296 = tail call i32 @lseek(i32 %272, i32 0, i32 %295)
%297 = icmp eq i32 %296, -1
br i1 %297, label %298, label %300
298: ; preds = %294
%299 = tail call i32 @die(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %300
300: ; preds = %294, %298
%301 = add nuw nsw i32 %279, 1
%302 = icmp eq i32 %301, %32
br i1 %302, label %303, label %278
303: ; preds = %300, %276
%304 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%305 = tail call i32 @close(i32 %272)
%306 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.18, i64 0, i64 0))
%307 = load i32, i32* %97
%308 = load i32, i32* %99
%309 = tail call i32 @print_elapse(i32 %307, i32 %308)
%310 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.27, i64 0, i64 0))
%311 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.28, i64 0, i64 0))
%312 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @str.29, i64 0, i64 0))
%313 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @str.30, i64 0, i64 0))
%314 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
br i1 %77, label %315, label %378
315: ; preds = %303, %339
%316 = phi i32 [ %341, %339 ], [ 0, %303 ]
%317 = load i32, i32* @O_RDWR
%318 = tail call i32 (i8*, i32, i32, ...) @open(i8* %31, i32 %317, i32 0)
%319 = icmp eq i32 %318, -1
br i1 %319, label %320, label %322
320: ; preds = %315
%321 = tail call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %322
322: ; preds = %320, %315
%323 = tail call i32 @write(i32 %318, i8* %67, i32 8192)
%324 = icmp eq i32 %323, 8192
br i1 %324, label %327, label %325
325: ; preds = %322
%326 = tail call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %327
327: ; preds = %325, %322
%328 = tail call i64 @fsync(i32 %318)
%329 = icmp eq i64 %328, 0
br i1 %329, label %332, label %330
330: ; preds = %327
%331 = tail call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %332
332: ; preds = %330, %327
%333 = tail call i32 @close(i32 %318)
%334 = load i32, i32* @O_RDWR
%335 = tail call i32 (i8*, i32, i32, ...) @open(i8* %31, i32 %334, i32 0)
%336 = icmp eq i32 %335, -1
br i1 %336, label %337, label %339
337: ; preds = %332
%338 = tail call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %339
339: ; preds = %337, %332
%340 = tail call i32 @close(i32 %335)
%341 = add nuw nsw i32 %316, 1
%342 = icmp eq i32 %341, %32
br i1 %342, label %343, label %315
343: ; preds = %339
%344 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%345 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.22, i64 0, i64 0))
%346 = load i32, i32* %97
%347 = load i32, i32* %99
%348 = tail call i32 @print_elapse(i32 %346, i32 %347)
%349 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
br i1 %77, label %350, label %385
350: ; preds = %343, %374
%351 = phi i32 [ %376, %374 ], [ 0, %343 ]
%352 = load i32, i32* @O_RDWR
%353 = tail call i32 (i8*, i32, i32, ...) @open(i8* %31, i32 %352, i32 0)
%354 = icmp eq i32 %353, -1
br i1 %354, label %355, label %357
355: ; preds = %350
%356 = tail call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %357
357: ; preds = %355, %350
%358 = tail call i32 @write(i32 %353, i8* %67, i32 8192)
%359 = icmp eq i32 %358, 8192
br i1 %359, label %362, label %360
360: ; preds = %357
%361 = tail call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %362
362: ; preds = %360, %357
%363 = tail call i32 @close(i32 %353)
%364 = load i32, i32* @O_RDWR
%365 = tail call i32 (i8*, i32, i32, ...) @open(i8* %31, i32 %364, i32 0)
%366 = icmp eq i32 %365, -1
br i1 %366, label %367, label %369
367: ; preds = %362
%368 = tail call i32 @die(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %369
369: ; preds = %367, %362
%370 = tail call i64 @fsync(i32 %365)
%371 = icmp eq i64 %370, 0
br i1 %371, label %374, label %372
372: ; preds = %369
%373 = tail call i32 @die(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %374
374: ; preds = %372, %369
%375 = tail call i32 @close(i32 %365)
%376 = add nuw nsw i32 %351, 1
%377 = icmp eq i32 %376, %32
br i1 %377, label %385, label %350
378: ; preds = %303
%379 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%380 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.22, i64 0, i64 0))
%381 = load i32, i32* %97
%382 = load i32, i32* %99
%383 = tail call i32 @print_elapse(i32 %381, i32 %382)
%384 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
br label %385
385: ; preds = %374, %378, %343
%386 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%387 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.23, i64 0, i64 0))
%388 = load i32, i32* %97
%389 = load i32, i32* %99
%390 = tail call i32 @print_elapse(i32 %388, i32 %389)
%391 = tail call i32 @free(i8* %8)
%392 = tail call i32 @unlink(i8* %31)
ret i32 0
}