#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 */
int /*<<< orphan*/ assert(int);
int gettimeofday(struct timeval *, int /*<<< orphan*/);
double wtime() {
  static struct timeval tv0 = {.tv_sec = 0};
  struct timeval tv;
  int cc;
  cc = gettimeofday(&tv, 0);
  assert(cc == 0);
  if (tv0.tv_sec == 0) {
    tv0 = tv;
    assert(tv0.tv_sec != 0);
  }
  double dt = ((double)(tv.tv_sec - tv0.tv_sec) +
               ((double)(tv.tv_usec - tv0.tv_usec) * 1e-6));
  return dt;
}


x86 assembly (clang, -O0):
<wtime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,0x2ee9(%rip)
jne    1180 <wtime+0x60>
mov    -0x10(%rbp),%rax
mov    %rax,0x2ed8(%rip)
mov    -0x8(%rbp),%rax
mov    %rax,0x2ed5(%rip)
cmpq   $0x0,0x2ec5(%rip)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rax
sub    0x2ead(%rip),%rax
cvtsi2sd %rax,%xmm1
mov    -0x8(%rbp),%rax
sub    0x2ea5(%rip),%rax
cvtsi2sd %rax,%xmm0
movsd  0xe58(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wtime>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
mov    0x2ef4(%rip),%rax
test   %rax,%rax
jne    116f <wtime+0x4f>
movups 0x8(%rsp),%xmm0
movups %xmm0,0x2ee3(%rip)
xor    %edi,%edi
cmpq   $0x0,0x2ed9(%rip)
setne  %dil
call   1040 <assert@plt>
mov    0x2ec9(%rip),%rax
mov    0x8(%rsp),%rcx
sub    %rax,%rcx
mov    0x10(%rsp),%rax
cvtsi2sd %rcx,%xmm1
sub    0x2eb8(%rip),%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mulsd  0xe68(%rip),%xmm0
addsd  %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@wtime.tv0 = internal global %struct.timeval zeroinitializer
define double @wtime() {
%1 = alloca %struct.timeval
%2 = alloca i32
%3 = alloca double
%4 = call i32 @gettimeofday(%struct.timeval* %1, i32 0)
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 0
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = load i64, i64* getelementptr inbounds (%struct.timeval, %struct.timeval* @wtime.tv0, i32 0, i32 0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %0
%12 = bitcast %struct.timeval* %1 to i8*
%13 = load i64, i64* getelementptr inbounds (%struct.timeval, %struct.timeval* @wtime.tv0, i32 0, i32 0)
%14 = icmp ne i64 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
br label %17
17: ; preds = %11, %0
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%19 = load i64, i64* %18
%20 = load i64, i64* getelementptr inbounds (%struct.timeval, %struct.timeval* @wtime.tv0, i32 0, i32 0)
%21 = sub nsw i64 %19, %20
%22 = sitofp i64 %21 to double
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%24 = load i64, i64* %23
%25 = load i64, i64* getelementptr inbounds (%struct.timeval, %struct.timeval* @wtime.tv0, i32 0, i32 1)
%26 = sub nsw i64 %24, %25
%27 = sitofp i64 %26 to double
%28 = call double @llvm.fmuladd.f64(double %27, double 0x3EB0C6F7A0B5ED8D, double %22)
store double %28, double* %3
%29 = load double, double* %3
ret double %29
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
@wtime.tv0 = internal unnamed_addr global %struct.timeval zeroinitializer
define double @wtime() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
%3 = call i32 @gettimeofday(%struct.timeval* %1, i32 0)
%4 = icmp eq i32 %3, 0
%5 = zext i1 %4 to i32
%6 = call i32 @assert(i32 %5)
%7 = load i64, i64* getelementptr inbounds (%struct.timeval, %struct.timeval* @wtime.tv0, i64 0, i32 0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %0
%10 = load i64, i64* getelementptr inbounds (%struct.timeval, %struct.timeval* @wtime.tv0, i64 0, i32 0)
%11 = icmp ne i64 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i64, i64* getelementptr inbounds (%struct.timeval, %struct.timeval* @wtime.tv0, i64 0, i32 0)
br label %15
15: ; preds = %9, %0
%16 = phi i64 [ %14, %9 ], [ %7, %0 ]
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%18 = load i64, i64* %17
%19 = sub nsw i64 %18, %16
%20 = sitofp i64 %19 to double
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%22 = load i64, i64* %21
%23 = load i64, i64* getelementptr inbounds (%struct.timeval, %struct.timeval* @wtime.tv0, i64 0, i32 1)
%24 = sub nsw i64 %22, %23
%25 = sitofp i64 %24 to double
%26 = call double @llvm.fmuladd.f64(double %25, double 0x3EB0C6F7A0B5ED8D, double %20)
ret double %26
}