#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct timeval {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};
struct TYPE_2__ {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};
struct rusage {
  TYPE_1__ ru_utime;
};

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char const *, double);
int /*<<< orphan*/ stdout;
void report(char const *title, int iters, const struct rusage *start,
            const struct rusage *finish) {
  struct timeval result;
  result.tv_sec = finish->ru_utime.tv_sec - start->ru_utime.tv_sec;
  result.tv_usec = finish->ru_utime.tv_usec - start->ru_utime.tv_usec;
  double t = (double)result.tv_sec + (double)result.tv_usec / 1000000.0;
  printf("%-20s %6.1f ns\n", title, (t * 1000000000.0 / iters));
  fflush(stdout);
}


x86 assembly (clang, -O0):
<report>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x18(%rbp),%rcx
sub    0x8(%rcx),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
sub    (%rcx),%rax
mov    %rax,-0x30(%rbp)
cvtsi2sdq -0x28(%rbp),%xmm0
cvtsi2sdq -0x30(%rbp),%xmm1
movsd  0xe97(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rsi
movsd  0xe76(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<report>:
push   %rax
mov    (%rcx),%rax
mov    0x8(%rcx),%rcx
sub    0x8(%rdx),%rcx
sub    (%rdx),%rax
cvtsi2sd %rcx,%xmm1
cvtsi2sd %rax,%xmm0
divsd  0xebf(%rip),%xmm0
addsd  %xmm1,%xmm0
mulsd  0xebb(%rip),%xmm0
mov    %rdi,%rax
xorps  %xmm1,%xmm1
cvtsi2sd %esi,%xmm1
divsd  %xmm1,%xmm0
lea    0xeae(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
pop    %rax
jmp    1040 <fflush@plt>

LLVM IR (-O0):
%struct.rusage = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64, i64 }
%struct.timeval = type { i64, i64 }
@.str = [16 x i8] c"%-20s %6.1f ns\0A\00"
@stdout = global i32 0
define void @report(i8* %0, i32 %1, %struct.rusage* %2, %struct.rusage* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca %struct.rusage*
%8 = alloca %struct.rusage*
%9 = alloca %struct.timeval
%10 = alloca double
store i8* %0, i8** %5
store i32 %1, i32* %6
store %struct.rusage* %2, %struct.rusage** %7
store %struct.rusage* %3, %struct.rusage** %8
%11 = load %struct.rusage*, %struct.rusage** %8
%12 = getelementptr inbounds %struct.rusage, %struct.rusage* %11, i32 0, i32 0
%13 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %12, i32 0, i32 1
%14 = load i64, i64* %13
%15 = load %struct.rusage*, %struct.rusage** %7
%16 = getelementptr inbounds %struct.rusage, %struct.rusage* %15, i32 0, i32 0
%17 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %16, i32 0, i32 1
%18 = load i64, i64* %17
%19 = sub nsw i64 %14, %18
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 1
store i64 %19, i64* %20
%21 = load %struct.rusage*, %struct.rusage** %8
%22 = getelementptr inbounds %struct.rusage, %struct.rusage* %21, i32 0, i32 0
%23 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %22, i32 0, i32 0
%24 = load i64, i64* %23
%25 = load %struct.rusage*, %struct.rusage** %7
%26 = getelementptr inbounds %struct.rusage, %struct.rusage* %25, i32 0, i32 0
%27 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %26, i32 0, i32 0
%28 = load i64, i64* %27
%29 = sub nsw i64 %24, %28
%30 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
store i64 %29, i64* %30
%31 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 1
%32 = load i64, i64* %31
%33 = sitofp i64 %32 to double
%34 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
%35 = load i64, i64* %34
%36 = sitofp i64 %35 to double
%37 = fdiv double %36, 1.000000e+06
%38 = fadd double %33, %37
store double %38, double* %10
%39 = load i8*, i8** %5
%40 = load double, double* %10
%41 = fmul double %40, 1.000000e+09
%42 = load i32, i32* %6
%43 = sitofp i32 %42 to double
%44 = fdiv double %41, %43
%45 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %39, double %44)
%46 = load i32, i32* @stdout
%47 = call i32 @fflush(i32 %46)
ret void
}

LLVM IR (-O2):
%struct.rusage = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64, i64 }
@.str = [16 x i8] c"%-20s %6.1f ns\0A\00"
@stdout = global i32 0
define void @report(i8* %0, i32 %1, %struct.rusage* nocapture %2, %struct.rusage* nocapture %3) {
%5 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 0, i32 1
%6 = load i64, i64* %5
%7 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i64 0, i32 0, i32 1
%8 = load i64, i64* %7
%9 = sub nsw i64 %6, %8
%10 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 0, i32 0
%11 = load i64, i64* %10
%12 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i64 0, i32 0, i32 0
%13 = load i64, i64* %12
%14 = sub nsw i64 %11, %13
%15 = sitofp i64 %9 to double
%16 = sitofp i64 %14 to double
%17 = fdiv double %16, 1.000000e+06
%18 = fadd double %17, %15
%19 = fmul double %18, 1.000000e+09
%20 = sitofp i32 %1 to double
%21 = fdiv double %19, %20
%22 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %0, double %21)
%23 = load i32, i32* @stdout
%24 = tail call i32 @fflush(i32 %23)
ret void
}