#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*/ times;
struct timespec {
  int tv_sec;
  int tv_nsec;
};
typedef int /*<<< orphan*/ ssize_t;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
unsigned long long fmaxl(unsigned long long, unsigned long long);
unsigned long long fminl(unsigned long long, unsigned long long);
int fsync(int);
int mkstemp(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, unsigned long long, unsigned long long,
                          unsigned long long, unsigned long long,
                          unsigned long long);
int rand();
unsigned long long rms(unsigned long long *, int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ unlink(char *);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  int fdo, i, j;
  ssize_t len;
  struct timespec start, stop;
  unsigned long long min_time, max_time, total_time;
  unsigned long long total = 0;
  char buffer[2048];
  unsigned long long times[10000];
  srand(time(NULL));
  for (i = 0; i < 10000; i++) {
    for (j = 0; j < 2048; j++) {
      buffer[j] = (char)(rand() & 0xFF);
    }
    char filename[] = "fsync-bench-XXXXXX";
    if ((fdo = mkstemp(filename)) == -1) {
      perror("mkstemp");
      exit(errno);
    }
    clock_gettime(CLOCK_MONOTONIC, &start);
    for (j = 0; j < 100; j++) {
      if (write(fdo, buffer, sizeof(buffer)) == -1) {
        perror("write");
        exit(errno);
      }
    }
    if (fsync(fdo) == -1) {
      perror("fsync");
      exit(errno);
    }
    clock_gettime(CLOCK_MONOTONIC, &stop);
    unsigned long long time_start =
        start.tv_sec * 1000 + start.tv_nsec / 1000000;
    unsigned long long time_stop = stop.tv_sec * 1000 + stop.tv_nsec / 1000000;
    unsigned long long elapsed = time_stop - time_start;
    if (i == 0)
      max_time = elapsed;
    else
      max_time = fmaxl(max_time, elapsed);
    min_time = fminl(min_time, elapsed);
    total += elapsed;
    times[i] = elapsed;
    if (close(fdo) == -1) {
      perror("close");
      exit(errno);
    }
    unlink(filename);
  }
  unsigned long long av =
      rms(times, sizeof(times) / sizeof(unsigned long long));
  printf("Done %d rounds, Total time: %llu , Min time: %llu, Max time: %llu, "
         "Average: %llu, RMS time: %llu\n",
         10000, total, min_time, max_time, total / 10000, av);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x14130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x50(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10a0 <time@plt>
mov    %eax,%edi
call   1090 <srand@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x2710,-0x18(%rbp)
jge    1496 <main+0x2a6>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x800,-0x1c(%rbp)
jge    1270 <main+0x80>
mov    $0x0,%al
call   1110 <rand@plt>
and    $0xff,%eax
mov    %al,%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x850(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    123c <main+0x4c>
mov    0xd89(%rip),%rax
mov    %rax,-0x140f0(%rbp)
mov    0xd83(%rip),%rax
mov    %rax,-0x140e8(%rbp)
mov    0xd7d(%rip),%ax
mov    %ax,-0x140e0(%rbp)
mov    0xd72(%rip),%al
mov    %al,-0x140de(%rbp)
lea    -0x140f0(%rbp),%rdi
call   10c0 <mkstemp@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    12d8 <main+0xe8>
lea    0xd4e(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2d07(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    0x2d09(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1040 <clock_gettime@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x64,-0x1c(%rbp)
jge    1345 <main+0x155>
mov    -0x14(%rbp),%edi
lea    -0x850(%rbp),%rsi
mov    $0x800,%edx
call   1050 <write@plt>
cmp    $0xffffffff,%eax
jne    1332 <main+0x142>
lea    0xcfc(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2cad(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
jmp    1337 <main+0x147>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12f1 <main+0x101>
mov    -0x14(%rbp),%edi
call   10d0 <fsync@plt>
cmp    $0xffffffff,%eax
jne    1370 <main+0x180>
lea    0xcc4(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2c6f(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    0x2c71(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
call   1040 <clock_gettime@plt>
imul   $0x3e8,-0x28(%rbp),%eax
mov    %eax,-0x14118(%rbp)
mov    -0x24(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14118(%rbp),%eax
add    %ecx,%eax
cltq
mov    %rax,-0x140f8(%rbp)
imul   $0x3e8,-0x30(%rbp),%eax
mov    %eax,-0x14114(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14114(%rbp),%eax
add    %ecx,%eax
cltq
mov    %rax,-0x14100(%rbp)
mov    -0x14100(%rbp),%rax
sub    -0x140f8(%rbp),%rax
mov    %rax,-0x14108(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    1407 <main+0x217>
mov    -0x14108(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    141b <main+0x22b>
mov    -0x40(%rbp),%rdi
mov    -0x14108(%rbp),%rsi
call   10b0 <fmaxl@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x14108(%rbp),%rsi
call   1070 <fminl@plt>
mov    %rax,-0x38(%rbp)
mov    -0x14108(%rbp),%rax
add    -0x50(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x14108(%rbp),%rcx
movslq -0x18(%rbp),%rax
mov    %rcx,-0x140d0(%rbp,%rax,8)
ff
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
cmp    $0xffffffff,%eax
jne    147c <main+0x28c>
lea    0xbbe(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2b63(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
lea    -0x140f0(%rbp),%rdi
call   1030 <unlink@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1228 <main+0x38>
lea    -0x140d0(%rbp),%rdi
mov    $0x2710,%esi
call   10e0 <rms@plt>
mov    %rax,-0x14110(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x14120(%rbp)
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%r8
mov    -0x50(%rbp),%rax
mov    $0x2710,%esi
xor    %edx,%edx
div    %rsi
mov    -0x14120(%rbp),%rdx
mov    %rax,%r9
mov    -0x14110(%rbp),%rax
lea    0xb46(%rip),%rdi
mov    $0x2710,%esi
mov    %rax,(%rsp)
call   1060 <printf@plt>
xor    %edi,%edi
call   1100 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x140d8,%rsp
xor    %edi,%edi
call   10a0 <time@plt>
mov    %eax,%edi
call   1090 <srand@plt>
lea    0x30(%rsp),%rbp
lea    0x50(%rsp),%r13
xor    %r14d,%r14d
xor    %r12d,%r12d
nop
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1110 <rand@plt>
mov    %al,0x50(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x800,%rbx
jne    1230 <main+0x40>
movaps 0xdb1(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movl   $0x585858,0x3f(%rsp)
mov    %rbp,%rdi
call   10c0 <mkstemp@plt>
cmp    $0xffffffff,%eax
je     1404 <main+0x214>
mov    %eax,%ebp
mov    0x2d72(%rip),%rax
mov    (%rax),%edi
lea    0x20(%rsp),%rsi
call   1040 <clock_gettime@plt>
mov    $0x64,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r13,%rsi
mov    $0x800,%edx
call   1050 <write@plt>
cmp    $0xffffffff,%eax
je     13ea <main+0x1fa>
add    $0xffffffff,%ebx
jne    1290 <main+0xa0>
mov    %ebp,%edi
call   10d0 <fsync@plt>
cmp    $0xffffffff,%eax
je     140d <main+0x21d>
mov    %r12,%rbx
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
lea    0x18(%rsp),%rsi
call   1040 <clock_gettime@plt>
movslq 0x20(%rsp),%rax
imul   $0x3e8,%rax,%rax
movslq 0x24(%rsp),%rcx
imul   $0x431bde83,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x32,%rcx
add    %edx,%ecx
movslq %ecx,%rcx
add    %rax,%rcx
movslq 0x18(%rsp),%rax
imul   $0x3e8,%rax,%rax
movslq 0x1c(%rsp),%rdx
imul   $0x431bde83,%rdx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x32,%rdx
add    %esi,%edx
movslq %edx,%r12
add    %rax,%r12
sub    %rcx,%r12
mov    %r12,%r15
test   %r14,%r14
je     1344 <main+0x154>
mov    0x28(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <fmaxl@plt>
mov    %rax,%r15
mov    0x10(%rsp),%rdi
mov    %r12,%rsi
call   1070 <fminl@plt>
mov    %rax,0x10(%rsp)
mov    %r12,0x850(%rsp,%r14,8)
mov    %ebp,%edi
call   1080 <close@plt>
cmp    $0xffffffff,%eax
je     1416 <main+0x226>
add    %r12,%rbx
mov    %rbx,%r12
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <unlink@plt>
add    $0x1,%r14
mov    %r15,0x28(%rsp)
cmp    $0x2710,%r14
jne    1220 <main+0x30>
lea    0x850(%rsp),%rdi
mov    $0x2710,%esi
call   10e0 <rms@plt>
mov    %rax,%rcx
movabs $0x346dc5d63886594b,%rdx
c5 6d 34
mov    %r12,%rax
mul    %rdx
mov    %rdx,%r9
shr    $0xb,%r9
mov    %rcx,(%rsp)
lea    0xc5f(%rip),%rdi
mov    $0x2710,%esi
mov    %r12,%rdx
mov    0x10(%rsp),%rcx
mov    %r15,%r8
call   1060 <printf@plt>
xor    %edi,%edi
call   1100 <exit@plt>
lea    0xc2a(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2bdb(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
lea    0xc08(%rip),%rdi
jmp    13f1 <main+0x201>
lea    0xc0d(%rip),%rdi
jmp    13f1 <main+0x201>
lea    0xc0a(%rip),%rdi
jmp    13f1 <main+0x201>

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
@__const.main.filename = [19 x i8] c"fsync-bench-XXXXXX\00"
@.str = [8 x i8] c"mkstemp\00"
@errno = global i32 0
@CLOCK_MONOTONIC = global i32 0
@.str.1 = [6 x i8] c"write\00"
@.str.2 = [6 x i8] c"fsync\00"
@.str.3 = [6 x i8] c"close\00"
@.str.4 = [98 x i8] c"Done %d rounds, Total time: %llu , Min time: %llu, Max time: %llu, Average: %llu, RMS time: %llu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.timespec
%11 = alloca %struct.timespec
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca [2048 x i8]
%17 = alloca [10000 x i64]
%18 = alloca [19 x i8]
%19 = alloca i64
%20 = alloca i64
%21 = alloca i64
%22 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %15
%23 = call i32 @time(i32* null)
%24 = call i32 @srand(i32 %23)
store i32 0, i32* %7
br label %25
25: ; preds = %129, %2
%26 = load i32, i32* %7
%27 = icmp slt i32 %26, 10000
br i1 %27, label %28, label %132
28: ; preds = %25
store i32 0, i32* %8
br label %29
29: ; preds = %39, %28
%30 = load i32, i32* %8
%31 = icmp slt i32 %30, 2048
br i1 %31, label %32, label %42
32: ; preds = %29
%33 = call i32 (...) @rand()
%34 = and i32 %33, 255
%35 = trunc i32 %34 to i8
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [2048 x i8], [2048 x i8]* %16, i64 0, i64 %37
store i8 %35, i8* %38
br label %39
39: ; preds = %32
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %29
42: ; preds = %29
%43 = bitcast [19 x i8]* %18 to i8*
%44 = getelementptr inbounds [19 x i8], [19 x i8]* %18, i64 0, i64 0
%45 = call i32 @mkstemp(i8* %44)
store i32 %45, i32* %6
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %51
47: ; preds = %42
%48 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%49 = load i32, i32* @errno
%50 = call i32 @exit(i32 %49)
unreachable
51: ; preds = %42
%52 = load i32, i32* @CLOCK_MONOTONIC
%53 = call i32 @clock_gettime(i32 %52, %struct.timespec* %10)
store i32 0, i32* %8
br label %54
54: ; preds = %67, %51
%55 = load i32, i32* %8
%56 = icmp slt i32 %55, 100
br i1 %56, label %57, label %70
57: ; preds = %54
%58 = load i32, i32* %6
%59 = getelementptr inbounds [2048 x i8], [2048 x i8]* %16, i64 0, i64 0
%60 = call i32 @write(i32 %58, i8* %59, i32 2048)
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %66
62: ; preds = %57
%63 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%64 = load i32, i32* @errno
%65 = call i32 @exit(i32 %64)
unreachable
66: ; preds = %57
br label %67
67: ; preds = %66
%68 = load i32, i32* %8
%69 = add nsw i32 %68, 1
store i32 %69, i32* %8
br label %54
70: ; preds = %54
%71 = load i32, i32* %6
%72 = call i32 @fsync(i32 %71)
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %78
74: ; preds = %70
%75 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%76 = load i32, i32* @errno
%77 = call i32 @exit(i32 %76)
unreachable
78: ; preds = %70
%79 = load i32, i32* @CLOCK_MONOTONIC
%80 = call i32 @clock_gettime(i32 %79, %struct.timespec* %11)
%81 = getelementptr inbounds %struct.timespec, %struct.timespec* %10, i32 0, i32 0
%82 = load i32, i32* %81
%83 = mul nsw i32 %82, 1000
%84 = getelementptr inbounds %struct.timespec, %struct.timespec* %10, i32 0, i32 1
%85 = load i32, i32* %84
%86 = sdiv i32 %85, 1000000
%87 = add nsw i32 %83, %86
%88 = sext i32 %87 to i64
store i64 %88, i64* %19
%89 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%90 = load i32, i32* %89
%91 = mul nsw i32 %90, 1000
%92 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 1
%93 = load i32, i32* %92
%94 = sdiv i32 %93, 1000000
%95 = add nsw i32 %91, %94
%96 = sext i32 %95 to i64
store i64 %96, i64* %20
%97 = load i64, i64* %20
%98 = load i64, i64* %19
%99 = sub i64 %97, %98
store i64 %99, i64* %21
%100 = load i32, i32* %7
%101 = icmp eq i32 %100, 0
br i1 %101, label %102, label %104
102: ; preds = %78
%103 = load i64, i64* %21
store i64 %103, i64* %13
br label %108
104: ; preds = %78
%105 = load i64, i64* %13
%106 = load i64, i64* %21
%107 = call i64 @fmaxl(i64 %105, i64 %106)
store i64 %107, i64* %13
br label %108
108: ; preds = %104, %102
%109 = load i64, i64* %12
%110 = load i64, i64* %21
%111 = call i64 @fminl(i64 %109, i64 %110)
store i64 %111, i64* %12
%112 = load i64, i64* %21
%113 = load i64, i64* %15
%114 = add i64 %113, %112
store i64 %114, i64* %15
%115 = load i64, i64* %21
%116 = load i32, i32* %7
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds [10000 x i64], [10000 x i64]* %17, i64 0, i64 %117
store i64 %115, i64* %118
%119 = load i32, i32* %6
%120 = call i32 @close(i32 %119)
%121 = icmp eq i32 %120, -1
br i1 %121, label %122, label %126
122: ; preds = %108
%123 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%124 = load i32, i32* @errno
%125 = call i32 @exit(i32 %124)
unreachable
126: ; preds = %108
%127 = getelementptr inbounds [19 x i8], [19 x i8]* %18, i64 0, i64 0
%128 = call i32 @unlink(i8* %127)
br label %129
129: ; preds = %126
%130 = load i32, i32* %7
%131 = add nsw i32 %130, 1
store i32 %131, i32* %7
br label %25
132: ; preds = %25
%133 = getelementptr inbounds [10000 x i64], [10000 x i64]* %17, i64 0, i64 0
%134 = call i64 @rms(i64* %133, i32 10000)
store i64 %134, i64* %22
%135 = load i64, i64* %15
%136 = load i64, i64* %12
%137 = load i64, i64* %13
%138 = load i64, i64* %15
%139 = udiv i64 %138, 10000
%140 = load i64, i64* %22
%141 = call i32 @printf(i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str.4, i64 0, i64 0), i32 10000, i64 %135, i64 %136, i64 %137, i64 %139, i64 %140)
%142 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
@__const.main.filename = [19 x i8] c"fsync-bench-XXXXXX\00"
@.str = [8 x i8] c"mkstemp\00"
@errno = global i32 0
@CLOCK_MONOTONIC = global i32 0
@.str.1 = [6 x i8] c"write\00"
@.str.2 = [6 x i8] c"fsync\00"
@.str.3 = [6 x i8] c"close\00"
@.str.4 = [98 x i8] c"Done %d rounds, Total time: %llu , Min time: %llu, Max time: %llu, Average: %llu, RMS time: %llu\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.timespec
%4 = alloca %struct.timespec
%5 = alloca [2048 x i8]
%6 = alloca [10000 x i64]
%7 = alloca [19 x i8]
%8 = bitcast %struct.timespec* %3 to i8*
%9 = bitcast %struct.timespec* %4 to i8*
%10 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%11 = bitcast [10000 x i64]* %6 to i8*
%12 = tail call i32 @time(i32* null)
%13 = tail call i32 @srand(i32 %12)
%14 = getelementptr inbounds [19 x i8], [19 x i8]* %7, i64 0, i64 0
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 0
%16 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 1
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 0
%18 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 1
br label %19
19: ; preds = %2, %88
%20 = phi i64 [ 0, %2 ], [ %91, %88 ]
%21 = phi i64 [ undef, %2 ], [ %80, %88 ]
%22 = phi i64 [ undef, %2 ], [ %79, %88 ]
%23 = phi i64 [ 0, %2 ], [ %89, %88 ]
br label %24
24: ; preds = %19, %24
%25 = phi i64 [ 0, %19 ], [ %29, %24 ]
%26 = call i32 (...) @rand()
%27 = trunc i32 %26 to i8
%28 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 %25
store i8 %27, i8* %28
%29 = add nuw nsw i64 %25, 1
%30 = icmp eq i64 %29, 2048
br i1 %30, label %31, label %24
31: ; preds = %24
%32 = call i32 @mkstemp(i8* %14)
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%36 = load i32, i32* @errno
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %31
%39 = load i32, i32* @CLOCK_MONOTONIC
%40 = call i32 @clock_gettime(i32 %39, %struct.timespec* %3)
br label %44
41: ; preds = %44
%42 = add nuw nsw i32 %45, 1
%43 = icmp eq i32 %42, 100
br i1 %43, label %52, label %44
44: ; preds = %38, %41
%45 = phi i32 [ 0, %38 ], [ %42, %41 ]
%46 = call i32 @write(i32 %32, i8* %10, i32 2048)
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %41
48: ; preds = %44
%49 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%50 = load i32, i32* @errno
%51 = call i32 @exit(i32 %50)
unreachable
52: ; preds = %41
%53 = call i32 @fsync(i32 %32)
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %59
55: ; preds = %52
%56 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%57 = load i32, i32* @errno
%58 = call i32 @exit(i32 %57)
unreachable
59: ; preds = %52
%60 = load i32, i32* @CLOCK_MONOTONIC
%61 = call i32 @clock_gettime(i32 %60, %struct.timespec* %4)
%62 = load i32, i32* %15
%63 = mul nsw i32 %62, 1000
%64 = load i32, i32* %16
%65 = sdiv i32 %64, 1000000
%66 = add nsw i32 %65, %63
%67 = sext i32 %66 to i64
%68 = load i32, i32* %17
%69 = mul nsw i32 %68, 1000
%70 = load i32, i32* %18
%71 = sdiv i32 %70, 1000000
%72 = add nsw i32 %71, %69
%73 = sext i32 %72 to i64
%74 = sub nsw i64 %73, %67
%75 = icmp eq i64 %20, 0
br i1 %75, label %78, label %76
76: ; preds = %59
%77 = call i64 @fmaxl(i64 %22, i64 %74)
br label %78
78: ; preds = %59, %76
%79 = phi i64 [ %77, %76 ], [ %74, %59 ]
%80 = call i64 @fminl(i64 %21, i64 %74)
%81 = getelementptr inbounds [10000 x i64], [10000 x i64]* %6, i64 0, i64 %20
store i64 %74, i64* %81
%82 = call i32 @close(i32 %32)
%83 = icmp eq i32 %82, -1
br i1 %83, label %84, label %88
84: ; preds = %78
%85 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%86 = load i32, i32* @errno
%87 = call i32 @exit(i32 %86)
unreachable
88: ; preds = %78
%89 = add i64 %74, %23
%90 = call i32 @unlink(i8* %14)
%91 = add nuw nsw i64 %20, 1
%92 = icmp eq i64 %91, 10000
br i1 %92, label %93, label %19
93: ; preds = %88
%94 = getelementptr inbounds [10000 x i64], [10000 x i64]* %6, i64 0, i64 0
%95 = call i64 @rms(i64* %94, i32 10000)
%96 = udiv i64 %89, 10000
%97 = call i32 @printf(i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str.4, i64 0, i64 0), i32 10000, i64 %89, i64 %80, i64 %79, i64 %96, i64 %95)
%98 = call i32 @exit(i32 0)
unreachable
}