#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 AstAlg_apparent_obliquity(double);
double AstAlg_apparent_solar_longitude(double);
double M_PI;
double atan2(int, int);
int cos(double);
int sin(double);
double AstAlg_solar_right_ascension(double jd) {
  static double last_jd, last_ra;
  double eps, slong, alpha;
  if (jd == last_jd)
    return last_ra;
  slong = (M_PI / 180.0) * AstAlg_apparent_solar_longitude(jd);
  eps = (M_PI / 180.0) * AstAlg_apparent_obliquity(jd);
  alpha = atan2(cos(eps) * sin(slong), cos(slong));
  last_ra = alpha / (M_PI / 180.0);
  last_jd = jd;
  return last_ra;
}


x86 assembly (clang, -O0):
<AstAlg_solar_right_ascension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd 0x2ee6(%rip),%xmm0
jne    1188 <AstAlg_solar_right_ascension+0x38>
jp     1188 <AstAlg_solar_right_ascension+0x38>
movsd  0x2eda(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1273 <AstAlg_solar_right_ascension+0x123>
mov    0x2e59(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe65(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <AstAlg_apparent_solar_longitude@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    0x2e22(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe2e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <AstAlg_apparent_obliquity@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1070 <cos@plt>
mov    %eax,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1060 <sin@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1070 <cos@plt>
mov    -0x2c(%rbp),%edi
mov    %eax,%esi
call   1040 <atan2@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    0x2dab(%rip),%rax
movsd  (%rax),%xmm1
movsd  0xdb7(%rip),%xmm2
divsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x2dff(%rip)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,0x2dea(%rip)
movsd  0x2dea(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AstAlg_solar_right_ascension>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movsd  0x2ef1(%rip),%xmm1
ucomisd %xmm0,%xmm1
jne    1174 <AstAlg_solar_right_ascension+0x24>
jp     1174 <AstAlg_solar_right_ascension+0x24>
movsd  0x2ee9(%rip),%xmm0
jmp    1214 <AstAlg_solar_right_ascension+0xc4>
mov    0x2e6d(%rip),%r14
movsd  (%r14),%xmm1
divsd  0xe78(%rip),%xmm1
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x8(%rsp)
call   1030 <AstAlg_apparent_solar_longitude@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  (%r14),%xmm0
divsd  0xe51(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <AstAlg_apparent_obliquity@plt>
mulsd  0x10(%rsp),%xmm0
call   1070 <cos@plt>
mov    %eax,%ebx
movsd  (%rsp),%xmm0
call   1060 <sin@plt>
imul   %eax,%ebx
movsd  (%rsp),%xmm0
call   1070 <cos@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1040 <atan2@plt>
movsd  (%r14),%xmm1
divsd  0xe06(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x2e52(%rip)
movsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x2e3c(%rip)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@AstAlg_solar_right_ascension.last_jd = internal global double 0.000000e+00
@AstAlg_solar_right_ascension.last_ra = internal global double 0.000000e+00
@M_PI = global double 0.000000e+00
define double @AstAlg_solar_right_ascension(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %3
%7 = load double, double* %3
%8 = load double, double* @AstAlg_solar_right_ascension.last_jd
%9 = fcmp oeq double %7, %8
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = load double, double* @AstAlg_solar_right_ascension.last_ra
store double %11, double* %2
br label %37
12: ; preds = %1
%13 = load double, double* @M_PI
%14 = fdiv double %13, 1.800000e+02
%15 = load double, double* %3
%16 = call double @AstAlg_apparent_solar_longitude(double %15)
%17 = fmul double %14, %16
store double %17, double* %5
%18 = load double, double* @M_PI
%19 = fdiv double %18, 1.800000e+02
%20 = load double, double* %3
%21 = call double @AstAlg_apparent_obliquity(double %20)
%22 = fmul double %19, %21
store double %22, double* %4
%23 = load double, double* %4
%24 = call i32 @cos(double %23)
%25 = load double, double* %5
%26 = call i32 @sin(double %25)
%27 = mul nsw i32 %24, %26
%28 = load double, double* %5
%29 = call i32 @cos(double %28)
%30 = call double @atan2(i32 %27, i32 %29)
store double %30, double* %6
%31 = load double, double* %6
%32 = load double, double* @M_PI
%33 = fdiv double %32, 1.800000e+02
%34 = fdiv double %31, %33
store double %34, double* @AstAlg_solar_right_ascension.last_ra
%35 = load double, double* %3
store double %35, double* @AstAlg_solar_right_ascension.last_jd
%36 = load double, double* @AstAlg_solar_right_ascension.last_ra
store double %36, double* %2
br label %37
37: ; preds = %12, %10
%38 = load double, double* %2
ret double %38
}

LLVM IR (-O2):
@AstAlg_solar_right_ascension.last_jd = internal unnamed_addr global double 0.000000e+00
@AstAlg_solar_right_ascension.last_ra = internal unnamed_addr global double 0.000000e+00
@M_PI = global double 0.000000e+00
define double @AstAlg_solar_right_ascension(double %0) {
%2 = load double, double* @AstAlg_solar_right_ascension.last_jd
%3 = fcmp oeq double %2, %0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = load double, double* @AstAlg_solar_right_ascension.last_ra
br label %23
6: ; preds = %1
%7 = load double, double* @M_PI
%8 = fdiv double %7, 1.800000e+02
%9 = tail call double @AstAlg_apparent_solar_longitude(double %0)
%10 = fmul double %8, %9
%11 = load double, double* @M_PI
%12 = fdiv double %11, 1.800000e+02
%13 = tail call double @AstAlg_apparent_obliquity(double %0)
%14 = fmul double %12, %13
%15 = tail call i32 @cos(double %14)
%16 = tail call i32 @sin(double %10)
%17 = mul nsw i32 %16, %15
%18 = tail call i32 @cos(double %10)
%19 = tail call double @atan2(i32 %17, i32 %18)
%20 = load double, double* @M_PI
%21 = fdiv double %20, 1.800000e+02
%22 = fdiv double %19, %21
store double %22, double* @AstAlg_solar_right_ascension.last_ra
store double %0, double* @AstAlg_solar_right_ascension.last_jd
br label %23
23: ; preds = %6, %4
%24 = phi double [ %5, %4 ], [ %22, %6 ]
ret double %24
}