#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 */
int diff_ms(struct timeval *t_1, struct timeval *t_2) {
  return (float)(1000.0 * (t_2->tv_sec - t_1->tv_sec) +
                 (0.001 * (t_2->tv_usec - t_1->tv_usec)));
}


x86 assembly (clang, -O0):
<diff_ms>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x8(%rbp),%rax
subsd  0x8(%rax),%xmm2
movsd  0xed2(%rip),%xmm1
mulsd  %xmm2,%xmm1
movsd  0xebe(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
cvttss2si %xmm0,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<diff_ms>:
movsd  (%rsi),%xmm0
movsd  0x8(%rsi),%xmm1
subsd  (%rdi),%xmm0
subsd  0x8(%rdi),%xmm1
mulsd  0xee6(%rip),%xmm1
mulsd  0xee6(%rip),%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
cvttss2si %xmm0,%eax
ret

LLVM IR (-O0):
%struct.timeval = type { double, double }
define i32 @diff_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 double, double* %6
%8 = load %struct.timeval*, %struct.timeval** %3
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%10 = load double, double* %9
%11 = fsub double %7, %10
%12 = load %struct.timeval*, %struct.timeval** %4
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 1
%14 = load double, double* %13
%15 = load %struct.timeval*, %struct.timeval** %3
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 1
%17 = load double, double* %16
%18 = fsub double %14, %17
%19 = fmul double 1.000000e-03, %18
%20 = call double @llvm.fmuladd.f64(double 1.000000e+03, double %11, double %19)
%21 = fptrunc double %20 to float
%22 = fptosi float %21 to i32
ret i32 %22
}

LLVM IR (-O2):
%struct.timeval = type { double, double }
define i32 @diff_ms(%struct.timeval* nocapture %0, %struct.timeval* nocapture %1) {
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%4 = load double, double* %3
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%6 = load double, double* %5
%7 = fsub double %4, %6
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%9 = load double, double* %8
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%11 = load double, double* %10
%12 = fsub double %9, %11
%13 = fmul double %12, 1.000000e-03
%14 = tail call double @llvm.fmuladd.f64(double %7, double 1.000000e+03, double %13)
%15 = fptrunc double %14 to float
%16 = fptosi float %15 to i32
ret i32 %16
}