#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_usec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
double in_sec(struct timeval *start, struct timeval *end) {
  double st, ed;
  st = (double)start->tv_sec + ((double)start->tv_usec / 1000000.0);
  ed = (double)end->tv_sec + ((double)end->tv_usec / 1000000.0);
  return ed - st;
}


x86 assembly (clang, -O0):
<in_sec>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cvtsi2sdq 0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
cvtsi2sdq (%rax),%xmm1
movsd  0xed9(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cvtsi2sdq 0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
cvtsi2sdq (%rax),%xmm1
movsd  0xeb1(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<in_sec>:
cvtsi2sdq 0x8(%rdi),%xmm1
cvtsi2sdq (%rdi),%xmm2
movsd  0xeed(%rip),%xmm3
divsd  %xmm3,%xmm2
cvtsi2sdq 0x8(%rsi),%xmm4
cvtsi2sdq (%rsi),%xmm0
addsd  %xmm1,%xmm2
divsd  %xmm3,%xmm0
addsd  %xmm4,%xmm0
subsd  %xmm2,%xmm0
ret

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

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