#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 {
  long long tv_sec;
  long long tv_usec;
};

/* Variables and functions */
double gu_timeval_diff(struct timeval *left, struct timeval *right) {
  long long diff = left->tv_sec;
  diff = ((diff - right->tv_sec) * 1000000LL) + left->tv_usec - right->tv_usec;
  return (((double)diff) * 1.0e-06);
}


x86 assembly (clang, -O0):
<gu_timeval_diff>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    (%rcx),%rax
imul   $0xf4240,%rax,%rax
mov    -0x8(%rbp),%rcx
add    0x8(%rcx),%rax
mov    -0x10(%rbp),%rcx
sub    0x8(%rcx),%rax
mov    %rax,-0x18(%rbp)
cvtsi2sdq -0x18(%rbp),%xmm0
movsd  0xeb5(%rip),%xmm1
mulsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<gu_timeval_diff>:
mov    (%rdi),%rax
sub    (%rsi),%rax
imul   $0xf4240,%rax,%rax
add    0x8(%rdi),%rax
sub    0x8(%rsi),%rax
cvtsi2sd %rax,%xmm0
mulsd  0xede(%rip),%xmm0
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
define double @gu_timeval_diff(%struct.timeval* %0, %struct.timeval* %1) {
%3 = alloca %struct.timeval*
%4 = alloca %struct.timeval*
%5 = alloca i64
store %struct.timeval* %0, %struct.timeval** %3
store %struct.timeval* %1, %struct.timeval** %4
%6 = load %struct.timeval*, %struct.timeval** %3
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%8 = load i64, i64* %7
store i64 %8, i64* %5
%9 = load i64, i64* %5
%10 = load %struct.timeval*, %struct.timeval** %4
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 0
%12 = load i64, i64* %11
%13 = sub nsw i64 %9, %12
%14 = mul nsw i64 %13, 1000000
%15 = load %struct.timeval*, %struct.timeval** %3
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 1
%17 = load i64, i64* %16
%18 = add nsw i64 %14, %17
%19 = load %struct.timeval*, %struct.timeval** %4
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 1
%21 = load i64, i64* %20
%22 = sub nsw i64 %18, %21
store i64 %22, i64* %5
%23 = load i64, i64* %5
%24 = sitofp i64 %23 to double
%25 = fmul double %24, 0x3EB0C6F7A0B5ED8D
ret double %25
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
define double @gu_timeval_diff(%struct.timeval* nocapture %0, %struct.timeval* nocapture %1) {
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%4 = load i64, i64* %3
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%6 = load i64, i64* %5
%7 = sub nsw i64 %4, %6
%8 = mul nsw i64 %7, 1000000
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%10 = load i64, i64* %9
%11 = add nsw i64 %8, %10
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%13 = load i64, i64* %12
%14 = sub i64 %11, %13
%15 = sitofp i64 %14 to double
%16 = fmul double %15, 0x3EB0C6F7A0B5ED8D
ret double %16
}