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

/* Variables and functions */
double elapsed_time(struct timeval t_start, struct timeval t_end) {
  double d_start, d_end;
  d_start = t_start.tv_sec + (t_start.tv_usec / 1000000.0);
  d_end = t_end.tv_sec + (t_end.tv_usec / 1000000.0);
  return d_end - d_start;
}


x86 assembly (clang, -O0):
<elapsed_time>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x8(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  0xed6(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xeb7(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<elapsed_time>:
unpcklpd %xmm1,%xmm3
divpd  0xef4(%rip),%xmm3
unpcklpd %xmm0,%xmm2
addpd  %xmm3,%xmm2
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
subsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
ret

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

LLVM IR (-O2):
define double @elapsed_time(double %0, double %1, double %2, double %3) {
%5 = insertelement <2 x double> poison, double %3, i64 0
%6 = insertelement <2 x double> %5, double %1, i64 1
%7 = fdiv <2 x double> %6, <double 1.000000e+06, double 1.000000e+06>
%8 = insertelement <2 x double> poison, double %2, i64 0
%9 = insertelement <2 x double> %8, double %0, i64 1
%10 = fadd <2 x double> %7, %9
%11 = shufflevector <2 x double> %10, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%12 = fsub <2 x double> %10, %11
%13 = extractelement <2 x double> %12, i64 0
ret double %13
}