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

/* Variables and functions */
double tv_diff(struct timeval *new, struct timeval *old) {
  double new_d, old_d;
  new_d = (double)new->tv_sec;
  new_d += new->tv_usec / 1000000.0;
  old_d = (double)old->tv_sec;
  old_d += old->tv_usec / 1000000.0;
  return (new_d - old_d);
}


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

x86 assembly (clang, -O2):
<tv_diff>:
cvtsi2sdq 0x8(%rsi),%xmm1
cvtsi2sdq 0x8(%rdi),%xmm2
movsd  (%rdi),%xmm0
movhpd (%rsi),%xmm0
divpd  0xee4(%rip),%xmm0
unpcklpd %xmm1,%xmm2
addpd  %xmm2,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
subsd  %xmm1,%xmm0
ret

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

LLVM IR (-O2):
%struct.timeval = type { double, i64 }
define double @tv_diff(%struct.timeval* nocapture %0, %struct.timeval* nocapture %1) {
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%4 = load i64, i64* %3
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%6 = load double, double* %5
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%8 = load i64, i64* %7
%9 = insertelement <2 x i64> poison, i64 %4, i64 0
%10 = insertelement <2 x i64> %9, i64 %8, i64 1
%11 = sitofp <2 x i64> %10 to <2 x double>
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%13 = load double, double* %12
%14 = insertelement <2 x double> poison, double %6, i64 0
%15 = insertelement <2 x double> %14, double %13, i64 1
%16 = fdiv <2 x double> %15, <double 1.000000e+06, double 1.000000e+06>
%17 = fadd <2 x double> %16, %11
%18 = shufflevector <2 x double> %17, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%19 = fsub <2 x double> %17, %18
%20 = extractelement <2 x double> %19, i64 0
ret double %20
}