#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 */

/* Variables and functions */
int floor(double);
double calcJD(int year, int month, int day) {
  double A;
  double B;
  double JD;
  if (month <= 2) {
    year -= 1;
    month += 12;
  }
  A = floor((double)year / 100);
  B = 2 - A + floor((double)A / 4);
  JD = floor(365.25 * (year + 4716)) + floor(30.6001 * (month + 1)) + day + B -
       1524.5;
  return JD;
}


x86 assembly (clang, -O0):
<calcJD>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x2,-0x8(%rbp)
jg     113d <calcJD+0x2d>
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x8(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xede(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <floor@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xebc(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe9d(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <floor@plt>
movsd  -0x38(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x4(%rbp),%eax
add    $0x126c,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe66(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <floor@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe40(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <floor@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
add    -0xc(%rbp),%eax
cvtsi2sd %eax,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xe14(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcJD>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r14d
mov    %edi,%ebp
lea    0xc(%rsi),%ebx
xor    %eax,%eax
cmp    $0x3,%esi
setl   %al
cmovge %esi,%ebx
sub    %eax,%ebp
cvtsi2sd %ebp,%xmm0
divsd  0xec7(%rip),%xmm0
call   1030 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xebb(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mulsd  0xeb1(%rip),%xmm0
call   1030 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
add    $0x126c,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0xe8c(%rip),%xmm0
call   1030 <floor@plt>
mov    %eax,%ebp
add    $0x1,%ebx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xe7b(%rip),%xmm0
call   1030 <floor@plt>
add    %r14d,%ebp
add    %eax,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
addsd  0x8(%rsp),%xmm0
addsd  0xe64(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @calcJD(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %5
%11 = icmp sle i32 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %3
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 1
store i32 %14, i32* %4
%15 = load i32, i32* %5
%16 = add nsw i32 %15, 12
store i32 %16, i32* %5
br label %17
17: ; preds = %12, %3
%18 = load i32, i32* %4
%19 = sitofp i32 %18 to double
%20 = fdiv double %19, 1.000000e+02
%21 = call i32 @floor(double %20)
%22 = sitofp i32 %21 to double
store double %22, double* %7
%23 = load double, double* %7
%24 = fsub double 2.000000e+00, %23
%25 = load double, double* %7
%26 = fdiv double %25, 4.000000e+00
%27 = call i32 @floor(double %26)
%28 = sitofp i32 %27 to double
%29 = fadd double %24, %28
store double %29, double* %8
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 4716
%32 = sitofp i32 %31 to double
%33 = fmul double 3.652500e+02, %32
%34 = call i32 @floor(double %33)
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
%37 = sitofp i32 %36 to double
%38 = fmul double 3.060010e+01, %37
%39 = call i32 @floor(double %38)
%40 = add nsw i32 %34, %39
%41 = load i32, i32* %6
%42 = add nsw i32 %40, %41
%43 = sitofp i32 %42 to double
%44 = load double, double* %8
%45 = fadd double %43, %44
%46 = fsub double %45, 1.524500e+03
store double %46, double* %9
%47 = load double, double* %9
ret double %47
}

LLVM IR (-O2):
define double @calcJD(i32 %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %1, 3
%5 = add nsw i32 %1, 12
%6 = select i1 %4, i32 %5, i32 %1
%7 = sext i1 %4 to i32
%8 = add nsw i32 %7, %0
%9 = sitofp i32 %8 to double
%10 = fdiv double %9, 1.000000e+02
%11 = tail call i32 @floor(double %10)
%12 = sitofp i32 %11 to double
%13 = fsub double 2.000000e+00, %12
%14 = fmul double %12, 2.500000e-01
%15 = tail call i32 @floor(double %14)
%16 = sitofp i32 %15 to double
%17 = fadd double %13, %16
%18 = add nsw i32 %8, 4716
%19 = sitofp i32 %18 to double
%20 = fmul double %19, 3.652500e+02
%21 = tail call i32 @floor(double %20)
%22 = add nsw i32 %6, 1
%23 = sitofp i32 %22 to double
%24 = fmul double %23, 3.060010e+01
%25 = tail call i32 @floor(double %24)
%26 = add i32 %21, %2
%27 = add i32 %26, %25
%28 = sitofp i32 %27 to double
%29 = fadd double %17, %28
%30 = fadd double %29, -1.524500e+03
ret double %30
}