#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 floor(double);
scalar_t__ sunmodel_is_leap_year(double);
double sunmodel_doy_from_jd(double jd) {
  double z, f, alpha;
  double a, b, c, d, e, k;
  double day, month, year;
  z = floor(jd + 0.5);
  f = (jd + 0.5) - z;
  if (z < 2299161.0) {
    a = z;
  } else {
    alpha = floor((z - 1867216.25) / 36524.25);
    a = z + 1.0 + alpha - floor(alpha * 0.25);
  }
  b = a + 1524.0;
  c = floor((b - 122.1) / 365.25);
  d = floor(365.25 * c);
  e = floor((b - d) / 30.6001);
  day = b - d - floor(30.6001 * e) + f;
  month = (e < 14.0) ? e - 1.0 : e - 13.0;
  year = (month > 2.0) ? c - 4716.0 : c - 4715.0;
  k = sunmodel_is_leap_year(year) ? 1.0 : 2.0;
  return floor((275.0 * month) / 9.0) - k * floor((month + 9.0) / 12.0) + day -
         30.0;
}


x86 assembly (clang, -O0):
<sunmodel_doy_from_jd>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xed0(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
call   1040 <floor@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  0xeb9(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe9a(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1180 <sunmodel_doy_from_jd+0x60>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11e1 <sunmodel_doy_from_jd+0xc1>
movsd  -0x10(%rbp),%xmm0
movsd  0xe9b(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe87(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xe69(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xe4a(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1040 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe67(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xe48(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe34(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xe1e(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
call   1040 <floor@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  0xdf5(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xdd0(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
call   1040 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
subsd  %xmm1,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xda0(%rip),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    12b6 <sunmodel_doy_from_jd+0x196>
movsd  -0x48(%rbp),%xmm0
movsd  0xd70(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
jmp    12cc <sunmodel_doy_from_jd+0x1ac>
movsd  -0x48(%rbp),%xmm0
movsd  0xd95(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  0xd7d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    130b <sunmodel_doy_from_jd+0x1eb>
movsd  -0x38(%rbp),%xmm0
movsd  0xd76(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
jmp    1324 <sunmodel_doy_from_jd+0x204>
movsd  -0x38(%rbp),%xmm0
movsd  0xd50(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
call   1030 <sunmodel_is_leap_year@plt>
movsd  0xcd5(%rip),%xmm0
movsd  0xd15(%rip),%xmm1
movsd  %xmm1,-0x98(%rbp)
ff
cmp    $0x0,%rax
movsd  %xmm0,-0x90(%rbp)
ff
jne    1375 <sunmodel_doy_from_jd+0x255>
movsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0x50(%rbp)
movsd  0xd06(%rip),%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  0xcf1(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  0xccb(%rip),%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  0xcb6(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
movsd  -0xa8(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0xa0(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  0xc66(%rip),%xmm1
subsd  %xmm1,%xmm0
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sunmodel_doy_from_jd>:
push   %rbx
sub    $0x20,%rsp
addsd  0xed3(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1040 <floor@plt>
movapd %xmm0,%xmm2
movsd  0xec4(%rip),%xmm0
ucomisd %xmm2,%xmm0
movapd %xmm2,%xmm0
ja     11a3 <sunmodel_doy_from_jd+0x83>
movsd  0xeba(%rip),%xmm0
addsd  %xmm2,%xmm0
divsd  0xeb6(%rip),%xmm0
movsd  %xmm2,(%rsp)
call   1040 <floor@plt>
movsd  0xeac(%rip),%xmm1
addsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mulsd  0xe9d(%rip),%xmm0
call   1040 <floor@plt>
movsd  (%rsp),%xmm2
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
movsd  0x10(%rsp),%xmm1
subsd  %xmm2,%xmm1
movsd  %xmm1,0x10(%rsp)
addsd  0xe75(%rip),%xmm0
movapd %xmm0,%xmm1
movsd  %xmm0,0x8(%rsp)
movsd  0xe6b(%rip),%xmm0
addsd  %xmm1,%xmm0
divsd  0xe67(%rip),%xmm0
call   1040 <floor@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0xe54(%rip),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1040 <floor@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
divsd  0xe33(%rip),%xmm0
call   1040 <floor@plt>
movsd  %xmm0,(%rsp)
movsd  0xe29(%rip),%xmm1
xor    %ebx,%ebx
ucomisd %xmm0,%xmm1
seta   %bl
movsd  0xe10(%rip),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1040 <floor@plt>
lea    0xe34(%rip),%rax
movsd  (%rsp),%xmm1
addsd  (%rax,%rbx,8),%xmm1
movsd  %xmm1,(%rsp)
xor    %eax,%eax
ucomisd 0xdf3(%rip),%xmm1
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
seta   %al
addsd  0x10(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
lea    0xe0b(%rip),%rcx
movsd  0x18(%rsp),%xmm0
addsd  (%rcx,%rax,8),%xmm0
call   1030 <sunmodel_is_leap_year@plt>
xor    %ebx,%ebx
test   %rax,%rax
sete   %bl
movsd  0xdbb(%rip),%xmm0
mulsd  (%rsp),%xmm0
divsd  0xdb6(%rip),%xmm0
call   1040 <floor@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
addsd  0xd9e(%rip),%xmm0
divsd  0xd9e(%rip),%xmm0
call   1040 <floor@plt>
lea    0xdc2(%rip),%rax
mulsd  (%rax,%rbx,8),%xmm0
movsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
addsd  0xd7d(%rip),%xmm1
movapd %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @sunmodel_doy_from_jd(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
store double %0, double* %2
%15 = load double, double* %2
%16 = fadd double %15, 5.000000e-01
%17 = call double @llvm.floor.f64(double %16)
store double %17, double* %3
%18 = load double, double* %2
%19 = fadd double %18, 5.000000e-01
%20 = load double, double* %3
%21 = fsub double %19, %20
store double %21, double* %4
%22 = load double, double* %3
%23 = fcmp olt double %22, 0x41418A8C80000000
br i1 %23, label %24, label %26
24: ; preds = %1
%25 = load double, double* %3
store double %25, double* %6
br label %39
26: ; preds = %1
%27 = load double, double* %3
%28 = fsub double %27, 0x413C7DD040000000
%29 = fdiv double %28, 0x40E1D58800000000
%30 = call double @llvm.floor.f64(double %29)
store double %30, double* %5
%31 = load double, double* %3
%32 = fadd double %31, 1.000000e+00
%33 = load double, double* %5
%34 = fadd double %32, %33
%35 = load double, double* %5
%36 = fmul double %35, 2.500000e-01
%37 = call double @llvm.floor.f64(double %36)
%38 = fsub double %34, %37
store double %38, double* %6
br label %39
39: ; preds = %26, %24
%40 = load double, double* %6
%41 = fadd double %40, 1.524000e+03
store double %41, double* %7
%42 = load double, double* %7
%43 = fsub double %42, 1.221000e+02
%44 = fdiv double %43, 3.652500e+02
%45 = call double @llvm.floor.f64(double %44)
store double %45, double* %8
%46 = load double, double* %8
%47 = fmul double 3.652500e+02, %46
%48 = call double @llvm.floor.f64(double %47)
store double %48, double* %9
%49 = load double, double* %7
%50 = load double, double* %9
%51 = fsub double %49, %50
%52 = fdiv double %51, 3.060010e+01
%53 = call double @llvm.floor.f64(double %52)
store double %53, double* %10
%54 = load double, double* %7
%55 = load double, double* %9
%56 = fsub double %54, %55
%57 = load double, double* %10
%58 = fmul double 3.060010e+01, %57
%59 = call double @llvm.floor.f64(double %58)
%60 = fsub double %56, %59
%61 = load double, double* %4
%62 = fadd double %60, %61
store double %62, double* %12
%63 = load double, double* %10
%64 = fcmp olt double %63, 1.400000e+01
br i1 %64, label %65, label %68
65: ; preds = %39
%66 = load double, double* %10
%67 = fsub double %66, 1.000000e+00
br label %71
68: ; preds = %39
%69 = load double, double* %10
%70 = fsub double %69, 1.300000e+01
br label %71
71: ; preds = %68, %65
%72 = phi double [ %67, %65 ], [ %70, %68 ]
store double %72, double* %13
%73 = load double, double* %13
%74 = fcmp ogt double %73, 2.000000e+00
br i1 %74, label %75, label %78
75: ; preds = %71
%76 = load double, double* %8
%77 = fsub double %76, 4.716000e+03
br label %81
78: ; preds = %71
%79 = load double, double* %8
%80 = fsub double %79, 4.715000e+03
br label %81
81: ; preds = %78, %75
%82 = phi double [ %77, %75 ], [ %80, %78 ]
store double %82, double* %14
%83 = load double, double* %14
%84 = call i64 @sunmodel_is_leap_year(double %83)
%85 = icmp ne i64 %84, 0
%86 = zext i1 %85 to i64
%87 = select i1 %85, double 1.000000e+00, double 2.000000e+00
store double %87, double* %11
%88 = load double, double* %13
%89 = fmul double 2.750000e+02, %88
%90 = fdiv double %89, 9.000000e+00
%91 = call double @llvm.floor.f64(double %90)
%92 = load double, double* %11
%93 = load double, double* %13
%94 = fadd double %93, 9.000000e+00
%95 = fdiv double %94, 1.200000e+01
%96 = call double @llvm.floor.f64(double %95)
%97 = fneg double %92
%98 = call double @llvm.fmuladd.f64(double %97, double %96, double %91)
%99 = load double, double* %12
%100 = fadd double %98, %99
%101 = fsub double %100, 3.000000e+01
ret double %101
}

LLVM IR (-O2):
define double @sunmodel_doy_from_jd(double %0) {
%2 = fadd double %0, 5.000000e-01
%3 = tail call double @llvm.floor.f64(double %2)
%4 = fcmp olt double %3, 0x41418A8C80000000
br i1 %4, label %14, label %5
5: ; preds = %1
%6 = fadd double %3, 0xC13C7DD040000000
%7 = fdiv double %6, 0x40E1D58800000000
%8 = tail call double @llvm.floor.f64(double %7)
%9 = fadd double %3, 1.000000e+00
%10 = fadd double %9, %8
%11 = fmul double %8, 2.500000e-01
%12 = tail call double @llvm.floor.f64(double %11)
%13 = fsub double %10, %12
br label %14
14: ; preds = %1, %5
%15 = phi double [ %13, %5 ], [ %3, %1 ]
%16 = fsub double %2, %3
%17 = fadd double %15, 1.524000e+03
%18 = fadd double %17, -1.221000e+02
%19 = fdiv double %18, 3.652500e+02
%20 = tail call double @llvm.floor.f64(double %19)
%21 = fmul double %20, 3.652500e+02
%22 = tail call double @llvm.floor.f64(double %21)
%23 = fsub double %17, %22
%24 = fdiv double %23, 3.060010e+01
%25 = tail call double @llvm.floor.f64(double %24)
%26 = fmul double %25, 3.060010e+01
%27 = tail call double @llvm.floor.f64(double %26)
%28 = fsub double %23, %27
%29 = fadd double %16, %28
%30 = fcmp olt double %25, 1.400000e+01
%31 = select i1 %30, double -1.000000e+00, double -1.300000e+01
%32 = fadd double %25, %31
%33 = fcmp ogt double %32, 2.000000e+00
%34 = select i1 %33, double -4.716000e+03, double -4.715000e+03
%35 = fadd double %20, %34
%36 = tail call i64 @sunmodel_is_leap_year(double %35)
%37 = icmp eq i64 %36, 0
%38 = select i1 %37, double 2.000000e+00, double 1.000000e+00
%39 = fmul double %32, 2.750000e+02
%40 = fdiv double %39, 9.000000e+00
%41 = tail call double @llvm.floor.f64(double %40)
%42 = fadd double %32, 9.000000e+00
%43 = fdiv double %42, 1.200000e+01
%44 = tail call double @llvm.floor.f64(double %43)
%45 = fneg double %38
%46 = tail call double @llvm.fmuladd.f64(double %45, double %44, double %41)
%47 = fadd double %29, %46
%48 = fadd double %47, -3.000000e+01
ret double %48
}