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

/* Variables and functions */
double timespec_diff(struct timespec now, struct timespec before) {
  double dt = (now.tv_sec + now.tv_nsec / 1000000000.0) -
              (before.tv_sec + before.tv_nsec / 1000000000.0);
  return dt;
}


x86 assembly (clang, -O0):
<timespec_diff>:
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  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  0xebc(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
pop    %rbp
ret

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

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

LLVM IR (-O2):
define double @timespec_diff(double %0, double %1, double %2, double %3) {
%5 = insertelement <2 x double> poison, double %1, i64 0
%6 = insertelement <2 x double> %5, double %3, i64 1
%7 = fdiv <2 x double> %6, <double 1.000000e+09, double 1.000000e+09>
%8 = insertelement <2 x double> poison, double %0, i64 0
%9 = insertelement <2 x double> %8, double %2, 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
}