#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;
  scalar_t__ tv_nsec;
};

/* Variables and functions */
double get_elapsed(struct timespec t1, struct timespec t2) {
  double ft1 = t1.tv_sec + ((double)t1.tv_nsec / 1000000000.0);
  double ft2 = t2.tv_sec + ((double)t2.tv_nsec / 1000000000.0);
  return ft2 - ft1;
}


x86 assembly (clang, -O0):
<get_elapsed>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
mov    %rdi,-0x8(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
cvtsi2sdq -0x8(%rbp),%xmm1
movsd  0xed7(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdq -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):
<get_elapsed>:
cvtsi2sd %rdi,%xmm3
cvtsi2sd %rsi,%xmm2
unpcklpd %xmm3,%xmm2
divpd  0xeea(%rip),%xmm2
unpcklpd %xmm0,%xmm1
addpd  %xmm1,%xmm2
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
subsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
ret

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

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