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

/* Variables and functions */
float timeDiffFloat(struct timeval *start, struct timeval *end) {
  float secDiff = end->tv_sec - start->tv_sec;
  float usecDiff = end->tv_usec - start->tv_usec;
  if (usecDiff < 0) {
    secDiff -= 1;
    usecDiff += 1000000;
  }
  return secDiff + usecDiff / 1000000;
}


x86 assembly (clang, -O0):
<timeDiffFloat>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
subss  (%rax),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x8(%rbp),%rax
subss  0x4(%rax),%xmm0
movss  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    116d <timeDiffFloat+0x6d>
movss  -0x14(%rbp),%xmm0
movss  0xeb2(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xe9d(%rip),%xmm0
addss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
movss  0xe81(%rip),%xmm2
divss  %xmm2,%xmm1
addss  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<timeDiffFloat>:
movss  (%rsi),%xmm3
movss  0x4(%rsi),%xmm1
subss  (%rdi),%xmm3
subss  0x4(%rdi),%xmm1
xorps  %xmm4,%xmm4
ucomiss %xmm1,%xmm4
movss  0xee0(%rip),%xmm5
addss  %xmm3,%xmm5
movss  0xed8(%rip),%xmm2
movaps %xmm1,%xmm0
cmpltss %xmm4,%xmm0
andps  %xmm0,%xmm5
andnps %xmm3,%xmm0
orps   %xmm5,%xmm0
jbe    1143 <timeDiffFloat+0x43>
addss  %xmm2,%xmm1
divss  %xmm2,%xmm1
addss  %xmm1,%xmm0
ret

LLVM IR (-O0):
%struct.timeval = type { float, float }
define float @timeDiffFloat(%struct.timeval* %0, %struct.timeval* %1) {
%3 = alloca %struct.timeval*
%4 = alloca %struct.timeval*
%5 = alloca float
%6 = alloca float
store %struct.timeval* %0, %struct.timeval** %3
store %struct.timeval* %1, %struct.timeval** %4
%7 = load %struct.timeval*, %struct.timeval** %4
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%9 = load float, float* %8
%10 = load %struct.timeval*, %struct.timeval** %3
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 0
%12 = load float, float* %11
%13 = fsub float %9, %12
store float %13, float* %5
%14 = load %struct.timeval*, %struct.timeval** %4
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
%16 = load float, float* %15
%17 = load %struct.timeval*, %struct.timeval** %3
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %17, i32 0, i32 1
%19 = load float, float* %18
%20 = fsub float %16, %19
store float %20, float* %6
%21 = load float, float* %6
%22 = fcmp olt float %21, 0.000000e+00
br i1 %22, label %23, label %28
23: ; preds = %2
%24 = load float, float* %5
%25 = fsub float %24, 1.000000e+00
store float %25, float* %5
%26 = load float, float* %6
%27 = fadd float %26, 1.000000e+06
store float %27, float* %6
br label %28
28: ; preds = %23, %2
%29 = load float, float* %5
%30 = load float, float* %6
%31 = fdiv float %30, 1.000000e+06
%32 = fadd float %29, %31
ret float %32
}

LLVM IR (-O2):
%struct.timeval = type { float, float }
define float @timeDiffFloat(%struct.timeval* nocapture %0, %struct.timeval* nocapture %1) {
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%4 = load float, float* %3
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%6 = load float, float* %5
%7 = fsub float %4, %6
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%9 = load float, float* %8
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%11 = load float, float* %10
%12 = fsub float %9, %11
%13 = fcmp olt float %12, 0.000000e+00
%14 = fadd float %7, -1.000000e+00
%15 = fadd float %12, 1.000000e+06
%16 = select i1 %13, float %14, float %7
%17 = select i1 %13, float %15, float %12
%18 = fdiv float %17, 1.000000e+06
%19 = fadd float %16, %18
ret float %19
}