#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 */
double trunc(double);
double astro_julday_d(int year, int month, double day) {
  double A, B;
  double Y = (double)year;
  double M = (double)month;
  if (month <= 2) {
    Y -= 1.0;
    M += 12.0;
  }
  if (year > 1582 ||
      (year == 1582 && (month > 10 || (month == 10 && day > 5.0)))) {
    A = trunc(Y / 100.0);
    B = 2.0 - A + trunc(A / 4.0);
  } else {
    B = 0;
  }
  return trunc(365.25 * (Y + 4716.0)) + trunc(30.6001 * (M + 1)) + day + B -
         1524.5;
}


x86 assembly (clang, -O0):
<astro_julday_d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
cmpl   $0x2,-0x8(%rbp)
jg     1169 <astro_julday_d+0x59>
movsd  -0x28(%rbp),%xmm0
movsd  0xeba(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xea1(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
cmpl   $0x62e,-0x4(%rbp)
jg     11ae <astro_julday_d+0x9e>
cmpl   $0x62e,-0x4(%rbp)
jne    1207 <astro_julday_d+0xf7>
cmpl   $0xa,-0x8(%rbp)
jg     11ae <astro_julday_d+0x9e>
cmpl   $0xa,-0x8(%rbp)
jne    1207 <astro_julday_d+0xf7>
movsd  -0x10(%rbp),%xmm0
movsd  0xe6c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1207 <astro_julday_d+0xf7>
movsd  -0x28(%rbp),%xmm0
movsd  0xe6d(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <trunc@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  0xe4f(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe30(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <trunc@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    120f <astro_julday_d+0xff>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe31(%rip),%xmm1
addsd  -0x28(%rbp),%xmm1
movsd  0xe1c(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <trunc@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  0xdce(%rip),%xmm1
addsd  -0x30(%rbp),%xmm1
movsd  0xdf1(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <trunc@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
addsd  %xmm1,%xmm0
addsd  -0x10(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xdc2(%rip),%xmm1
subsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<astro_julday_d>:
push   %rbx
sub    $0x20,%rsp
movsd  %xmm0,0x18(%rsp)
mov    %esi,%ebx
cvtsi2sd %edi,%xmm1
cmp    $0x3,%esi
jge    112e <astro_julday_d+0x1e>
addsd  0xed2(%rip),%xmm1
cmp    $0x62e,%edi
jle    117c <astro_julday_d+0x6c>
movapd %xmm1,%xmm0
divsd  0xece(%rip),%xmm0
movsd  %xmm1,0x8(%rsp)
call   1030 <trunc@plt>
movsd  0xec3(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
mulsd  0xeba(%rip),%xmm0
call   1030 <trunc@plt>
movsd  0x8(%rsp),%xmm1
movapd %xmm0,%xmm2
addsd  (%rsp),%xmm2
jmp    1199 <astro_julday_d+0x89>
xorpd  %xmm2,%xmm2
jne    1199 <astro_julday_d+0x89>
cmp    $0xa,%ebx
jg     1136 <astro_julday_d+0x26>
jne    1199 <astro_julday_d+0x89>
movsd  0x18(%rsp),%xmm0
ucomisd 0xe71(%rip),%xmm0
ja     1136 <astro_julday_d+0x26>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
cmp    $0x3,%ebx
movsd  %xmm2,0x8(%rsp)
jge    11b3 <astro_julday_d+0xa3>
addsd  0xe75(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
addsd  0xe6f(%rip),%xmm1
mulsd  0xe6f(%rip),%xmm1
movapd %xmm1,%xmm0
call   1030 <trunc@plt>
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
addsd  0xe5b(%rip),%xmm0
mulsd  0xe5b(%rip),%xmm0
call   1030 <trunc@plt>
addsd  (%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
addsd  0xe45(%rip),%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @astro_julday_d(i32 %0, i32 %1, double %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store i32 %0, i32* %4
store i32 %1, i32* %5
store double %2, double* %6
%11 = load i32, i32* %4
%12 = sitofp i32 %11 to double
store double %12, double* %9
%13 = load i32, i32* %5
%14 = sitofp i32 %13 to double
store double %14, double* %10
%15 = load i32, i32* %5
%16 = icmp sle i32 %15, 2
br i1 %16, label %17, label %22
17: ; preds = %3
%18 = load double, double* %9
%19 = fsub double %18, 1.000000e+00
store double %19, double* %9
%20 = load double, double* %10
%21 = fadd double %20, 1.200000e+01
store double %21, double* %10
br label %22
22: ; preds = %17, %3
%23 = load i32, i32* %4
%24 = icmp sgt i32 %23, 1582
br i1 %24, label %37, label %25
25: ; preds = %22
%26 = load i32, i32* %4
%27 = icmp eq i32 %26, 1582
br i1 %27, label %28, label %47
28: ; preds = %25
%29 = load i32, i32* %5
%30 = icmp sgt i32 %29, 10
br i1 %30, label %37, label %31
31: ; preds = %28
%32 = load i32, i32* %5
%33 = icmp eq i32 %32, 10
br i1 %33, label %34, label %47
34: ; preds = %31
%35 = load double, double* %6
%36 = fcmp ogt double %35, 5.000000e+00
br i1 %36, label %37, label %47
37: ; preds = %34, %28, %22
%38 = load double, double* %9
%39 = fdiv double %38, 1.000000e+02
%40 = call double @llvm.trunc.f64(double %39)
store double %40, double* %7
%41 = load double, double* %7
%42 = fsub double 2.000000e+00, %41
%43 = load double, double* %7
%44 = fdiv double %43, 4.000000e+00
%45 = call double @llvm.trunc.f64(double %44)
%46 = fadd double %42, %45
store double %46, double* %8
br label %48
47: ; preds = %34, %31, %25
store double 0.000000e+00, double* %8
br label %48
48: ; preds = %47, %37
%49 = load double, double* %9
%50 = fadd double %49, 4.716000e+03
%51 = fmul double 3.652500e+02, %50
%52 = call double @llvm.trunc.f64(double %51)
%53 = load double, double* %10
%54 = fadd double %53, 1.000000e+00
%55 = fmul double 3.060010e+01, %54
%56 = call double @llvm.trunc.f64(double %55)
%57 = fadd double %52, %56
%58 = load double, double* %6
%59 = fadd double %57, %58
%60 = load double, double* %8
%61 = fadd double %59, %60
%62 = fsub double %61, 1.524500e+03
ret double %62
}

LLVM IR (-O2):
define double @astro_julday_d(i32 %0, i32 %1, double %2) {
%4 = sitofp i32 %0 to double
%5 = sitofp i32 %1 to double
%6 = icmp slt i32 %1, 3
%7 = fadd double %4, -1.000000e+00
%8 = select i1 %6, double %7, double %4
%9 = icmp sgt i32 %0, 1582
br i1 %9, label %18, label %10
10: ; preds = %3
%11 = icmp eq i32 %0, 1582
br i1 %11, label %12, label %25
12: ; preds = %10
%13 = icmp sgt i32 %1, 10
br i1 %13, label %18, label %14
14: ; preds = %12
%15 = icmp eq i32 %1, 10
%16 = fcmp ogt double %2, 5.000000e+00
%17 = and i1 %15, %16
br i1 %17, label %18, label %25
18: ; preds = %14, %12, %3
%19 = fdiv double %8, 1.000000e+02
%20 = tail call double @llvm.trunc.f64(double %19)
%21 = fsub double 2.000000e+00, %20
%22 = fmul double %20, 2.500000e-01
%23 = tail call double @llvm.trunc.f64(double %22)
%24 = fadd double %21, %23
br label %25
25: ; preds = %10, %14, %18
%26 = phi double [ %24, %18 ], [ 0.000000e+00, %14 ], [ 0.000000e+00, %10 ]
%27 = fadd double %5, 1.200000e+01
%28 = select i1 %6, double %27, double %5
%29 = fadd double %8, 4.716000e+03
%30 = fmul double %29, 3.652500e+02
%31 = tail call double @llvm.trunc.f64(double %30)
%32 = fadd double %28, 1.000000e+00
%33 = fmul double %32, 3.060010e+01
%34 = tail call double @llvm.trunc.f64(double %33)
%35 = fadd double %31, %34
%36 = fadd double %35, %2
%37 = fadd double %36, %26
%38 = fadd double %37, -1.524500e+03
ret double %38
}