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

/* Variables and functions */
double timespecDiff(struct timespec *timeA_p, struct timespec *timeB_p) {
  double n, s;
  n = (double)timeA_p->tv_nsec - (double)timeB_p->tv_nsec;
  s = (double)timeA_p->tv_sec - (double)timeB_p->tv_sec;
  return (s + n * 1.0e-9);
}


x86 assembly (clang, -O0):
<timespecDiff>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cvtsi2sdq 0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
cvtsi2sdq 0x8(%rax),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cvtsi2sdq (%rax),%xmm0
mov    -0x10(%rbp),%rax
cvtsi2sdq (%rax),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
movsd  0xeaa(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<timespecDiff>:
cvtsi2sdq 0x8(%rdi),%xmm0
cvtsi2sdq 0x8(%rsi),%xmm1
subsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq (%rdi),%xmm1
cvtsi2sdq (%rsi),%xmm2
subsd  %xmm2,%xmm1
mulsd  0xed7(%rip),%xmm0
addsd  %xmm1,%xmm0
ret

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

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
define double @timespecDiff(%struct.timespec* nocapture %0, %struct.timespec* nocapture %1) {
%3 = getelementptr inbounds %struct.timespec, %struct.timespec* %0, i64 0, i32 1
%4 = load i64, i64* %3
%5 = sitofp i64 %4 to double
%6 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%7 = load i64, i64* %6
%8 = sitofp i64 %7 to double
%9 = fsub double %5, %8
%10 = getelementptr inbounds %struct.timespec, %struct.timespec* %0, i64 0, i32 0
%11 = load i64, i64* %10
%12 = sitofp i64 %11 to double
%13 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%14 = load i64, i64* %13
%15 = sitofp i64 %14 to double
%16 = fsub double %12, %15
%17 = tail call double @llvm.fmuladd.f64(double %9, double 1.000000e-09, double %16)
ret double %17
}