#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 */

/* Variables and functions */
double get_seconds();
int /*<<< orphan*/ srandom(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
double time_func(int iters, float (*func)()) {
  int i;
  float f;
  double t0, t1;
  srandom(time(NULL));
  t0 = get_seconds();
  for (i = 0; i < iters; i++) {
    f = func();
  }
  t1 = get_seconds();
  return t1 - t0;
}


x86 assembly (clang, -O0):
<time_func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srandom@plt>
mov    $0x0,%al
call   1030 <get_seconds@plt>
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1186 <time_func+0x56>
mov    $0x0,%al
call   *-0x10(%rbp)
movss  %xmm0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1162 <time_func+0x32>
mov    $0x0,%al
call   1030 <get_seconds@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_func>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srandom@plt>
xor    %eax,%eax
call   1030 <get_seconds@plt>
movsd  %xmm0,(%rsp)
test   %ebp,%ebp
jle    1169 <time_func+0x39>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   *%rbx
add    $0xffffffff,%ebp
jne    1160 <time_func+0x30>
xor    %eax,%eax
call   1030 <get_seconds@plt>
subsd  (%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @time_func(i32 %0, float (...)* %1) {
%3 = alloca i32
%4 = alloca float (...)*
%5 = alloca i32
%6 = alloca float
%7 = alloca double
%8 = alloca double
store i32 %0, i32* %3
store float (...)* %1, float (...)** %4
%9 = call i32 @time(i32* null)
%10 = call i32 @srandom(i32 %9)
%11 = call double (...) @get_seconds()
store double %11, double* %7
store i32 0, i32* %5
br label %12
12: ; preds = %19, %2
%13 = load i32, i32* %5
%14 = load i32, i32* %3
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = load float (...)*, float (...)** %4
%18 = call float (...) %17()
store float %18, float* %6
br label %19
19: ; preds = %16
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %12
22: ; preds = %12
%23 = call double (...) @get_seconds()
store double %23, double* %8
%24 = load double, double* %8
%25 = load double, double* %7
%26 = fsub double %24, %25
ret double %26
}

LLVM IR (-O2):
define double @time_func(i32 %0, float (...)* nocapture %1) {
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srandom(i32 %3)
%5 = tail call double (...) @get_seconds()
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %12
7: ; preds = %2, %7
%8 = phi i32 [ %10, %7 ], [ 0, %2 ]
%9 = tail call float (...) %1()
%10 = add nuw nsw i32 %8, 1
%11 = icmp eq i32 %10, %0
br i1 %11, label %12, label %7
12: ; preds = %7, %2
%13 = tail call double (...) @get_seconds()
%14 = fsub double %13, %5
ret double %14
}