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

/* Variables and functions */
scalar_t__ INFINITY;
scalar_t__ timeval_delta(struct timeval const *, struct timeval const *,
                         struct timeval *);
double timeval_delta_d(const struct timeval *start, const struct timeval *end) {
  struct timeval delta;
  if (timeval_delta(start, end, &delta))
    return (double)INFINITY;
  return (double)delta.tv_usec / 1000000 + (double)delta.tv_sec;
}


x86 assembly (clang, -O0):
<timeval_delta_d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1030 <timeval_delta@plt>
cmp    $0x0,%rax
je     1151 <timeval_delta_d+0x41>
mov    0x2ea6(%rip),%rax
cvtsi2sdq (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1172 <timeval_delta_d+0x62>
cvtsi2sdq -0x20(%rbp),%xmm0
movsd  0xea1(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsi2sdq -0x28(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timeval_delta_d>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdx
call   1030 <timeval_delta@plt>
test   %rax,%rax
je     1134 <timeval_delta_d+0x24>
mov    0x2ebe(%rip),%rax
cvtsi2sdq (%rax),%xmm0
add    $0x18,%rsp
ret
cvtsi2sdq 0x10(%rsp),%xmm1
divsd  0xebd(%rip),%xmm1
cvtsi2sdq 0x8(%rsp),%xmm0
addsd  %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@INFINITY = global i64 0
define double @timeval_delta_d(%struct.timeval* %0, %struct.timeval* %1) {
%3 = alloca double
%4 = alloca %struct.timeval*
%5 = alloca %struct.timeval*
%6 = alloca %struct.timeval
store %struct.timeval* %0, %struct.timeval** %4
store %struct.timeval* %1, %struct.timeval** %5
%7 = load %struct.timeval*, %struct.timeval** %4
%8 = load %struct.timeval*, %struct.timeval** %5
%9 = call i64 @timeval_delta(%struct.timeval* %7, %struct.timeval* %8, %struct.timeval* %6)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i64, i64* @INFINITY
%13 = sitofp i64 %12 to double
store double %13, double* %3
br label %23
14: ; preds = %2
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%16 = load i64, i64* %15
%17 = sitofp i64 %16 to double
%18 = fdiv double %17, 1.000000e+06
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%20 = load i64, i64* %19
%21 = sitofp i64 %20 to double
%22 = fadd double %18, %21
store double %22, double* %3
br label %23
23: ; preds = %14, %11
%24 = load double, double* %3
ret double %24
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
@INFINITY = global i64 0
define double @timeval_delta_d(%struct.timeval* %0, %struct.timeval* %1) {
%3 = alloca %struct.timeval
%4 = bitcast %struct.timeval* %3 to i8*
%5 = call i64 @timeval_delta(%struct.timeval* %0, %struct.timeval* %1, %struct.timeval* %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = load i64, i64* @INFINITY
%9 = sitofp i64 %8 to double
br label %19
10: ; preds = %2
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%12 = load i64, i64* %11
%13 = sitofp i64 %12 to double
%14 = fdiv double %13, 1.000000e+06
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%16 = load i64, i64* %15
%17 = sitofp i64 %16 to double
%18 = fadd double %14, %17
br label %19
19: ; preds = %10, %7
%20 = phi double [ %9, %7 ], [ %18, %10 ]
ret double %20
}