#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 timeval {
  int tv_sec;
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char const *, long long, float);
void print_diff(char const *msg, int iterations, struct timeval *start,
                struct timeval *stop) {
  long long micro1 = start->tv_sec * 1000000 + start->tv_usec;
  long long micro2 = stop->tv_sec * 1000000 + stop->tv_usec;
  long long diff = micro2 - micro1;
  printf("\033[32m%30s\033[0m %12lld us = %.4f us / iteration\n", msg, diff,
         (float)diff / iterations);
}


x86 assembly (clang, -O0):
<print_diff>:
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    -0x18(%rbp),%rax
imul   $0xf4240,(%rax),%eax
mov    -0x18(%rbp),%rcx
add    0x4(%rcx),%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
imul   $0xf4240,(%rax),%eax
mov    -0x20(%rbp),%rcx
add    0x4(%rcx),%eax
cltq
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
sub    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x38(%rbp),%rdx
cvtsi2ssq -0x38(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
divss  %xmm1,%xmm0
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_diff>:
movslq (%rdx),%rax
imul   $0xf4240,%rax,%r8
movslq 0x4(%rdx),%rax
add    %r8,%rax
movslq (%rcx),%rdx
imul   $0xf4240,%rdx,%r8
movslq 0x4(%rcx),%rdx
add    %r8,%rdx
sub    %rax,%rdx
cvtsi2ss %rdx,%xmm0
cvtsi2ss %esi,%xmm1
mov    %rdi,%rsi
divss  %xmm1,%xmm0
lea    0xeb4(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [47 x i8] c"\1B[32m%30s\1B[0m %12lld us = %.4f us / iteration\0A\00"
define void @print_diff(i8* %0, i32 %1, %struct.timeval* %2, %struct.timeval* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca %struct.timeval*
%8 = alloca %struct.timeval*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
store i8* %0, i8** %5
store i32 %1, i32* %6
store %struct.timeval* %2, %struct.timeval** %7
store %struct.timeval* %3, %struct.timeval** %8
%12 = load %struct.timeval*, %struct.timeval** %7
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = mul nsw i32 %14, 1000000
%16 = load %struct.timeval*, %struct.timeval** %7
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 1
%18 = load i32, i32* %17
%19 = add nsw i32 %15, %18
%20 = sext i32 %19 to i64
store i64 %20, i64* %9
%21 = load %struct.timeval*, %struct.timeval** %8
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %21, i32 0, i32 0
%23 = load i32, i32* %22
%24 = mul nsw i32 %23, 1000000
%25 = load %struct.timeval*, %struct.timeval** %8
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %25, i32 0, i32 1
%27 = load i32, i32* %26
%28 = add nsw i32 %24, %27
%29 = sext i32 %28 to i64
store i64 %29, i64* %10
%30 = load i64, i64* %10
%31 = load i64, i64* %9
%32 = sub nsw i64 %30, %31
store i64 %32, i64* %11
%33 = load i8*, i8** %5
%34 = load i64, i64* %11
%35 = load i64, i64* %11
%36 = sitofp i64 %35 to float
%37 = load i32, i32* %6
%38 = sitofp i32 %37 to float
%39 = fdiv float %36, %38
%40 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %33, i64 %34, float %39)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@.str = [47 x i8] c"\1B[32m%30s\1B[0m %12lld us = %.4f us / iteration\0A\00"
define void @print_diff(i8* %0, i32 %1, %struct.timeval* nocapture %2, %struct.timeval* nocapture %3) {
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%6 = load i32, i32* %5
%7 = mul nsw i32 %6, 1000000
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%9 = load i32, i32* %8
%10 = add nsw i32 %7, %9
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%13 = load i32, i32* %12
%14 = mul nsw i32 %13, 1000000
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%16 = load i32, i32* %15
%17 = add nsw i32 %14, %16
%18 = sext i32 %17 to i64
%19 = sub nsw i64 %18, %11
%20 = sitofp i64 %19 to float
%21 = sitofp i32 %1 to float
%22 = fdiv float %20, %21
%23 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %0, i64 %19, float %22)
ret void
}