#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 timespec {
  scalar_t__ tv_sec;
  scalar_t__ tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
scalar_t__ clock_gettime(int /*<<< orphan*/, struct timespec *);
double julian_centuries(double *nowp) {
  struct timespec now;
  if (clock_gettime(CLOCK_REALTIME, &now))
    return -1;
  *nowp = (double)(now.tv_nsec) / 1000000000.0 + (double)(now.tv_sec);
  *nowp = (*nowp / 86400.0 + 2440587.5 - 2451545.0) / 36525.0;
  return 0;
}


x86 assembly (clang, -O0):
<julian_centuries>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2ebd(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
call   1030 <clock_gettime@plt>
cmp    $0x0,%rax
je     114a <julian_centuries+0x3a>
movsd  0xee8(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b6 <julian_centuries+0xa6>
cvtsi2sdq -0x18(%rbp),%xmm0
movsd  0xec8(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsi2sdq -0x20(%rbp),%xmm1
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe9a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe86(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe72(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe5e(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<julian_centuries>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    0x2ec1(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1030 <clock_gettime@plt>
test   %rax,%rax
je     1138 <julian_centuries+0x28>
movsd  0xeca(%rip),%xmm0
jmp    1179 <julian_centuries+0x69>
cvtsi2sdq 0x8(%rsp),%xmm0
divsd  0xec1(%rip),%xmm0
cvtsi2sdq (%rsp),%xmm1
addsd  %xmm0,%xmm1
divsd  0xeb7(%rip),%xmm1
addsd  0xeb7(%rip),%xmm1
addsd  0xeb7(%rip),%xmm1
divsd  0xeb7(%rip),%xmm1
movsd  %xmm1,(%rbx)
xorpd  %xmm0,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i64 }
@CLOCK_REALTIME = global i32 0
define double @julian_centuries(double* %0) {
%2 = alloca double
%3 = alloca double*
%4 = alloca %struct.timespec
store double* %0, double** %3
%5 = load i32, i32* @CLOCK_REALTIME
%6 = call i64 @clock_gettime(i32 %5, %struct.timespec* %4)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store double -1.000000e+00, double* %2
br label %26
9: ; preds = %1
%10 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 1
%11 = load i64, i64* %10
%12 = sitofp i64 %11 to double
%13 = fdiv double %12, 1.000000e+09
%14 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
%15 = load i64, i64* %14
%16 = sitofp i64 %15 to double
%17 = fadd double %13, %16
%18 = load double*, double** %3
store double %17, double* %18
%19 = load double*, double** %3
%20 = load double, double* %19
%21 = fdiv double %20, 8.640000e+04
%22 = fadd double %21, 0x41429EC5C0000000
%23 = fsub double %22, 0x4142B42C80000000
%24 = fdiv double %23, 3.652500e+04
%25 = load double*, double** %3
store double %24, double* %25
store double 0.000000e+00, double* %2
br label %26
26: ; preds = %9, %8
%27 = load double, double* %2
ret double %27
}

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
@CLOCK_REALTIME = global i32 0
define double @julian_centuries(double* nocapture writeonly %0) {
%2 = alloca %struct.timespec
%3 = bitcast %struct.timespec* %2 to i8*
%4 = load i32, i32* @CLOCK_REALTIME
%5 = call i64 @clock_gettime(i32 %4, %struct.timespec* %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %20
7: ; preds = %1
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
%9 = load i64, i64* %8
%10 = sitofp i64 %9 to double
%11 = fdiv double %10, 1.000000e+09
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
%13 = load i64, i64* %12
%14 = sitofp i64 %13 to double
%15 = fadd double %11, %14
%16 = fdiv double %15, 8.640000e+04
%17 = fadd double %16, 0x41429EC5C0000000
%18 = fadd double %17, 0xC142B42C80000000
%19 = fdiv double %18, 3.652500e+04
store double %19, double* %0
br label %20
20: ; preds = %1, %7
%21 = phi double [ 0.000000e+00, %7 ], [ -1.000000e+00, %1 ]
ret double %21
}