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

/* Variables and functions */
double elapsedMicroseconds(struct timeval x, struct timeval y) {
  double x_ms, y_ms, diff;
  x_ms = (double)x.tv_sec * 1000000 + (double)x.tv_usec;
  y_ms = (double)y.tv_sec * 1000000 + (double)y.tv_usec;
  diff = (double)y_ms - (double)x_ms;
  return diff;
}


x86 assembly (clang, -O0):
<elapsedMicroseconds>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x8(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x18(%rbp)
cvtsi2sdq -0x8(%rbp),%xmm0
cvtsi2sdq -0x10(%rbp),%xmm1
movsd  0xed8(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdq -0x18(%rbp),%xmm0
cvtsi2sdq -0x20(%rbp),%xmm1
movsd  0xeb7(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<elapsedMicroseconds>:
cvtsi2sd %rsi,%xmm1
cvtsi2sd %rdi,%xmm2
movsd  0xeee(%rip),%xmm3
mulsd  %xmm3,%xmm1
cvtsi2sd %rcx,%xmm0
cvtsi2sd %rdx,%xmm4
addsd  %xmm2,%xmm1
mulsd  %xmm3,%xmm0
addsd  %xmm4,%xmm0
subsd  %xmm1,%xmm0
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
define double @elapsedMicroseconds(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca %struct.timeval
%6 = alloca %struct.timeval
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = bitcast %struct.timeval* %5 to { i64, i64 }*
%11 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %10, i32 0, i32 0
store i64 %0, i64* %11
%12 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %10, i32 0, i32 1
store i64 %1, i64* %12
%13 = bitcast %struct.timeval* %6 to { i64, i64 }*
%14 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %13, i32 0, i32 0
store i64 %2, i64* %14
%15 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %13, i32 0, i32 1
store i64 %3, i64* %15
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%17 = load i64, i64* %16
%18 = sitofp i64 %17 to double
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%20 = load i64, i64* %19
%21 = sitofp i64 %20 to double
%22 = call double @llvm.fmuladd.f64(double %18, double 1.000000e+06, double %21)
store double %22, double* %7
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%24 = load i64, i64* %23
%25 = sitofp i64 %24 to double
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%27 = load i64, i64* %26
%28 = sitofp i64 %27 to double
%29 = call double @llvm.fmuladd.f64(double %25, double 1.000000e+06, double %28)
store double %29, double* %8
%30 = load double, double* %8
%31 = load double, double* %7
%32 = fsub double %30, %31
store double %32, double* %9
%33 = load double, double* %9
ret double %33
}

LLVM IR (-O2):
define double @elapsedMicroseconds(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = sitofp i64 %1 to double
%6 = sitofp i64 %0 to double
%7 = tail call double @llvm.fmuladd.f64(double %5, double 1.000000e+06, double %6)
%8 = sitofp i64 %3 to double
%9 = sitofp i64 %2 to double
%10 = tail call double @llvm.fmuladd.f64(double %8, double 1.000000e+06, double %9)
%11 = fsub double %10, %7
ret double %11
}