#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 int /*<<< orphan*/ time_t;
struct tm {
  int tm_year;
  int tm_mon;
  int tm_mday;
  int tm_hour;
  int tm_min;
  int tm_sec;
};

/* Variables and functions */
double CalcJD(int, int, int, double);
struct tm *gmtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
double JDNow(void) {
  int year, month, day;
  int hours, minutes, seconds;
  double ut, jd;
  time_t observatory;
  struct tm *greenwich;
  time(&observatory);
  greenwich = gmtime(&observatory);
  year = greenwich->tm_year;
  year = year + 1900;
  month = greenwich->tm_mon;
  month = month + 1;
  day = greenwich->tm_mday;
  hours = greenwich->tm_hour;
  minutes = greenwich->tm_min;
  seconds = greenwich->tm_sec;
  ut = ((double)seconds) / 3600. + ((double)minutes) / 60. + ((double)hours);
  jd = CalcJD(year, month, day, ut);
  return (jd);
}


x86 assembly (clang, -O0):
<JDNow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    -0x2c(%rbp),%rdi
call   1040 <time@plt>
lea    -0x2c(%rbp),%rdi
call   1050 <gmtime@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x76c,%eax
mov    %eax,-0x4(%rbp)
mov    -0x38(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x38(%rbp),%rax
mov    0xc(%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x38(%rbp),%rax
mov    0x10(%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x38(%rbp),%rax
mov    0x14(%rax),%eax
mov    %eax,-0x18(%rbp)
cvtsi2sdl -0x18(%rbp),%xmm0
movsd  0xe5e(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xe45(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
movsd  -0x20(%rbp),%xmm0
call   1030 <CalcJD@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<JDNow>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <time@plt>
mov    %rbx,%rdi
call   1050 <gmtime@plt>
mov    $0x76c,%edi
add    (%rax),%edi
mov    0x4(%rax),%esi
mov    0x8(%rax),%edx
cvtdq2pd 0x10(%rax),%xmm0
add    $0x1,%esi
divpd  0xe99(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sdl 0xc(%rax),%xmm0
addsd  %xmm1,%xmm0
call   1030 <CalcJD@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
define double @JDNow() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca %struct.tm*
%11 = call i32 @time(i32* %9)
%12 = call %struct.tm* @gmtime(i32* %9)
store %struct.tm* %12, %struct.tm** %10
%13 = load %struct.tm*, %struct.tm** %10
%14 = getelementptr inbounds %struct.tm, %struct.tm* %13, i32 0, i32 0
%15 = load i32, i32* %14
store i32 %15, i32* %1
%16 = load i32, i32* %1
%17 = add nsw i32 %16, 1900
store i32 %17, i32* %1
%18 = load %struct.tm*, %struct.tm** %10
%19 = getelementptr inbounds %struct.tm, %struct.tm* %18, i32 0, i32 1
%20 = load i32, i32* %19
store i32 %20, i32* %2
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
%23 = load %struct.tm*, %struct.tm** %10
%24 = getelementptr inbounds %struct.tm, %struct.tm* %23, i32 0, i32 2
%25 = load i32, i32* %24
store i32 %25, i32* %3
%26 = load %struct.tm*, %struct.tm** %10
%27 = getelementptr inbounds %struct.tm, %struct.tm* %26, i32 0, i32 3
%28 = load i32, i32* %27
store i32 %28, i32* %4
%29 = load %struct.tm*, %struct.tm** %10
%30 = getelementptr inbounds %struct.tm, %struct.tm* %29, i32 0, i32 4
%31 = load i32, i32* %30
store i32 %31, i32* %5
%32 = load %struct.tm*, %struct.tm** %10
%33 = getelementptr inbounds %struct.tm, %struct.tm* %32, i32 0, i32 5
%34 = load i32, i32* %33
store i32 %34, i32* %6
%35 = load i32, i32* %6
%36 = sitofp i32 %35 to double
%37 = fdiv double %36, 3.600000e+03
%38 = load i32, i32* %5
%39 = sitofp i32 %38 to double
%40 = fdiv double %39, 6.000000e+01
%41 = fadd double %37, %40
%42 = load i32, i32* %4
%43 = sitofp i32 %42 to double
%44 = fadd double %41, %43
store double %44, double* %7
%45 = load i32, i32* %1
%46 = load i32, i32* %2
%47 = load i32, i32* %3
%48 = load double, double* %7
%49 = call double @CalcJD(i32 %45, i32 %46, i32 %47, double %48)
store double %49, double* %8
%50 = load double, double* %8
ret double %50
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
define double @JDNow() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @time(i32* %1)
%4 = call %struct.tm* @gmtime(i32* %1)
%5 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%6 = load i32, i32* %5
%7 = add nsw i32 %6, 1900
%8 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%9 = load i32, i32* %8
%10 = add nsw i32 %9, 1
%11 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 3
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 4
%16 = bitcast i32* %15 to <2 x i32>*
%17 = load <2 x i32>, <2 x i32>* %16
%18 = sitofp <2 x i32> %17 to <2 x double>
%19 = fdiv <2 x double> %18, <double 6.000000e+01, double 3.600000e+03>
%20 = shufflevector <2 x double> %19, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%21 = fadd <2 x double> %19, %20
%22 = extractelement <2 x double> %21, i64 0
%23 = sitofp i32 %14 to double
%24 = fadd double %22, %23
%25 = call double @CalcJD(i32 %7, i32 %10, i32 %12, double %24)
ret double %25
}