#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) {
  if (month <= 2) {
    year -= 1;
    month += 12;
  }
  int A = floor(year / 100);
  int B = 2 - A + floor(A / 4);
  double 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    $0x30,%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)
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
call   1030 <floor@plt>
mov    %eax,-0x10(%rbp)
mov    $0x2,%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
call   1030 <floor@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
add    $0x126c,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe7f(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <floor@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe59(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <floor@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
add    -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe2f(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcJD>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebx
lea    0xc(%rsi),%r13d
xor    %eax,%eax
cmp    $0x3,%esi
setl   %al
cmovge %esi,%r13d
sub    %eax,%edi
movslq %edi,%rbp
imul   $0x51eb851f,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
call   1030 <floor@plt>
mov    %eax,%r14d
lea    0x3(%r14),%eax
test   %r14d,%r14d
cmovns %r14d,%eax
sar    $0x2,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
call   1030 <floor@plt>
mov    %eax,%r15d
add    $0x126c,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0xe7c(%rip),%xmm0
call   1030 <floor@plt>
mov    %eax,%r12d
add    $0x1,%r13d
xorps  %xmm0,%xmm0
cvtsi2sd %r13d,%xmm0
mulsd  0xe68(%rip),%xmm0
call   1030 <floor@plt>
sub    %r14d,%ebx
add    %r15d,%ebx
add    %r12d,%ebx
add    %ebx,%eax
add    $0x2,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0xe4e(%rip),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
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 i32
%8 = alloca i32
%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 = sdiv i32 %18, 100
%20 = sitofp i32 %19 to double
%21 = call i32 @floor(double %20)
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = sub nsw i32 2, %22
%24 = load i32, i32* %7
%25 = sdiv i32 %24, 4
%26 = sitofp i32 %25 to double
%27 = call i32 @floor(double %26)
%28 = add nsw i32 %23, %27
store i32 %28, i32* %8
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 4716
%31 = sitofp i32 %30 to double
%32 = fmul double 3.652500e+02, %31
%33 = call i32 @floor(double %32)
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
%36 = sitofp i32 %35 to double
%37 = fmul double 3.060010e+01, %36
%38 = call i32 @floor(double %37)
%39 = add nsw i32 %33, %38
%40 = load i32, i32* %6
%41 = add nsw i32 %39, %40
%42 = load i32, i32* %8
%43 = add nsw i32 %41, %42
%44 = sitofp i32 %43 to double
%45 = fsub double %44, 1.524500e+03
store double %45, double* %9
%46 = load double, double* %9
ret double %46
}

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 = sdiv i32 %8, 100
%10 = sitofp i32 %9 to double
%11 = tail call i32 @floor(double %10)
%12 = sdiv i32 %11, 4
%13 = sitofp i32 %12 to double
%14 = tail call i32 @floor(double %13)
%15 = add nsw i32 %8, 4716
%16 = sitofp i32 %15 to double
%17 = fmul double %16, 3.652500e+02
%18 = tail call i32 @floor(double %17)
%19 = add nsw i32 %6, 1
%20 = sitofp i32 %19 to double
%21 = fmul double %20, 3.060010e+01
%22 = tail call i32 @floor(double %21)
%23 = add i32 %2, 2
%24 = sub i32 %23, %11
%25 = add i32 %24, %14
%26 = add i32 %25, %18
%27 = add i32 %26, %22
%28 = sitofp i32 %27 to double
%29 = fadd double %28, -1.524500e+03
ret double %29
}