#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 */
struct timespec {
  int tv_nsec;
  int tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ MSG(char *, double);
void report_time(struct timespec *t1, struct timespec *t2, int n) {
  double T1 = t1->tv_nsec + t1->tv_sec * 1E9;
  double T2 = t2->tv_nsec + t2->tv_sec * 1E9;
  MSG("Performance: %f nsec/loop\n", (T2 - T1) / n);
}


x86 assembly (clang, -O0):
<report_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
cvtsi2sdl (%rax),%xmm1
mov    -0x8(%rbp),%rax
cvtsi2sdl 0x4(%rax),%xmm0
movsd  0xec4(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cvtsi2sdl (%rax),%xmm1
mov    -0x10(%rbp),%rax
cvtsi2sdl 0x4(%rax),%xmm0
movsd  0xe9e(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xe7f(%rip),%rdi
call   1030 <MSG@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<report_time>:
movss  (%rdi),%xmm0
movss  (%rsi),%xmm1
unpcklps %xmm0,%xmm1
cvtdq2pd %xmm1,%xmm1
movss  0x4(%rdi),%xmm0
movss  0x4(%rsi),%xmm2
unpcklps %xmm0,%xmm2
cvtdq2pd %xmm2,%xmm0
mulpd  0xec8(%rip),%xmm0
addpd  %xmm1,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
subsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %edx,%xmm1
divsd  %xmm1,%xmm0
lea    0xeb6(%rip),%rdi
jmp    1030 <MSG@plt>

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
@.str = [27 x i8] c"Performance: %f nsec/loop\0A\00"
define void @report_time(%struct.timespec* %0, %struct.timespec* %1, i32 %2) {
%4 = alloca %struct.timespec*
%5 = alloca %struct.timespec*
%6 = alloca i32
%7 = alloca double
%8 = alloca double
store %struct.timespec* %0, %struct.timespec** %4
store %struct.timespec* %1, %struct.timespec** %5
store i32 %2, i32* %6
%9 = load %struct.timespec*, %struct.timespec** %4
%10 = getelementptr inbounds %struct.timespec, %struct.timespec* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = sitofp i32 %11 to double
%13 = load %struct.timespec*, %struct.timespec** %4
%14 = getelementptr inbounds %struct.timespec, %struct.timespec* %13, i32 0, i32 1
%15 = load i32, i32* %14
%16 = sitofp i32 %15 to double
%17 = call double @llvm.fmuladd.f64(double %16, double 1.000000e+09, double %12)
store double %17, double* %7
%18 = load %struct.timespec*, %struct.timespec** %5
%19 = getelementptr inbounds %struct.timespec, %struct.timespec* %18, i32 0, i32 0
%20 = load i32, i32* %19
%21 = sitofp i32 %20 to double
%22 = load %struct.timespec*, %struct.timespec** %5
%23 = getelementptr inbounds %struct.timespec, %struct.timespec* %22, i32 0, i32 1
%24 = load i32, i32* %23
%25 = sitofp i32 %24 to double
%26 = call double @llvm.fmuladd.f64(double %25, double 1.000000e+09, double %21)
store double %26, double* %8
%27 = load double, double* %8
%28 = load double, double* %7
%29 = fsub double %27, %28
%30 = load i32, i32* %6
%31 = sitofp i32 %30 to double
%32 = fdiv double %29, %31
%33 = call i32 @MSG(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), double %32)
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
@.str = [27 x i8] c"Performance: %f nsec/loop\0A\00"
define void @report_time(%struct.timespec* nocapture %0, %struct.timespec* nocapture %1, i32 %2) {
%4 = getelementptr inbounds %struct.timespec, %struct.timespec* %0, i64 0, i32 0
%5 = load i32, i32* %4
%6 = getelementptr inbounds %struct.timespec, %struct.timespec* %0, i64 0, i32 1
%7 = load i32, i32* %6
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%9 = load i32, i32* %8
%10 = insertelement <2 x i32> poison, i32 %9, i64 0
%11 = insertelement <2 x i32> %10, i32 %5, i64 1
%12 = sitofp <2 x i32> %11 to <2 x double>
%13 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%14 = load i32, i32* %13
%15 = insertelement <2 x i32> poison, i32 %14, i64 0
%16 = insertelement <2 x i32> %15, i32 %7, i64 1
%17 = sitofp <2 x i32> %16 to <2 x double>
%18 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %17, <2 x double> <double 1.000000e+09, double 1.000000e+09>, <2 x double> %12)
%19 = shufflevector <2 x double> %18, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%20 = fsub <2 x double> %18, %19
%21 = extractelement <2 x double> %20, i64 0
%22 = sitofp i32 %2 to double
%23 = fdiv double %21, %22
%24 = tail call i32 @MSG(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), double %23)
ret void
}