#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 */
typedef double time_t;
struct timeval {
  double tv_sec;
  double tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ ccnl_get_timeval(struct timeval *);
double CCNL_NOW() {
  struct timeval tv;
  static time_t start;
  static time_t start_usec;
  ccnl_get_timeval(&tv);
  if (!start) {
    start = tv.tv_sec;
    start_usec = tv.tv_usec;
  }
  return (double)(tv.tv_sec) - start +
         ((double)(tv.tv_usec) - start_usec) / 1000000;
}


x86 assembly (clang, -O0):
<CCNL_NOW>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x10(%rbp),%rdi
call   1030 <ccnl_get_timeval@plt>
movsd  0x2f07(%rip),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1156 <CCNL_NOW+0x46>
jp     1156 <CCNL_NOW+0x46>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,0x2ee7(%rip)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,0x2ee2(%rip)
movsd  -0x10(%rbp),%xmm0
subsd  0x2ecd(%rip),%xmm0
movsd  -0x8(%rbp),%xmm1
subsd  0x2ec8(%rip),%xmm1
movsd  0xe88(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CCNL_NOW>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
call   1030 <ccnl_get_timeval@plt>
movsd  0x2f0a(%rip),%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm1
jne    1138 <CCNL_NOW+0x28>
jnp    1148 <CCNL_NOW+0x38>
movsd  0x10(%rsp),%xmm0
movsd  0x2ef2(%rip),%xmm3
jmp    1166 <CCNL_NOW+0x56>
movsd  %xmm1,0x2ee0(%rip)
movsd  0x10(%rsp),%xmm3
movsd  %xmm3,0x2eda(%rip)
movapd %xmm3,%xmm0
movapd %xmm1,%xmm2
subsd  %xmm3,%xmm0
subsd  %xmm2,%xmm1
divsd  0xe8a(%rip),%xmm0
addsd  %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { double, double }
@CCNL_NOW.start = internal global double 0.000000e+00
@CCNL_NOW.start_usec = internal global double 0.000000e+00
define double @CCNL_NOW() {
%1 = alloca %struct.timeval
%2 = call i32 @ccnl_get_timeval(%struct.timeval* %1)
%3 = load double, double* @CCNL_NOW.start
%4 = fcmp une double %3, 0.000000e+00
br i1 %4, label %10, label %5
5: ; preds = %0
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%7 = load double, double* %6
store double %7, double* @CCNL_NOW.start
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%9 = load double, double* %8
store double %9, double* @CCNL_NOW.start_usec
br label %10
10: ; preds = %5, %0
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%12 = load double, double* %11
%13 = load double, double* @CCNL_NOW.start
%14 = fsub double %12, %13
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%16 = load double, double* %15
%17 = load double, double* @CCNL_NOW.start_usec
%18 = fsub double %16, %17
%19 = fdiv double %18, 1.000000e+06
%20 = fadd double %14, %19
ret double %20
}

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