#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 {
  double tv_sec;
  int tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char const *, size_t, double const,
                          double const, int);
void print_times(const char *test_name, size_t num_messages,
                 const struct timespec *start, const struct timespec *stop) {
  const double t = (stop->tv_sec + stop->tv_nsec * 1e-9) -
                   (start->tv_sec + start->tv_nsec * 1e-9),
               rate = num_messages / t;
  printf("-- %s: %zuK messages in %0.3f s (%.0fK msg/s, %.3f µs/msg)\n",
         test_name, num_messages / 1000, t, rate / 1000., 1000000. / rate);
}


x86 assembly (clang, -O0):
<print_times>:
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    -0x20(%rbp),%rax
movsd  (%rax),%xmm1
cvtsi2sdl 0x8(%rax),%xmm0
movsd  0xed3(%rip),%xmm3
mulsd  %xmm3,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
cvtsi2sdl 0x8(%rax),%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movaps 0xeb6(%rip),%xmm1
movq   -0x10(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xeb5(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rdx
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  0xe4d(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  0xe39(%rip),%xmm2
divsd  -0x30(%rbp),%xmm2
cvttsd2si %xmm2,%ecx
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_times>:
movss  0x8(%rdx),%xmm0
movss  0x8(%rcx),%xmm1
unpcklps %xmm0,%xmm1
cvtdq2pd %xmm1,%xmm0
movsd  (%rcx),%xmm1
movhpd (%rdx),%xmm1
mulpd  0xecf(%rip),%xmm0
mov    %rsi,%rax
mov    %rdi,%rsi
addpd  %xmm1,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
movq   %rax,%xmm2
punpckldq 0xec0(%rip),%xmm2
subpd  0xec8(%rip),%xmm2
subsd  %xmm1,%xmm0
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm0,%xmm1
shr    $0x3,%rax
movabs $0x20c49ba5e353f7cf,%rcx
9b c4 20
mul    %rcx
movsd  0xeb3(%rip),%xmm2
divsd  %xmm1,%xmm2
divsd  0xe9f(%rip),%xmm1
shr    $0x4,%rdx
cvttsd2si %xmm2,%ecx
lea    0xea0(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.timespec = type { double, i32 }
@.str = [61 x i8] c"-- %s: %zuK messages in %0.3f s (%.0fK msg/s, %.3f \C2\B5s/msg)\0A\00"
define void @print_times(i8* %0, i64 %1, %struct.timespec* %2, %struct.timespec* %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca %struct.timespec*
%8 = alloca %struct.timespec*
%9 = alloca double
%10 = alloca double
store i8* %0, i8** %5
store i64 %1, i64* %6
store %struct.timespec* %2, %struct.timespec** %7
store %struct.timespec* %3, %struct.timespec** %8
%11 = load %struct.timespec*, %struct.timespec** %8
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%13 = load double, double* %12
%14 = load %struct.timespec*, %struct.timespec** %8
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %14, i32 0, i32 1
%16 = load i32, i32* %15
%17 = sitofp i32 %16 to double
%18 = call double @llvm.fmuladd.f64(double %17, double 1.000000e-09, double %13)
%19 = load %struct.timespec*, %struct.timespec** %7
%20 = getelementptr inbounds %struct.timespec, %struct.timespec* %19, i32 0, i32 0
%21 = load double, double* %20
%22 = load %struct.timespec*, %struct.timespec** %7
%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)
%27 = fsub double %18, %26
store double %27, double* %9
%28 = load i64, i64* %6
%29 = uitofp i64 %28 to double
%30 = load double, double* %9
%31 = fdiv double %29, %30
store double %31, double* %10
%32 = load i8*, i8** %5
%33 = load i64, i64* %6
%34 = udiv i64 %33, 1000
%35 = load double, double* %9
%36 = load double, double* %10
%37 = fdiv double %36, 1.000000e+03
%38 = load double, double* %10
%39 = fdiv double 1.000000e+06, %38
%40 = fptosi double %39 to i32
%41 = call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i8* %32, i64 %34, double %35, double %37, i32 %40)
ret void
}

LLVM IR (-O2):
%struct.timespec = type { double, i32 }
@.str = [61 x i8] c"-- %s: %zuK messages in %0.3f s (%.0fK msg/s, %.3f \C2\B5s/msg)\0A\00"
define void @print_times(i8* %0, i64 %1, %struct.timespec* nocapture %2, %struct.timespec* nocapture %3) {
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 0
%6 = load double, double* %5
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 1
%8 = load i32, i32* %7
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
%10 = load double, double* %9
%11 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
%12 = load i32, i32* %11
%13 = insertelement <2 x i32> poison, i32 %8, i64 0
%14 = insertelement <2 x i32> %13, i32 %12, i64 1
%15 = sitofp <2 x i32> %14 to <2 x double>
%16 = insertelement <2 x double> poison, double %6, i64 0
%17 = insertelement <2 x double> %16, double %10, i64 1
%18 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %15, <2 x double> <double 1.000000e-09, double 1.000000e-09>, <2 x double> %17)
%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 = uitofp i64 %1 to double
%23 = fdiv double %22, %21
%24 = udiv i64 %1, 1000
%25 = fdiv double %23, 1.000000e+03
%26 = fdiv double 1.000000e+06, %23
%27 = fptosi double %26 to i32
%28 = tail call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i8* %0, i64 %24, double %21, double %25, i32 %27)
ret void
}