#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 */
long double timediff(struct timeval start, struct timeval end) {
  long double ta, tb;
  ta = start.tv_sec + start.tv_usec * 0.000001;
  tb = end.tv_sec + end.tv_usec * 0.000001;
  return tb - ta;
}


x86 assembly (clang, -O0):
<timediff>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x8(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  0xed6(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
fldl   -0x48(%rbp)
fstpt  -0x30(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
fldl   -0x50(%rbp)
fstpt  -0x40(%rbp)
fldt   -0x40(%rbp)
fldt   -0x30(%rbp)
fsubrp %st,%st(1)
pop    %rbp
ret

x86 assembly (clang, -O2):
<timediff>:
movsd  0xef8(%rip),%xmm4
mulsd  %xmm4,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,-0x8(%rsp)
mulsd  %xmm4,%xmm3
addsd  %xmm2,%xmm3
movsd  %xmm3,-0x10(%rsp)
fldl   -0x10(%rsp)
fsubl  -0x8(%rsp)
ret

LLVM IR (-O0):
%struct.timeval = type { double, double }
define x86_fp80 @timediff(double %0, double %1, double %2, double %3) {
%5 = alloca %struct.timeval
%6 = alloca %struct.timeval
%7 = alloca x86_fp80
%8 = alloca x86_fp80
%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 = call double @llvm.fmuladd.f64(double %18, double 0x3EB0C6F7A0B5ED8D, double %16)
%20 = fpext double %19 to x86_fp80
store x86_fp80 %20, x86_fp80* %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 = call double @llvm.fmuladd.f64(double %24, double 0x3EB0C6F7A0B5ED8D, double %22)
%26 = fpext double %25 to x86_fp80
store x86_fp80 %26, x86_fp80* %8
%27 = load x86_fp80, x86_fp80* %8
%28 = load x86_fp80, x86_fp80* %7
%29 = fsub x86_fp80 %27, %28
ret x86_fp80 %29
}

LLVM IR (-O2):
define x86_fp80 @timediff(double %0, double %1, double %2, double %3) {
%5 = tail call double @llvm.fmuladd.f64(double %1, double 0x3EB0C6F7A0B5ED8D, double %0)
%6 = fpext double %5 to x86_fp80
%7 = tail call double @llvm.fmuladd.f64(double %3, double 0x3EB0C6F7A0B5ED8D, double %2)
%8 = fpext double %7 to x86_fp80
%9 = fsub x86_fp80 %8, %6
ret x86_fp80 %9
}