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

/* Variables and functions */
float get_time_diff(struct timeval *t_new, struct timeval *t_old) {
  float t_diff;
  double new_time;
  double old_time;
  new_time = (double)t_new->tv_sec + ((double)t_new->tv_usec / 1000000);
  old_time = (double)t_old->tv_sec + ((double)t_old->tv_usec / 1000000);
  t_diff = (double)new_time - (double)old_time;
  return (t_diff);
}


x86 assembly (clang, -O0):
<get_time_diff>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cvtsi2sdq 0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
cvtsi2sdq (%rax),%xmm1
movsd  0xed9(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cvtsi2sdq 0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
cvtsi2sdq (%rax),%xmm1
movsd  0xeb1(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_time_diff>:
cvtsi2sdq 0x8(%rdi),%xmm0
cvtsi2sdq (%rdi),%xmm1
movsd  0xeed(%rip),%xmm2
divsd  %xmm2,%xmm1
cvtsi2sdq 0x8(%rsi),%xmm3
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sdq (%rsi),%xmm0
divsd  %xmm2,%xmm0
addsd  %xmm3,%xmm0
subsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
ret

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

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
define float @get_time_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 = sitofp i64 %4 to double
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%7 = load i64, i64* %6
%8 = sitofp i64 %7 to double
%9 = fdiv double %8, 1.000000e+06
%10 = fadd double %9, %5
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%12 = load i64, i64* %11
%13 = sitofp i64 %12 to double
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%15 = load i64, i64* %14
%16 = sitofp i64 %15 to double
%17 = fdiv double %16, 1.000000e+06
%18 = fadd double %17, %13
%19 = fsub double %10, %18
%20 = fptrunc double %19 to float
ret float %20
}