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

/* Variables and functions */
int /*<<< orphan*/ mark_time(struct timeval *);
double time_since(struct timeval *t0) {
  struct timeval t1;
  mark_time(&t1);
  return ((double)(t1.tv_sec - t0->tv_sec)) + 1E-6 * (t1.tv_usec - t0->tv_usec);
}


x86 assembly (clang, -O0):
<time_since>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x18(%rbp),%rdi
call   1030 <mark_time@plt>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    0x8(%rcx),%rax
cvtsi2sd %rax,%xmm1
mov    -0x18(%rbp),%eax
mov    -0x8(%rbp),%rcx
sub    (%rcx),%eax
cvtsi2sd %eax,%xmm0
movsd  0xeb5(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_since>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
call   1030 <mark_time@plt>
mov    0x8(%rsp),%rax
sub    0x8(%rbx),%rax
cvtsi2sd %rax,%xmm1
mov    (%rsp),%eax
sub    (%rbx),%eax
cvtsi2sd %eax,%xmm0
mulsd  0xec1(%rip),%xmm0
addsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
define double @time_since(%struct.timeval* %0) {
%2 = alloca %struct.timeval*
%3 = alloca %struct.timeval
store %struct.timeval* %0, %struct.timeval** %2
%4 = call i32 @mark_time(%struct.timeval* %3)
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%6 = load i64, i64* %5
%7 = load %struct.timeval*, %struct.timeval** %2
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%9 = load i64, i64* %8
%10 = sub nsw i64 %6, %9
%11 = sitofp i64 %10 to double
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%13 = load i32, i32* %12
%14 = load %struct.timeval*, %struct.timeval** %2
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = sub nsw i32 %13, %16
%18 = sitofp i32 %17 to double
%19 = call double @llvm.fmuladd.f64(double 0x3EB0C6F7A0B5ED8D, double %18, double %11)
ret double %19
}

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
define double @time_since(%struct.timeval* nocapture %0) {
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %2 to i8*
%4 = call i32 @mark_time(%struct.timeval* %2)
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%6 = load i64, i64* %5
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%8 = load i64, i64* %7
%9 = sub nsw i64 %6, %8
%10 = sitofp i64 %9 to double
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%14 = load i32, i32* %13
%15 = sub nsw i32 %12, %14
%16 = sitofp i32 %15 to double
%17 = call double @llvm.fmuladd.f64(double %16, double 0x3EB0C6F7A0B5ED8D, double %10)
ret double %17
}