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

/* Variables and functions */
double getTimeDifference(struct timeval *start_time, struct timeval *end_time) {
  double timediff;
  timediff = ((*end_time).tv_usec - (*start_time).tv_usec);
  timediff = timediff / 1000000;
  timediff = ((*end_time).tv_sec - (*start_time).tv_sec) + timediff;
  return timediff;
}


x86 assembly (clang, -O0):
<getTimeDifference>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xed2(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  0x8(%rax),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<getTimeDifference>:
movupd (%rsi),%xmm0
movupd (%rdi),%xmm1
subpd  %xmm1,%xmm0
movapd %xmm0,%xmm1
divsd  0xee8(%rip),%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
ret

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

LLVM IR (-O2):
%struct.timeval = type { double, double }
define double @getTimeDifference(%struct.timeval* nocapture %0, %struct.timeval* nocapture %1) {
%3 = bitcast %struct.timeval* %1 to <2 x double>*
%4 = load <2 x double>, <2 x double>* %3
%5 = bitcast %struct.timeval* %0 to <2 x double>*
%6 = load <2 x double>, <2 x double>* %5
%7 = fsub <2 x double> %4, %6
%8 = extractelement <2 x double> %7, i64 0
%9 = fdiv double %8, 1.000000e+06
%10 = extractelement <2 x double> %7, i64 1
%11 = fadd double %9, %10
ret double %11
}