#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 GetMoonEclipticLongitudeEC(double);
double GetSunEclipticLongitudeEC(double);
double fabs(double);
double CalculateMoonShuoJD(double tdJD) {
  double JD0, JD1, stDegree, stDegreep;
  JD1 = tdJD;
  do {
    JD0 = JD1;
    double moonLongitude = GetMoonEclipticLongitudeEC(JD0);
    double sunLongitude = GetSunEclipticLongitudeEC(JD0);
    if ((moonLongitude > 330.0) && (sunLongitude < 30.0)) {
      sunLongitude = 360.0 + sunLongitude;
    }
    if ((sunLongitude > 330.0) && (moonLongitude < 30.0)) {
      moonLongitude = 60.0 + moonLongitude;
    }
    stDegree = moonLongitude - sunLongitude;
    if (stDegree >= 360.0)
      stDegree -= 360.0;
    if (stDegree < -360.0)
      stDegree += 360.0;
    stDegreep = (GetMoonEclipticLongitudeEC(JD0 + 0.000005) -
                 GetSunEclipticLongitudeEC(JD0 + 0.000005) -
                 GetMoonEclipticLongitudeEC(JD0 - 0.000005) +
                 GetSunEclipticLongitudeEC(JD0 - 0.000005)) /
                0.00001;
    JD1 = JD0 - stDegree / stDegreep;
  } while ((fabs(JD1 - JD0) > 0.00000001));
  return JD1;
}


