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

/* Variables and functions */
double elapsed_ms(const struct timeval *t0, const struct timeval *t1) {
  return (t1->tv_sec * 1000 + (double)t1->tv_usec / 1000) -
         (t0->tv_sec * 1000 + (double)t0->tv_usec / 1000);
}


x86 assembly (clang, -O0):
<elapsed_ms>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
imul   $0x3e8,(%rax),%eax
cvtsi2sd %eax,%xmm0
mov    -0x10(%rbp),%rax
cvtsi2sdq 0x8(%rax),%xmm1
movsd  0xed4(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
imul   $0x3e8,(%rax),%eax
cvtsi2sd %eax,%xmm1
mov    -0x8(%rbp),%rax
cvtsi2sdq 0x8(%rax),%xmm2
movsd  0xeac(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<elapsed_ms>:
imul   $0x3e8,(%rsi),%eax
cvtsi2sd %eax,%xmm1
cvtsi2sdq 0x8(%rsi),%xmm0
movsd  0xee8(%rip),%xmm2
divsd  %xmm2,%xmm0
imul   $0x3e8,(%rdi),%eax
cvtsi2sd %eax,%xmm3
cvtsi2sdq 0x8(%rdi),%xmm4
addsd  %xmm1,%xmm0
divsd  %xmm2,%xmm4
addsd  %xmm3,%xmm4
subsd  %xmm4,%xmm0
ret

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

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
define double @elapsed_ms(%struct.timeval* nocapture %0, %struct.timeval* nocapture %1) {
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%4 = load i32, i32* %3
%5 = mul nsw i32 %4, 1000
%6 = sitofp i32 %5 to double
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%8 = load i64, i64* %7
%9 = sitofp i64 %8 to double
%10 = fdiv double %9, 1.000000e+03
%11 = fadd double %10, %6
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%13 = load i32, i32* %12
%14 = mul nsw i32 %13, 1000
%15 = sitofp i32 %14 to double
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%17 = load i64, i64* %16
%18 = sitofp i64 %17 to double
%19 = fdiv double %18, 1.000000e+03
%20 = fadd double %19, %15
%21 = fsub double %11, %20
ret double %21
}