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

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ i;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, double);
int /*<<< orphan*/ fsync(int);
double mono_time();
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ write(int, int *, int);
int main(int argc, char **argv) {
  double t0, t1, ns;
  int i;
  t0 = mono_time();
  for (i = 0; i < (100); i++) {
    write(1, &i, sizeof(i));
    fsync(1);
  }
  t1 = mono_time();
  ns = (t1 - t0) / (100);
  fprintf(stderr, "%ens per fsync();", ns);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <mono_time@plt>
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x64,-0x2c(%rbp)
jge    119e <main+0x5e>
mov    $0x1,%edi
lea    -0x2c(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1060 <fsync@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1169 <main+0x29>
mov    $0x0,%al
call   1040 <mono_time@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  0xe44(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
movsd  -0x28(%rbp),%xmm0
lea    0xe2e(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   1040 <mono_time@plt>
movsd  %xmm0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
mov    $0x1,%ebp
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1060 <fsync@plt>
mov    %ebp,0xc(%rsp)
add    $0x1,%ebp
cmp    $0x65,%ebp
jne    1170 <main+0x30>
xor    %eax,%eax
call   1040 <mono_time@plt>
subsd  0x10(%rsp),%xmm0
divsd  0xe53(%rip),%xmm0
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
lea    0xe4b(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [18 x i8] c"%ens per fsync();\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call double (...) @mono_time()
store double %10, double* %6
store i32 0, i32* %9
br label %11
11: ; preds = %17, %2
%12 = load i32, i32* %9
%13 = icmp slt i32 %12, 100
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = call i32 @write(i32 1, i32* %9, i32 4)
%16 = call i32 @fsync(i32 1)
br label %17
17: ; preds = %14
%18 = load i32, i32* %9
%19 = add nsw i32 %18, 1
store i32 %19, i32* %9
br label %11
20: ; preds = %11
%21 = call double (...) @mono_time()
store double %21, double* %7
%22 = load double, double* %7
%23 = load double, double* %6
%24 = fsub double %22, %23
%25 = fdiv double %24, 1.000000e+02
store double %25, double* %8
%26 = load i32, i32* @stderr
%27 = load double, double* %8
%28 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), double %27)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [18 x i8] c"%ens per fsync();\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call double (...) @mono_time()
store i32 0, i32* %3
br label %6
6: ; preds = %2, %6
%7 = phi i32 [ 0, %2 ], [ %10, %6 ]
%8 = call i32 @write(i32 1, i32* %3, i32 4)
%9 = tail call i32 @fsync(i32 1)
%10 = add nuw nsw i32 %7, 1
store i32 %10, i32* %3
%11 = icmp eq i32 %10, 100
br i1 %11, label %12, label %6
12: ; preds = %6
%13 = tail call double (...) @mono_time()
%14 = fsub double %13, %5
%15 = fdiv double %14, 1.000000e+02
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), double %15)
ret i32 0
}