#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 timespec {
  unsigned int tv_sec;
  long tv_nsec;
};

/* Variables and functions */
float msdelta(struct timespec *start, struct timespec *end) {
  unsigned sec = end->tv_sec - start->tv_sec;
  long nsec = end->tv_nsec - start->tv_nsec;
  return (float)sec * 1000 + (float)nsec / 1000000;
}


x86 assembly (clang, -O0):
<msdelta>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%ecx
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x8(%rbp),%rcx
mov    0x8(%rcx),%rcx
sub    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
cvtsi2ss %rax,%xmm0
cvtsi2ssq -0x20(%rbp),%xmm1
movss  0xeba(%rip),%xmm2
divss  %xmm2,%xmm1
movss  0xeaa(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<msdelta>:
mov    (%rsi),%eax
sub    (%rdi),%eax
mov    0x8(%rsi),%rcx
sub    0x8(%rdi),%rcx
cvtsi2ss %rax,%xmm0
cvtsi2ss %rcx,%xmm1
divss  0xee2(%rip),%xmm1
mulss  0xede(%rip),%xmm0
addss  %xmm1,%xmm0
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i64 }
define float @msdelta(%struct.timespec* %0, %struct.timespec* %1) {
%3 = alloca %struct.timespec*
%4 = alloca %struct.timespec*
%5 = alloca i32
%6 = alloca i64
store %struct.timespec* %0, %struct.timespec** %3
store %struct.timespec* %1, %struct.timespec** %4
%7 = load %struct.timespec*, %struct.timespec** %4
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i32 0, i32 0
%9 = load i32, i32* %8
%10 = load %struct.timespec*, %struct.timespec** %3
%11 = getelementptr inbounds %struct.timespec, %struct.timespec* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = sub i32 %9, %12
store i32 %13, i32* %5
%14 = load %struct.timespec*, %struct.timespec** %4
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %14, i32 0, i32 1
%16 = load i64, i64* %15
%17 = load %struct.timespec*, %struct.timespec** %3
%18 = getelementptr inbounds %struct.timespec, %struct.timespec* %17, i32 0, i32 1
%19 = load i64, i64* %18
%20 = sub nsw i64 %16, %19
store i64 %20, i64* %6
%21 = load i32, i32* %5
%22 = uitofp i32 %21 to float
%23 = load i64, i64* %6
%24 = sitofp i64 %23 to float
%25 = fdiv float %24, 1.000000e+06
%26 = call float @llvm.fmuladd.f32(float %22, float 1.000000e+03, float %25)
ret float %26
}

LLVM IR (-O2):
%struct.timespec = type { i32, i64 }
define float @msdelta(%struct.timespec* nocapture %0, %struct.timespec* nocapture %1) {
%3 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%4 = load i32, i32* %3
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %0, i64 0, i32 0
%6 = load i32, i32* %5
%7 = sub i32 %4, %6
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%9 = load i64, i64* %8
%10 = getelementptr inbounds %struct.timespec, %struct.timespec* %0, i64 0, i32 1
%11 = load i64, i64* %10
%12 = sub nsw i64 %9, %11
%13 = uitofp i32 %7 to float
%14 = sitofp i64 %12 to float
%15 = fdiv float %14, 1.000000e+06
%16 = tail call float @llvm.fmuladd.f32(float %13, float 1.000000e+03, float %15)
ret float %16
}