x86 assembly (clang, -O0):
<CalculateMoonShuoJD>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <GetMoonEclipticLongitudeEC@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <GetSunEclipticLongitudeEC@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xe94(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    119b <CalculateMoonShuoJD+0x7b>
movsd  0xe8a(%rip),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    119b <CalculateMoonShuoJD+0x7b>
movsd  0xe7f(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xe58(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11d7 <CalculateMoonShuoJD+0xb7>
movsd  0xe4e(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    11d7 <CalculateMoonShuoJD+0xb7>
movsd  0xe4b(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe1d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1213 <CalculateMoonShuoJD+0xf3>
movsd  -0x20(%rbp),%xmm0
movsd  0xe06(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe05(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1238 <CalculateMoonShuoJD+0x118>
movsd  0xde2(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xdf0(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
call   1030 <GetMoonEclipticLongitudeEC@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  0xdd9(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
call   1040 <GetSunEclipticLongitudeEC@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xdb1(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <GetMoonEclipticLongitudeEC@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xd8a(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1040 <GetSunEclipticLongitudeEC@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  0xd65(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
divsd  -0x28(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movaps 0xd4b(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xd37(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1137 <CalculateMoonShuoJD+0x17>
movsd  -0x18(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalculateMoonShuoJD>:
sub    $0x48,%rsp
movapd %xmm0,%xmm2
nopl   0x0(%rax,%rax,1)
movsd  %xmm2,0x8(%rsp)
movapd %xmm2,%xmm0
call   1030 <GetMoonEclipticLongitudeEC@plt>
movapd %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <GetSunEclipticLongitudeEC@plt>
movapd %xmm0,%xmm1
movsd  0xea4(%rip),%xmm3
addsd  %xmm3,%xmm1
movapd %xmm0,%xmm2
movsd  0xe9c(%rip),%xmm4
cmpltsd %xmm4,%xmm2
andpd  %xmm2,%xmm1
andnpd %xmm0,%xmm2
orpd   %xmm1,%xmm2
movsd  0xe8b(%rip),%xmm5
movapd %xmm5,%xmm1
movapd 0x10(%rsp),%xmm6
cmpltsd %xmm6,%xmm1
andpd  %xmm1,%xmm2
andnpd %xmm0,%xmm1
orpd   %xmm2,%xmm1
movapd %xmm6,%xmm0
addsd  0xe6c(%rip),%xmm0
movapd %xmm6,%xmm2
cmpltsd %xmm4,%xmm2
andpd  %xmm2,%xmm0
andnpd %xmm6,%xmm2
orpd   %xmm0,%xmm2
movapd %xmm5,%xmm0
cmpltsd %xmm1,%xmm0
andpd  %xmm0,%xmm2
andnpd %xmm6,%xmm0
orpd   %xmm2,%xmm0
subsd  %xmm1,%xmm0
movapd %xmm0,%xmm1
movsd  0xe3a(%rip),%xmm4
addsd  %xmm4,%xmm1
movapd %xmm3,%xmm2
cmpnlesd %xmm0,%xmm2
andpd  %xmm2,%xmm0
andnpd %xmm1,%xmm2
orpd   %xmm0,%xmm2
movapd %xmm2,%xmm0
addsd  %xmm3,%xmm0
movapd %xmm2,%xmm1
cmpltsd %xmm4,%xmm1
andpd  %xmm1,%xmm0
andnpd %xmm2,%xmm1
orpd   %xmm0,%xmm1
movapd %xmm1,0x30(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  0xdf8(%rip),%xmm0
movsd  %xmm0,0x28(%rsp)
call   1030 <GetMoonEclipticLongitudeEC@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x28(%rsp),%xmm0
call   1040 <GetSunEclipticLongitudeEC@plt>
movsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  0xdc6(%rip),%xmm0
movsd  %xmm0,0x28(%rsp)
call   1030 <GetMoonEclipticLongitudeEC@plt>
movsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x28(%rsp),%xmm0
call   1040 <GetSunEclipticLongitudeEC@plt>
movapd 0x30(%rsp),%xmm2
addsd  0x10(%rsp),%xmm0
divsd  0xd94(%rip),%xmm0
divsd  %xmm0,%xmm2
movsd  0x8(%rsp),%xmm1
addsd  %xmm1,%xmm2
movapd %xmm2,%xmm0
subsd  %xmm1,%xmm0
andpd  0xd8e(%rip),%xmm0
ucomisd 0xd76(%rip),%xmm0
ja     1130 <CalculateMoonShuoJD+0x10>
movapd %xmm2,%xmm0
add    $0x48,%rsp
ret

LLVM IR (-O0):
define double @CalculateMoonShuoJD(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %2
%9 = load double, double* %2
store double %9, double* %4
br label %10
10: ; preds = %70, %1
%11 = load double, double* %4
store double %11, double* %3
%12 = load double, double* %3
%13 = call double @GetMoonEclipticLongitudeEC(double %12)
store double %13, double* %7
%14 = load double, double* %3
%15 = call double @GetSunEclipticLongitudeEC(double %14)
store double %15, double* %8
%16 = load double, double* %7
%17 = fcmp ogt double %16, 3.300000e+02
br i1 %17, label %18, label %24
18: ; preds = %10
%19 = load double, double* %8
%20 = fcmp olt double %19, 3.000000e+01
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load double, double* %8
%23 = fadd double 3.600000e+02, %22
store double %23, double* %8
br label %24
24: ; preds = %21, %18, %10
%25 = load double, double* %8
%26 = fcmp ogt double %25, 3.300000e+02
br i1 %26, label %27, label %33
27: ; preds = %24
%28 = load double, double* %7
%29 = fcmp olt double %28, 3.000000e+01
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load double, double* %7
%32 = fadd double 6.000000e+01, %31
store double %32, double* %7
br label %33
33: ; preds = %30, %27, %24
%34 = load double, double* %7
%35 = load double, double* %8
%36 = fsub double %34, %35
store double %36, double* %5
%37 = load double, double* %5
%38 = fcmp oge double %37, 3.600000e+02
br i1 %38, label %39, label %42
39: ; preds = %33
%40 = load double, double* %5
%41 = fsub double %40, 3.600000e+02
store double %41, double* %5
br label %42
42: ; preds = %39, %33
%43 = load double, double* %5
%44 = fcmp olt double %43, -3.600000e+02
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load double, double* %5
%47 = fadd double %46, 3.600000e+02
store double %47, double* %5
br label %48
48: ; preds = %45, %42
%49 = load double, double* %3
%50 = fadd double %49, 5.000000e-06
%51 = call double @GetMoonEclipticLongitudeEC(double %50)
%52 = load double, double* %3
%53 = fadd double %52, 5.000000e-06
%54 = call double @GetSunEclipticLongitudeEC(double %53)
%55 = fsub double %51, %54
%56 = load double, double* %3
%57 = fsub double %56, 5.000000e-06
%58 = call double @GetMoonEclipticLongitudeEC(double %57)
%59 = fsub double %55, %58
%60 = load double, double* %3
%61 = fsub double %60, 5.000000e-06
%62 = call double @GetSunEclipticLongitudeEC(double %61)
%63 = fadd double %59, %62
%64 = fdiv double %63, 1.000000e-05
store double %64, double* %6
%65 = load double, double* %3
%66 = load double, double* %5
%67 = load double, double* %6
%68 = fdiv double %66, %67
%69 = fsub double %65, %68
store double %69, double* %4
br label %70
70: ; preds = %48
%71 = load double, double* %4
%72 = load double, double* %3
%73 = fsub double %71, %72
%74 = call double @llvm.fabs.f64(double %73)
%75 = fcmp ogt double %74, 1.000000e-08
br i1 %75, label %10, label %76
76: ; preds = %70
%77 = load double, double* %4
ret double %77
}

LLVM IR (-O2):
define double @CalculateMoonShuoJD(double %0) {
br label %2
2: ; preds = %2, %1
%3 = phi double [ %0, %1 ], [ %34, %2 ]
%4 = tail call double @GetMoonEclipticLongitudeEC(double %3)
%5 = tail call double @GetSunEclipticLongitudeEC(double %3)
%6 = fcmp ogt double %4, 3.300000e+02
%7 = fcmp olt double %5, 3.000000e+01
%8 = select i1 %6, i1 %7, i1 false
%9 = fadd double %5, 3.600000e+02
%10 = select i1 %8, double %9, double %5
%11 = fcmp ogt double %10, 3.300000e+02
%12 = fcmp olt double %4, 3.000000e+01
%13 = select i1 %11, i1 %12, i1 false
%14 = fadd double %4, 6.000000e+01
%15 = select i1 %13, double %14, double %4
%16 = fsub double %15, %10
%17 = fcmp ult double %16, 3.600000e+02
%18 = fadd double %16, -3.600000e+02
%19 = select i1 %17, double %16, double %18
%20 = fcmp olt double %19, -3.600000e+02
%21 = fadd double %19, 3.600000e+02
%22 = select i1 %20, double %21, double %19
%23 = fadd double %3, 5.000000e-06
%24 = tail call double @GetMoonEclipticLongitudeEC(double %23)
%25 = tail call double @GetSunEclipticLongitudeEC(double %23)
%26 = fsub double %24, %25
%27 = fadd double %3, -5.000000e-06
%28 = tail call double @GetMoonEclipticLongitudeEC(double %27)
%29 = fsub double %26, %28
%30 = tail call double @GetSunEclipticLongitudeEC(double %27)
%31 = fadd double %29, %30
%32 = fdiv double %31, 1.000000e-05
%33 = fdiv double %22, %32
%34 = fsub double %3, %33
%35 = fsub double %34, %3
%36 = tail call double @llvm.fabs.f64(double %35)
%37 = fcmp ogt double %36, 1.000000e-08
br i1 %37, label %2, label %38
38: ; preds = %2
ret double %34
}