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

/* Variables and functions */
int /*<<< orphan*/ errno;
int gettimeofday(struct timeval *, void *);
int /*<<< orphan*/ xAbort(int /*<<< orphan*/, char *);
double xTime(void) {
  struct timeval tv;
  int r = gettimeofday(&tv, ((void *)0));
  if (r == -1)
    xAbort(errno, "gettimeofday");
  return tv.tv_sec + tv.tv_usec * 1e-6;
}


x86 assembly (clang, -O0):
<xTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1157 <xTime+0x37>
mov    0x2e97(%rip),%rax
mov    (%rax),%edi
lea    0xeb6(%rip),%rsi
call   1040 <xAbort@plt>
movsd  -0x10(%rbp),%xmm1
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe97(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xTime>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
cmp    $0xffffffff,%eax
jne    114a <xTime+0x2a>
mov    0x2ea4(%rip),%rax
mov    (%rax),%edi
lea    0xec3(%rip),%rsi
call   1040 <xAbort@plt>
cvtsi2sdl 0x10(%rsp),%xmm0
mulsd  0xea8(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { double, i32 }
@errno = global i32 0
@.str = [13 x i8] c"gettimeofday\00"
define double @xTime() {
%1 = alloca %struct.timeval
%2 = alloca i32
%3 = call i32 @gettimeofday(%struct.timeval* %1, i8* null)
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = load i32, i32* @errno
%8 = call i32 @xAbort(i32 %7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %6, %0
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%11 = load double, double* %10
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%13 = load i32, i32* %12
%14 = sitofp i32 %13 to double
%15 = call double @llvm.fmuladd.f64(double %14, double 0x3EB0C6F7A0B5ED8D, double %11)
ret double %15
}

LLVM IR (-O2):
%struct.timeval = type { double, i32 }
@errno = global i32 0
@.str = [13 x i8] c"gettimeofday\00"
define double @xTime() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
%3 = call i32 @gettimeofday(%struct.timeval* %1, i8* null)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = load i32, i32* @errno
%7 = tail call i32 @xAbort(i32 %6, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %5, %0
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%10 = load double, double* %9
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%12 = load i32, i32* %11
%13 = sitofp i32 %12 to double
%14 = tail call double @llvm.fmuladd.f64(double %13, double 0x3EB0C6F7A0B5ED8D, double %10)
ret double %14
}