#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 timezone {
  int dummy;
};
struct timeval {
  long tv_sec;
  double tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, struct timezone *);
double fgetwtod_() {
  static double wtod;
  static long time0;
  static int init = 0;
  static struct timeval tod;
  static struct timezone tz;
  gettimeofday(&tod, &tz);
  if (init == 0) {
    init = 1;
    time0 = tod.tv_sec;
  }
  wtod = (tod.tv_sec - time0) + tod.tv_usec * 1.0e-6;
  return (wtod);
}


x86 assembly (clang, -O0):
<fgetwtod_>:
push   %rbp
mov    %rsp,%rbp
lea    0x2f2d(%rip),%rdi
lea    0x2f36(%rip),%rsi
call   1030 <gettimeofday@plt>
cmpl   $0x0,0x2f12(%rip)
jne    114c <fgetwtod_+0x3c>
movl   $0x1,0x2f02(%rip)
mov    0x2f03(%rip),%rax
mov    %rax,0x2eec(%rip)
mov    0x2ef5(%rip),%rax
sub    0x2ede(%rip),%rax
cvtsi2sd %rax,%xmm1
movsd  0x2ee9(%rip),%xmm0
movsd  0xe91(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x2eb1(%rip)
movsd  0x2ea9(%rip),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<fgetwtod_>:
push   %rax
lea    0x2f28(%rip),%rdi
lea    0x2f31(%rip),%rsi
call   1030 <gettimeofday@plt>
cmpb   $0x1,0x2f0d(%rip)
jne    113d <fgetwtod_+0x2d>
mov    0x2f0c(%rip),%rcx
mov    0x2ef5(%rip),%rax
jmp    1155 <fgetwtod_+0x45>
movb   $0x1,0x2ef4(%rip)
mov    0x2ef5(%rip),%rax
mov    %rax,0x2ede(%rip)
mov    %rax,%rcx
sub    %rax,%rcx
cvtsi2sd %rcx,%xmm1
movsd  0x2ee3(%rip),%xmm0
mulsd  0xe93(%rip),%xmm0
addsd  %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
%struct.timeval = type { i64, double }
%struct.timezone = type { i32 }
@fgetwtod_.wtod = internal global double 0.000000e+00
@fgetwtod_.time0 = internal global i64 0
@fgetwtod_.init = internal global i32 0
@fgetwtod_.tod = internal global %struct.timeval zeroinitializer
@fgetwtod_.tz = internal global %struct.timezone zeroinitializer
define double @fgetwtod_() {
%1 = call i32 @gettimeofday(%struct.timeval* @fgetwtod_.tod, %struct.timezone* @fgetwtod_.tz)
%2 = load i32, i32* @fgetwtod_.init
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
store i32 1, i32* @fgetwtod_.init
%5 = load i64, i64* getelementptr inbounds (%struct.timeval, %struct.timeval* @fgetwtod_.tod, i32 0, i32 0)
store i64 %5, i64* @fgetwtod_.time0
br label %6
6: ; preds = %4, %0
%7 = load i64, i64* getelementptr inbounds (%struct.timeval, %struct.timeval* @fgetwtod_.tod, i32 0, i32 0)
%8 = load i64, i64* @fgetwtod_.time0
%9 = sub nsw i64 %7, %8
%10 = sitofp i64 %9 to double
%11 = load double, double* getelementptr inbounds (%struct.timeval, %struct.timeval* @fgetwtod_.tod, i32 0, i32 1)
%12 = call double @llvm.fmuladd.f64(double %11, double 0x3EB0C6F7A0B5ED8D, double %10)
store double %12, double* @fgetwtod_.wtod
%13 = load double, double* @fgetwtod_.wtod
ret double %13
}

LLVM IR (-O2):
%struct.timeval = type { i64, double }
%struct.timezone = type { i32 }
@fgetwtod_.time0 = internal unnamed_addr global i64 0
@fgetwtod_.init = internal unnamed_addr global i1 false
@fgetwtod_.tod = internal global %struct.timeval zeroinitializer
@fgetwtod_.tz = internal global %struct.timezone zeroinitializer
define double @fgetwtod_() {
%1 = tail call i32 @gettimeofday(%struct.timeval* @fgetwtod_.tod, %struct.timezone* @fgetwtod_.tz)
%2 = load i1, i1* @fgetwtod_.init
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = load i64, i64* getelementptr inbounds (%struct.timeval, %struct.timeval* @fgetwtod_.tod, i64 0, i32 0)
%5 = load i64, i64* @fgetwtod_.time0
br label %8
6: ; preds = %0
store i1 true, i1* @fgetwtod_.init
%7 = load i64, i64* getelementptr inbounds (%struct.timeval, %struct.timeval* @fgetwtod_.tod, i64 0, i32 0)
store i64 %7, i64* @fgetwtod_.time0
br label %8
8: ; preds = %3, %6
%9 = phi i64 [ %5, %3 ], [ %7, %6 ]
%10 = phi i64 [ %4, %3 ], [ %7, %6 ]
%11 = sub nsw i64 %10, %9
%12 = sitofp i64 %11 to double
%13 = load double, double* getelementptr inbounds (%struct.timeval, %struct.timeval* @fgetwtod_.tod, i64 0, i32 1)
%14 = tail call double @llvm.fmuladd.f64(double %13, double 0x3EB0C6F7A0B5ED8D, double %12)
ret double %14
}