#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);
double getYearFromJulian(double jd) {
  double tempJD;
  double F, Z, A, B, a, D, E;
  int C, month, year;
  tempJD = jd + 0.5;
  if ((jd - floor(jd)) > 0) {
    tempJD -= (jd - floor(jd));
    tempJD += 0.5;
  }
  Z = (int)tempJD;
  F = tempJD - floor(tempJD);
  if (Z < 2299161)
    A = Z;
  else {
    a = (int)((Z - 1867216.25) / 36524.25);
    A = Z + 1 + a - (int)(a / 4.0);
  }
  B = A + 1524;
  C = (int)((B - 122.1) / 365.25);
  D = (int)(365.25 * C);
  E = (int)((B - D) / 30.6001);
  if (E < 14)
    month = E - 1;
  else if (E == 14 || E == 15)
    month = E - 13;
  else
    month = 0;
  if (month > 2)
    return C - 4716;
  else
    return C - 4715;
}


x86 assembly (clang, -O0):
<getYearFromJulian>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xed8(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
subsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    119c <getYearFromJulian+0x8c>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <floor@plt>
movsd  -0x70(%rbp),%xmm1
subsd  %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe6e(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
cvttsd2si -0x18(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe31(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11f1 <getYearFromJulian+0xe1>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    124f <getYearFromJulian+0x13f>
movsd  -0x28(%rbp),%xmm0
movsd  0xe2a(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe16(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xdf5(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
movsd  0xdd6(%rip),%xmm2
divsd  %xmm2,%xmm1
cvttsd2si %xmm1,%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xdf9(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xdda(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xdc6(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x54(%rbp)
cvtsi2sdl -0x54(%rbp),%xmm1
movsd  0xdae(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  0xd83(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xd62(%rip),%xmm0
ucomisd -0x50(%rbp),%xmm0
jbe    12f6 <getYearFromJulian+0x1e6>
movsd  -0x50(%rbp),%xmm0
movsd  0xd32(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x58(%rbp)
jmp    135e <getYearFromJulian+0x24e>
movsd  -0x50(%rbp),%xmm0
movsd  0xd2d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1318 <getYearFromJulian+0x208>
jp     1318 <getYearFromJulian+0x208>
jmp    1335 <getYearFromJulian+0x225>
movsd  -0x50(%rbp),%xmm0
movsd  0xd33(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1352 <getYearFromJulian+0x242>
jp     1352 <getYearFromJulian+0x242>
movsd  -0x50(%rbp),%xmm0
movsd  0xd1e(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x58(%rbp)
jmp    1359 <getYearFromJulian+0x249>
movl   $0x0,-0x58(%rbp)
jmp    135e <getYearFromJulian+0x24e>
cmpl   $0x2,-0x58(%rbp)
jle    137e <getYearFromJulian+0x26e>
mov    -0x54(%rbp),%eax
sub    $0x126c,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    138f <getYearFromJulian+0x27f>
mov    -0x54(%rbp),%eax
sub    $0x126b,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getYearFromJulian>:
sub    $0x28,%rsp
movsd  %xmm0,0x8(%rsp)
movapd %xmm0,%xmm1
addsd  0xeda(%rip),%xmm1
movapd %xmm1,0x10(%rsp)
call   1030 <floor@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd 0x10(%rsp),%xmm3
movapd %xmm3,%xmm0
subsd  %xmm1,%xmm0
movapd %xmm1,%xmm2
addsd  0xeab(%rip),%xmm0
xorpd  %xmm1,%xmm1
cmpltsd %xmm2,%xmm1
movapd %xmm1,%xmm2
andnpd %xmm3,%xmm2
andpd  %xmm0,%xmm1
orpd   %xmm2,%xmm1
cvttsd2si %xmm1,%eax
cvttpd2dq %xmm1,%xmm0
cvtdq2pd %xmm0,%xmm0
cmp    $0x231519,%eax
jl     11bd <getYearFromJulian+0xad>
movsd  0xe7f(%rip),%xmm1
addsd  %xmm0,%xmm1
divsd  0xe7b(%rip),%xmm1
cvttpd2dq %xmm1,%xmm1
cvtdq2pd %xmm1,%xmm1
addsd  0xe73(%rip),%xmm0
addsd  %xmm1,%xmm0
mulsd  0xe6f(%rip),%xmm1
cvttpd2dq %xmm1,%xmm1
cvtdq2pd %xmm1,%xmm1
subsd  %xmm1,%xmm0
addsd  0xe63(%rip),%xmm0
movsd  0xe63(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0xe5f(%rip),%xmm2
divsd  %xmm2,%xmm1
cvttsd2si %xmm1,%eax
cvttpd2dq %xmm1,%xmm1
cvtdq2pd %xmm1,%xmm1
mulsd  %xmm2,%xmm1
cvttpd2dq %xmm1,%xmm1
cvtdq2pd %xmm1,%xmm1
subsd  %xmm1,%xmm0
divsd  0xe3f(%rip),%xmm0
cvttsd2si %xmm0,%ecx
cmp    $0xe,%ecx
jge    1214 <getYearFromJulian+0x104>
movsd  0xe36(%rip),%xmm1
jmp    1224 <getYearFromJulian+0x114>
and    $0xfffffffe,%ecx
cmp    $0xe,%ecx
jne    123e <getYearFromJulian+0x12e>
movsd  0xe2c(%rip),%xmm1
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
xor    %edx,%edx
cmp    $0x3,%ecx
setge  %dl
sub    %edx,%eax
add    $0xffffed95,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @getYearFromJulian(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 i32
%13 = alloca i32
%14 = alloca i32
store double %0, double* %3
%15 = load double, double* %3
%16 = fadd double %15, 5.000000e-01
store double %16, double* %4
%17 = load double, double* %3
%18 = load double, double* %3
%19 = call double @llvm.floor.f64(double %18)
%20 = fsub double %17, %19
%21 = fcmp ogt double %20, 0.000000e+00
br i1 %21, label %22, label %31
22: ; preds = %1
%23 = load double, double* %3
%24 = load double, double* %3
%25 = call double @llvm.floor.f64(double %24)
%26 = fsub double %23, %25
%27 = load double, double* %4
%28 = fsub double %27, %26
store double %28, double* %4
%29 = load double, double* %4
%30 = fadd double %29, 5.000000e-01
store double %30, double* %4
br label %31
31: ; preds = %22, %1
%32 = load double, double* %4
%33 = fptosi double %32 to i32
%34 = sitofp i32 %33 to double
store double %34, double* %6
%35 = load double, double* %4
%36 = load double, double* %4
%37 = call double @llvm.floor.f64(double %36)
%38 = fsub double %35, %37
store double %38, double* %5
%39 = load double, double* %6
%40 = fcmp olt double %39, 0x41418A8C80000000
br i1 %40, label %41, label %43
41: ; preds = %31
%42 = load double, double* %6
store double %42, double* %7
br label %58
43: ; preds = %31
%44 = load double, double* %6
%45 = fsub double %44, 0x413C7DD040000000
%46 = fdiv double %45, 0x40E1D58800000000
%47 = fptosi double %46 to i32
%48 = sitofp i32 %47 to double
store double %48, double* %9
%49 = load double, double* %6
%50 = fadd double %49, 1.000000e+00
%51 = load double, double* %9
%52 = fadd double %50, %51
%53 = load double, double* %9
%54 = fdiv double %53, 4.000000e+00
%55 = fptosi double %54 to i32
%56 = sitofp i32 %55 to double
%57 = fsub double %52, %56
store double %57, double* %7
br label %58
58: ; preds = %43, %41
%59 = load double, double* %7
%60 = fadd double %59, 1.524000e+03
store double %60, double* %8
%61 = load double, double* %8
%62 = fsub double %61, 1.221000e+02
%63 = fdiv double %62, 3.652500e+02
%64 = fptosi double %63 to i32
store i32 %64, i32* %12
%65 = load i32, i32* %12
%66 = sitofp i32 %65 to double
%67 = fmul double 3.652500e+02, %66
%68 = fptosi double %67 to i32
%69 = sitofp i32 %68 to double
store double %69, double* %10
%70 = load double, double* %8
%71 = load double, double* %10
%72 = fsub double %70, %71
%73 = fdiv double %72, 3.060010e+01
%74 = fptosi double %73 to i32
%75 = sitofp i32 %74 to double
store double %75, double* %11
%76 = load double, double* %11
%77 = fcmp olt double %76, 1.400000e+01
br i1 %77, label %78, label %82
78: ; preds = %58
%79 = load double, double* %11
%80 = fsub double %79, 1.000000e+00
%81 = fptosi double %80 to i32
store i32 %81, i32* %13
br label %94
82: ; preds = %58
%83 = load double, double* %11
%84 = fcmp oeq double %83, 1.400000e+01
br i1 %84, label %88, label %85
85: ; preds = %82
%86 = load double, double* %11
%87 = fcmp oeq double %86, 1.500000e+01
br i1 %87, label %88, label %92
88: ; preds = %85, %82
%89 = load double, double* %11
%90 = fsub double %89, 1.300000e+01
%91 = fptosi double %90 to i32
store i32 %91, i32* %13
br label %93
92: ; preds = %85
store i32 0, i32* %13
br label %93
93: ; preds = %92, %88
br label %94
94: ; preds = %93, %78
%95 = load i32, i32* %13
%96 = icmp sgt i32 %95, 2
br i1 %96, label %97, label %101
97: ; preds = %94
%98 = load i32, i32* %12
%99 = sub nsw i32 %98, 4716
%100 = sitofp i32 %99 to double
store double %100, double* %2
br label %105
101: ; preds = %94
%102 = load i32, i32* %12
%103 = sub nsw i32 %102, 4715
%104 = sitofp i32 %103 to double
store double %104, double* %2
br label %105
105: ; preds = %101, %97
%106 = load double, double* %2
ret double %106
}

LLVM IR (-O2):
define double @getYearFromJulian(double %0) {
%2 = fadd double %0, 5.000000e-01
%3 = tail call double @llvm.floor.f64(double %0)
%4 = fsub double %0, %3
%5 = fcmp ogt double %4, 0.000000e+00
%6 = fsub double %2, %4
%7 = fadd double %6, 5.000000e-01
%8 = select i1 %5, double %7, double %2
%9 = fptosi double %8 to i32
%10 = sitofp i32 %9 to double
%11 = icmp slt i32 %9, 2299161
br i1 %11, label %23, label %12
12: ; preds = %1
%13 = fadd double %10, 0xC13C7DD040000000
%14 = fdiv double %13, 0x40E1D58800000000
%15 = fptosi double %14 to i32
%16 = sitofp i32 %15 to double
%17 = fadd double %10, 1.000000e+00
%18 = fadd double %17, %16
%19 = fmul double %16, 2.500000e-01
%20 = fptosi double %19 to i32
%21 = sitofp i32 %20 to double
%22 = fsub double %18, %21
br label %23
23: ; preds = %1, %12
%24 = phi double [ %22, %12 ], [ %10, %1 ]
%25 = fadd double %24, 1.524000e+03
%26 = fadd double %25, -1.221000e+02
%27 = fdiv double %26, 3.652500e+02
%28 = fptosi double %27 to i32
%29 = sitofp i32 %28 to double
%30 = fmul double %29, 3.652500e+02
%31 = fptosi double %30 to i32
%32 = sitofp i32 %31 to double
%33 = fsub double %25, %32
%34 = fdiv double %33, 3.060010e+01
%35 = fptosi double %34 to i32
%36 = sitofp i32 %35 to double
%37 = icmp slt i32 %35, 14
br i1 %37, label %43, label %38
38: ; preds = %23
%39 = and i32 %35, -2
%40 = icmp eq i32 %39, 14
br i1 %40, label %43, label %41
41: ; preds = %38
%42 = add nsw i32 %28, -4715
br label %50
43: ; preds = %38, %23
%44 = phi double [ -1.000000e+00, %23 ], [ -1.300000e+01, %38 ]
%45 = fadd double %44, %36
%46 = fptosi double %45 to i32
%47 = icmp sgt i32 %46, 2
%48 = select i1 %47, i32 -4716, i32 -4715
%49 = add nsw i32 %48, %28
br label %50
50: ; preds = %43, %41
%51 = phi i32 [ %42, %41 ], [ %49, %43 ]
%52 = sitofp i32 %51 to double
ret double %52
}