#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 scalar_t__ clock_t;

/* Variables and functions */
scalar_t__ CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ test();
int main() {
  clock_t t1, t2;
  t1 = clock();
  for (int i = 0; i < (100000); i++) {
    test();
  }
  t2 = clock();
  double delta = (double)(t2 - t1);
  double iteration_clocks = delta / (double)(100000);
  double iteration_seconds = iteration_clocks / (double)CLOCKS_PER_SEC;
  printf("%.10g sec/iteration\n", iteration_seconds);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x186a0,-0x1c(%rbp)
jge    1173 <main+0x43>
mov    $0x0,%al
call   1050 <test@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1151 <main+0x21>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
sub    -0x10(%rbp),%rax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe63(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    0x2e36(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
lea    0xe3c(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbx
mov    $0x186a0,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <test@plt>
add    $0xffffffff,%ebp
jne    1150 <main+0x20>
xor    %eax,%eax
call   1030 <clock@plt>
sub    %rbx,%rax
cvtsi2sd %rax,%xmm0
divsd  0xe8d(%rip),%xmm0
mov    0x2e6e(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@CLOCKS_PER_SEC = global i64 0
@.str = [21 x i8] c"%.10g sec/iteration\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i32 0, i32* %1
%8 = call i64 (...) @clock()
store i64 %8, i64* %2
store i32 0, i32* %4
br label %9
9: ; preds = %14, %0
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 100000
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = call i32 (...) @test()
br label %14
14: ; preds = %12
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
br label %9
17: ; preds = %9
%18 = call i64 (...) @clock()
store i64 %18, i64* %3
%19 = load i64, i64* %3
%20 = load i64, i64* %2
%21 = sub nsw i64 %19, %20
%22 = sitofp i64 %21 to double
store double %22, double* %5
%23 = load double, double* %5
%24 = fdiv double %23, 1.000000e+05
store double %24, double* %6
%25 = load double, double* %6
%26 = load i64, i64* @CLOCKS_PER_SEC
%27 = sitofp i64 %26 to double
%28 = fdiv double %25, %27
store double %28, double* %7
%29 = load double, double* %7
%30 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), double %29)
ret i32 0
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global i64 0
@.str = [21 x i8] c"%.10g sec/iteration\0A\00"
define i32 @main() {
%1 = tail call i64 (...) @clock()
br label %11
2: ; preds = %11
%3 = tail call i64 (...) @clock()
%4 = sub nsw i64 %3, %1
%5 = sitofp i64 %4 to double
%6 = fdiv double %5, 1.000000e+05
%7 = load i64, i64* @CLOCKS_PER_SEC
%8 = sitofp i64 %7 to double
%9 = fdiv double %6, %8
%10 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), double %9)
ret i32 0
11: ; preds = %0, %11
%12 = phi i32 [ 0, %0 ], [ %14, %11 ]
%13 = tail call i32 (...) @test()
%14 = add nuw nsw i32 %12, 1
%15 = icmp eq i32 %14, 100000
br i1 %15, label %2, label %11
}