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

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, struct timezone *);
double Sys_DoubleTime(void) {
  struct timeval tp;
  struct timezone tzp;
  static int secbase;
  gettimeofday(&tp, &tzp);
  if (!secbase) {
    secbase = tp.tv_sec;
    return tp.tv_usec / 1000000.0;
  }
  return (tp.tv_sec - secbase) + tp.tv_usec / 1000000.0;
}


x86 assembly (clang, -O0):
<Sys_DoubleTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <gettimeofday@plt>
cmpl   $0x0,0x2f00(%rip)
jne    1156 <Sys_DoubleTime+0x46>
mov    -0x18(%rbp),%eax
mov    %eax,0x2ef1(%rip)
movsd  -0x10(%rbp),%xmm0
movsd  0xeb8(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    117d <Sys_DoubleTime+0x6d>
mov    -0x18(%rbp),%eax
sub    0x2ecd(%rip),%eax
cvtsi2sd %eax,%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xe90(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Sys_DoubleTime>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1030 <gettimeofday@plt>
mov    0x2f05(%rip),%ecx
mov    0x8(%rsp),%eax
test   %ecx,%ecx
je     114c <Sys_DoubleTime+0x3c>
sub    %ecx,%eax
cvtsi2sd %eax,%xmm1
movsd  0x10(%rsp),%xmm0
divsd  0xebd(%rip),%xmm0
addsd  %xmm1,%xmm0
add    $0x18,%rsp
ret
mov    %eax,0x2eda(%rip)
movsd  0x10(%rsp),%xmm0
divsd  0xea0(%rip),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, double }
%struct.timezone = type { i32 }
@Sys_DoubleTime.secbase = internal global i32 0
define double @Sys_DoubleTime() {
%1 = alloca double
%2 = alloca %struct.timeval
%3 = alloca %struct.timezone
%4 = call i32 @gettimeofday(%struct.timeval* %2, %struct.timezone* %3)
%5 = load i32, i32* @Sys_DoubleTime.secbase
%6 = icmp ne i32 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %0
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
%9 = load i32, i32* %8
store i32 %9, i32* @Sys_DoubleTime.secbase
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
%11 = load double, double* %10
%12 = fdiv double %11, 1.000000e+06
store double %12, double* %1
br label %23
13: ; preds = %0
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
%15 = load i32, i32* %14
%16 = load i32, i32* @Sys_DoubleTime.secbase
%17 = sub nsw i32 %15, %16
%18 = sitofp i32 %17 to double
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
%20 = load double, double* %19
%21 = fdiv double %20, 1.000000e+06
%22 = fadd double %18, %21
store double %22, double* %1
br label %23
23: ; preds = %13, %7
%24 = load double, double* %1
ret double %24
}

LLVM IR (-O2):
%struct.timeval = type { i32, double }
%struct.timezone = type { i32 }
@Sys_DoubleTime.secbase = internal unnamed_addr global i32 0
define double @Sys_DoubleTime() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timezone
%3 = bitcast %struct.timeval* %1 to i8*
%4 = bitcast %struct.timezone* %2 to i8*
%5 = call i32 @gettimeofday(%struct.timeval* %1, %struct.timezone* %2)
%6 = load i32, i32* @Sys_DoubleTime.secbase
%7 = icmp eq i32 %6, 0
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%9 = load i32, i32* %8
br i1 %7, label %10, label %14
10: ; preds = %0
store i32 %9, i32* @Sys_DoubleTime.secbase
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%12 = load double, double* %11
%13 = fdiv double %12, 1.000000e+06
br label %21
14: ; preds = %0
%15 = sub nsw i32 %9, %6
%16 = sitofp i32 %15 to double
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%18 = load double, double* %17
%19 = fdiv double %18, 1.000000e+06
%20 = fadd double %19, %16
br label %21
21: ; preds = %14, %10
%22 = phi double [ %20, %14 ], [ %13, %10 ]
ret double %22
}