#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__ int64_t;

/* Variables and functions */
scalar_t__ clock_micro();
int /*<<< orphan*/ printf(char *, char const *, long long, double, double);
int /*<<< orphan*/ ut_pass();
void ut_benchmark(const char *label, int64_t iter,
                  void (*func)(int64_t iter, void *ctx), void *ctx) {
  int64_t start = clock_micro();
  int64_t dt;
  func(iter, ctx);
  dt = clock_micro() - start;
  ut_pass();
  printf("%s: %lld iterations in %0.3f msecs. (%g iterations/msec)\n", label,
         (long long)iter, (double)dt / 1000.0,
         (double)iter * 1000.0 / (double)dt);
}


x86 assembly (clang, -O0):
<ut_benchmark>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    $0x0,%al
call   1030 <clock_micro@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   *%rax
mov    $0x0,%al
call   1030 <clock_micro@plt>
sub    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1050 <ut_pass@plt>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
cvtsi2sdq -0x30(%rbp),%xmm0
movsd  0xe73(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsi2sdq -0x10(%rbp),%xmm1
movsd  0xe61(%rip),%xmm2
mulsd  %xmm2,%xmm1
cvtsi2sdq -0x30(%rbp),%xmm2
divsd  %xmm2,%xmm1
lea    0xe54(%rip),%rdi
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ut_benchmark>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbp
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <clock_micro@plt>
mov    %rax,%r13
mov    %rbp,%rdi
mov    %r15,%rsi
call   *%r12
xor    %eax,%eax
call   1030 <clock_micro@plt>
mov    %rax,%rbx
sub    %r13,%rbx
xor    %eax,%eax
call   1050 <ut_pass@plt>
cvtsi2sd %rbx,%xmm0
movsd  0xe85(%rip),%xmm2
cvtsi2sd %rbp,%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm0,%xmm1
divsd  %xmm2,%xmm0
lea    0xe75(%rip),%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [58 x i8] c"%s: %lld iterations in %0.3f msecs. (%g iterations/msec)\0A\00"
define void @ut_benchmark(i8* %0, i64 %1, void (i64, i8*)* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca void (i64, i8*)*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
store i8* %0, i8** %5
store i64 %1, i64* %6
store void (i64, i8*)* %2, void (i64, i8*)** %7
store i8* %3, i8** %8
%11 = call i64 (...) @clock_micro()
store i64 %11, i64* %9
%12 = load void (i64, i8*)*, void (i64, i8*)** %7
%13 = load i64, i64* %6
%14 = load i8*, i8** %8
%15 = call i64 (...) @clock_micro()
%16 = load i64, i64* %9
%17 = sub nsw i64 %15, %16
store i64 %17, i64* %10
%18 = call i32 (...) @ut_pass()
%19 = load i8*, i8** %5
%20 = load i64, i64* %6
%21 = load i64, i64* %10
%22 = sitofp i64 %21 to double
%23 = fdiv double %22, 1.000000e+03
%24 = load i64, i64* %6
%25 = sitofp i64 %24 to double
%26 = fmul double %25, 1.000000e+03
%27 = load i64, i64* %10
%28 = sitofp i64 %27 to double
%29 = fdiv double %26, %28
%30 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i8* %19, i64 %20, double %23, double %29)
ret void
}

LLVM IR (-O2):
@.str = [58 x i8] c"%s: %lld iterations in %0.3f msecs. (%g iterations/msec)\0A\00"
define void @ut_benchmark(i8* %0, i64 %1, void (i64, i8*)* nocapture %2, i8* %3) {
%5 = tail call i64 (...) @clock_micro()
tail call void %2(i64 %1, i8* %3)
%6 = tail call i64 (...) @clock_micro()
%7 = sub nsw i64 %6, %5
%8 = tail call i32 (...) @ut_pass()
%9 = sitofp i64 %7 to double
%10 = fdiv double %9, 1.000000e+03
%11 = sitofp i64 %1 to double
%12 = fmul double %11, 1.000000e+03
%13 = fdiv double %12, %9
%14 = tail call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i8* %0, i64 %1, double %10, double %13)
ret void
}