#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 */
int /*<<< orphan*/ benchmark_func();
double calls_per_sec();
double time_func(void) {
  int const iter = 100000;
  double rate;
  while (!(rate = calls_per_sec())) {
    int n;
    for (n = iter / 4; n--;) {
      benchmark_func();
      benchmark_func();
      benchmark_func();
      benchmark_func();
    }
  }
  return rate * iter;
}


x86 assembly (clang, -O0):
<time_func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x186a0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <calls_per_sec@plt>
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setne  %al
setp   %cl
or     %cl,%al
xor    $0xff,%al
test   $0x1,%al
jne    1159 <time_func+0x39>
jmp    119a <time_func+0x7a>
movl   $0x61a8,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     1195 <time_func+0x75>
mov    $0x0,%al
call   1030 <benchmark_func@plt>
mov    $0x0,%al
call   1030 <benchmark_func@plt>
mov    $0x0,%al
call   1030 <benchmark_func@plt>
mov    $0x0,%al
call   1030 <benchmark_func@plt>
jmp    1160 <time_func+0x40>
jmp    112f <time_func+0xf>
movsd  0xe5e(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_func>:
push   %rbx
xor    %eax,%eax
call   1040 <calls_per_sec@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1179 <time_func+0x59>
jp     1179 <time_func+0x59>
mov    $0x61a8,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <benchmark_func@plt>
xor    %eax,%eax
call   1030 <benchmark_func@plt>
xor    %eax,%eax
call   1030 <benchmark_func@plt>
xor    %eax,%eax
call   1030 <benchmark_func@plt>
add    $0xffffffff,%ebx
jne    1140 <time_func+0x20>
xor    %eax,%eax
call   1040 <calls_per_sec@plt>
ucomisd 0xe98(%rip),%xmm0
mov    $0x61a8,%ebx
jne    1179 <time_func+0x59>
jnp    1140 <time_func+0x20>
mulsd  0xe7f(%rip),%xmm0
pop    %rbx
ret

LLVM IR (-O0):
define double @time_func() {
%1 = alloca i32
%2 = alloca double
%3 = alloca i32
store i32 100000, i32* %1
br label %4
4: ; preds = %18, %0
%5 = call double (...) @calls_per_sec()
store double %5, double* %2
%6 = fcmp une double %5, 0.000000e+00
%7 = xor i1 %6, true
br i1 %7, label %8, label %19
8: ; preds = %4
store i32 25000, i32* %3
br label %9
9: ; preds = %13, %8
%10 = load i32, i32* %3
%11 = add nsw i32 %10, -1
store i32 %11, i32* %3
%12 = icmp ne i32 %10, 0
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = call i32 (...) @benchmark_func()
%15 = call i32 (...) @benchmark_func()
%16 = call i32 (...) @benchmark_func()
%17 = call i32 (...) @benchmark_func()
br label %9
18: ; preds = %9
br label %4
19: ; preds = %4
%20 = load double, double* %2
%21 = fmul double %20, 1.000000e+05
ret double %21
}

LLVM IR (-O2):
define double @time_func() {
%1 = tail call double (...) @calls_per_sec()
%2 = fcmp oeq double %1, 0.000000e+00
br i1 %2, label %6, label %16
3: ; preds = %6
%4 = tail call double (...) @calls_per_sec()
%5 = fcmp oeq double %4, 0.000000e+00
br i1 %5, label %14, label %16
6: ; preds = %0, %14
%7 = phi i32 [ %15, %14 ], [ 25000, %0 ]
%8 = add nsw i32 %7, -1
%9 = tail call i32 (...) @benchmark_func()
%10 = tail call i32 (...) @benchmark_func()
%11 = tail call i32 (...) @benchmark_func()
%12 = tail call i32 (...) @benchmark_func()
%13 = icmp eq i32 %8, 0
br i1 %13, label %3, label %14
14: ; preds = %6, %3
%15 = phi i32 [ %8, %6 ], [ 25000, %3 ]
br label %6
16: ; preds = %3, %0
%17 = phi double [ %1, %0 ], [ %4, %3 ]
%18 = fmul double %17, 1.000000e+05
ret double %18
}