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

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
double seconds() {
  static double base;
  struct timeval tv;
  gettimeofday(&tv, 0);
  if (!base)
    base = tv.tv_sec + tv.tv_usec * 1e-6;
  return tv.tv_sec + tv.tv_usec * 1e-6 - base;
}


x86 assembly (clang, -O0):
<seconds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
movsd  0x2f05(%rip),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1160 <seconds+0x50>
jp     1160 <seconds+0x50>
cvtsi2sdl -0x8(%rbp),%xmm1
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xeb0(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x2ed0(%rip)
cvtsi2sdl -0x8(%rbp),%xmm1
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xe8e(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  0x2eae(%rip),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seconds>:
push   %rax
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
movsd  0x2f0d(%rip),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
mov    (%rsp),%eax
jne    1132 <seconds+0x22>
jnp    114d <seconds+0x3d>
cvtsi2sd %eax,%xmm2
xorps  %xmm0,%xmm0
cvtsi2sdl 0x4(%rsp),%xmm0
mulsd  0xeb9(%rip),%xmm0
addsd  %xmm2,%xmm0
jmp    1175 <seconds+0x65>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sdl 0x4(%rsp),%xmm0
mulsd  0xe9b(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x2ebf(%rip)
movapd %xmm0,%xmm1
subsd  %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@seconds.base = internal global double 0.000000e+00
define double @seconds() {
%1 = alloca %struct.timeval
%2 = call i32 @gettimeofday(%struct.timeval* %1, i32 0)
%3 = load double, double* @seconds.base
%4 = fcmp une double %3, 0.000000e+00
br i1 %4, label %13, label %5
5: ; preds = %0
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%7 = load i32, i32* %6
%8 = sitofp i32 %7 to double
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%10 = load i32, i32* %9
%11 = sitofp i32 %10 to double
%12 = call double @llvm.fmuladd.f64(double %11, double 0x3EB0C6F7A0B5ED8D, double %8)
store double %12, double* @seconds.base
br label %13
13: ; preds = %5, %0
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%15 = load i32, i32* %14
%16 = sitofp i32 %15 to double
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%18 = load i32, i32* %17
%19 = sitofp i32 %18 to double
%20 = call double @llvm.fmuladd.f64(double %19, double 0x3EB0C6F7A0B5ED8D, double %16)
%21 = load double, double* @seconds.base
%22 = fsub double %20, %21
ret double %22
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@seconds.base = internal unnamed_addr global double 0.000000e+00
define double @seconds() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
%3 = call i32 @gettimeofday(%struct.timeval* %1, i32 0)
%4 = load double, double* @seconds.base
%5 = fcmp une double %4, 0.000000e+00
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%7 = load i32, i32* %6
br i1 %5, label %8, label %14
8: ; preds = %0
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%10 = load i32, i32* %9
%11 = sitofp i32 %7 to double
%12 = sitofp i32 %10 to double
%13 = call double @llvm.fmuladd.f64(double %12, double 0x3EB0C6F7A0B5ED8D, double %11)
br label %20
14: ; preds = %0
%15 = sitofp i32 %7 to double
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%17 = load i32, i32* %16
%18 = sitofp i32 %17 to double
%19 = call double @llvm.fmuladd.f64(double %18, double 0x3EB0C6F7A0B5ED8D, double %15)
store double %19, double* @seconds.base
br label %20
20: ; preds = %8, %14
%21 = phi double [ %13, %8 ], [ %19, %14 ]
%22 = phi double [ %4, %8 ], [ %19, %14 ]
%23 = fsub double %21, %22
ret double %23
}