#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*/ printf(char *, ...);
int show_benchmark(const char *descr, double t1, double t2, size_t size,
                   int rep, const char *reptext) {
  double tdiff = t2 - t1;
  double nstime;
  printf("operation: %s\n", descr);
  printf("elapsed time: %.3f (s)\n", tdiff);
  printf("iterations: %d\n", rep);
  printf("size: %lu (bytes)\n", (unsigned long)size);
  printf("bandwidth: %.3f (MB/s)\n", (double)rep * (double)size / 1e6 / tdiff);
  printf("throughput in ops per sec: %.3f\n", rep / tdiff);
  if (reptext && rep != 1) {
    printf("throughput in %s ops per sec: %.3f\n", reptext, 1 / tdiff);
  }
  nstime = tdiff * 1e9 / rep;
  if (nstime < 1000) {
    printf("time per op: %.3f (ns)\n", nstime);
  } else if (nstime < 1e6) {
    printf("time per op: %.3f (us)\n", nstime / 1000);
  } else if (nstime < 1e9) {
    printf("time per op: %.3f (ms)\n", nstime / 1e6);
  } else {
    printf("time per op: %.3f (s)\n", nstime / 1e9);
  }
  return 0;
}


x86 assembly (clang, -O0):
<show_benchmark>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
mov    %rcx,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xef1(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x41(%rbp)
call   1030 <printf@plt>
movsd  -0x38(%rbp),%xmm0
lea    0xeea(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x41(%rbp),%al
mov    -0x24(%rbp),%esi
lea    0xeee(%rip),%rdi
call   1030 <printf@plt>
mov    -0x41(%rbp),%al
mov    -0x20(%rbp),%rsi
lea    0xeeb(%rip),%rdi
call   1030 <printf@plt>
cvtsi2sdl -0x24(%rbp),%xmm0
movaps 0xe83(%rip),%xmm2
movq   -0x20(%rbp),%xmm1
punpckldq %xmm2,%xmm1
movapd 0xe82(%rip),%xmm2
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe37(%rip),%xmm1
divsd  %xmm1,%xmm0
divsd  -0x38(%rbp),%xmm0
lea    0xeb1(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cvtsi2sdl -0x24(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
lea    0xeb1(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x30(%rbp)
je     122c <show_benchmark+0x11c>
cmpl   $0x1,-0x24(%rbp)
je     122c <show_benchmark+0x11c>
mov    -0x30(%rbp),%rsi
movsd  0xdef(%rip),%xmm0
divsd  -0x38(%rbp),%xmm0
lea    0xe9e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xde4(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xdc1(%rip),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    1272 <show_benchmark+0x162>
movsd  -0x40(%rbp),%xmm0
lea    0xe81(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1309 <show_benchmark+0x1f9>
movsd  0xd86(%rip),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    12a9 <show_benchmark+0x199>
movsd  -0x40(%rbp),%xmm0
movsd  0xd7e(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe62(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1304 <show_benchmark+0x1f4>
movsd  0xd67(%rip),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    12e0 <show_benchmark+0x1d0>
movsd  -0x40(%rbp),%xmm0
movsd  0xd37(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe43(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12ff <show_benchmark+0x1ef>
movsd  -0x40(%rbp),%xmm0
movsd  0xd2b(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe37(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1304 <show_benchmark+0x1f4>
jmp    1309 <show_benchmark+0x1f9>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_benchmark>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%rsi
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
lea    0xf0d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf0e(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xf13(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf13(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
cvtsi2sd %ebp,%xmm2
movsd  %xmm2,0x8(%rsp)
movq   %rbx,%xmm1
punpckldq 0xe7b(%rip),%xmm1
subpd  0xe83(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
divsd  0xe7b(%rip),%xmm0
divsd  (%rsp),%xmm0
lea    0xed9(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm0
divsd  (%rsp),%xmm0
lea    0xed8(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cmp    $0x1,%ebp
je     11f9 <show_benchmark+0xe9>
test   %r14,%r14
je     11f9 <show_benchmark+0xe9>
movsd  0xe45(%rip),%xmm0
divsd  (%rsp),%xmm0
lea    0xed4(%rip),%rdi
mov    %r14,%rsi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  (%rsp),%xmm0
mulsd  0xe2a(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
movsd  0xe24(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1223 <show_benchmark+0x113>
lea    0xec6(%rip),%rdi
jmp    1270 <show_benchmark+0x160>
movsd  0xdf5(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1242 <show_benchmark+0x132>
divsd  0xdff(%rip),%xmm0
lea    0xebf(%rip),%rdi
jmp    1270 <show_benchmark+0x160>
movsd  0xde6(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1261 <show_benchmark+0x151>
divsd  0xdc8(%rip),%xmm0
lea    0xeb8(%rip),%rdi
jmp    1270 <show_benchmark+0x160>
divsd  0xdc7(%rip),%xmm0
lea    0xebf(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"operation: %s\0A\00"
@.str.1 = [24 x i8] c"elapsed time: %.3f (s)\0A\00"
@.str.2 = [16 x i8] c"iterations: %d\0A\00"
@.str.3 = [19 x i8] c"size: %lu (bytes)\0A\00"
@.str.4 = [24 x i8] c"bandwidth: %.3f (MB/s)\0A\00"
@.str.5 = [33 x i8] c"throughput in ops per sec: %.3f\0A\00"
@.str.6 = [36 x i8] c"throughput in %s ops per sec: %.3f\0A\00"
@.str.7 = [24 x i8] c"time per op: %.3f (ns)\0A\00"
@.str.8 = [24 x i8] c"time per op: %.3f (us)\0A\00"
@.str.9 = [24 x i8] c"time per op: %.3f (ms)\0A\00"
@.str.10 = [23 x i8] c"time per op: %.3f (s)\0A\00"
define i32 @show_benchmark(i8* %0, double %1, double %2, i64 %3, i32 %4, i8* %5) {
%7 = alloca i8*
%8 = alloca double
%9 = alloca double
%10 = alloca i64
%11 = alloca i32
%12 = alloca i8*
%13 = alloca double
%14 = alloca double
store i8* %0, i8** %7
store double %1, double* %8
store double %2, double* %9
store i64 %3, i64* %10
store i32 %4, i32* %11
store i8* %5, i8** %12
%15 = load double, double* %9
%16 = load double, double* %8
%17 = fsub double %15, %16
store double %17, double* %13
%18 = load i8*, i8** %7
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load double, double* %13
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), double %20)
%22 = load i32, i32* %11
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = load i64, i64* %10
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i64 %24)
%26 = load i32, i32* %11
%27 = sitofp i32 %26 to double
%28 = load i64, i64* %10
%29 = uitofp i64 %28 to double
%30 = fmul double %27, %29
%31 = fdiv double %30, 1.000000e+06
%32 = load double, double* %13
%33 = fdiv double %31, %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), double %33)
%35 = load i32, i32* %11
%36 = sitofp i32 %35 to double
%37 = load double, double* %13
%38 = fdiv double %36, %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), double %38)
%40 = load i8*, i8** %12
%41 = icmp ne i8* %40, null
br i1 %41, label %42, label %50
42: ; preds = %6
%43 = load i32, i32* %11
%44 = icmp ne i32 %43, 1
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = load i8*, i8** %12
%47 = load double, double* %13
%48 = fdiv double 1.000000e+00, %47
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i8* %46, double %48)
br label %50
50: ; preds = %45, %42, %6
%51 = load double, double* %13
%52 = fmul double %51, 1.000000e+09
%53 = load i32, i32* %11
%54 = sitofp i32 %53 to double
%55 = fdiv double %52, %54
store double %55, double* %14
%56 = load double, double* %14
%57 = fcmp olt double %56, 1.000000e+03
br i1 %57, label %58, label %61
58: ; preds = %50
%59 = load double, double* %14
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), double %59)
br label %81
61: ; preds = %50
%62 = load double, double* %14
%63 = fcmp olt double %62, 1.000000e+06
br i1 %63, label %64, label %68
64: ; preds = %61
%65 = load double, double* %14
%66 = fdiv double %65, 1.000000e+03
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), double %66)
br label %80
68: ; preds = %61
%69 = load double, double* %14
%70 = fcmp olt double %69, 1.000000e+09
br i1 %70, label %71, label %75
71: ; preds = %68
%72 = load double, double* %14
%73 = fdiv double %72, 1.000000e+06
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), double %73)
br label %79
75: ; preds = %68
%76 = load double, double* %14
%77 = fdiv double %76, 1.000000e+09
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), double %77)
br label %79
79: ; preds = %75, %71
br label %80
80: ; preds = %79, %64
br label %81
81: ; preds = %80, %58
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"operation: %s\0A\00"
@.str.1 = [24 x i8] c"elapsed time: %.3f (s)\0A\00"
@.str.2 = [16 x i8] c"iterations: %d\0A\00"
@.str.3 = [19 x i8] c"size: %lu (bytes)\0A\00"
@.str.4 = [24 x i8] c"bandwidth: %.3f (MB/s)\0A\00"
@.str.5 = [33 x i8] c"throughput in ops per sec: %.3f\0A\00"
@.str.6 = [36 x i8] c"throughput in %s ops per sec: %.3f\0A\00"
@.str.7 = [24 x i8] c"time per op: %.3f (ns)\0A\00"
@.str.8 = [24 x i8] c"time per op: %.3f (us)\0A\00"
@.str.9 = [24 x i8] c"time per op: %.3f (ms)\0A\00"
@.str.10 = [23 x i8] c"time per op: %.3f (s)\0A\00"
define i32 @show_benchmark(i8* %0, double %1, double %2, i64 %3, i32 %4, i8* %5) {
%7 = fsub double %2, %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), double %7)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %4)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i64 %3)
%12 = sitofp i32 %4 to double
%13 = uitofp i64 %3 to double
%14 = fmul double %13, %12
%15 = fdiv double %14, 1.000000e+06
%16 = fdiv double %15, %7
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), double %16)
%18 = fdiv double %12, %7
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), double %18)
%20 = icmp ne i8* %5, null
%21 = icmp ne i32 %4, 1
%22 = and i1 %21, %20
br i1 %22, label %23, label %26
23: ; preds = %6
%24 = fdiv double 1.000000e+00, %7
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i8* %5, double %24)
br label %26
26: ; preds = %23, %6
%27 = fmul double %7, 1.000000e+09
%28 = fdiv double %27, %12
%29 = fcmp olt double %28, 1.000000e+03
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), double %28)
br label %45
32: ; preds = %26
%33 = fcmp olt double %28, 1.000000e+06
br i1 %33, label %34, label %37
34: ; preds = %32
%35 = fdiv double %28, 1.000000e+03
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), double %35)
br label %45
37: ; preds = %32
%38 = fcmp olt double %28, 1.000000e+09
br i1 %38, label %39, label %42
39: ; preds = %37
%40 = fdiv double %28, 1.000000e+06
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), double %40)
br label %45
42: ; preds = %37
%43 = fdiv double %28, 1.000000e+09
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), double %43)
br label %45
45: ; preds = %34, %42, %39, %30
ret i32 0
}