#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 asin(double);
double sin(double);
double AstAlg_solar_declination(double jd) {
  static double last_jd, last_sdec;
  double sindec;
  if (jd == last_jd)
    return last_sdec;
  sindec = sin((M_PI / 180.0) * AstAlg_apparent_obliquity(jd)) *
           sin((M_PI / 180.0) * AstAlg_apparent_solar_longitude(jd));
  last_jd = jd;
  last_sdec = asin(sindec) / (M_PI / 180.0);
  return last_sdec;
}


x86 assembly (clang, -O0):
<AstAlg_solar_declination>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd 0x2eee(%rip),%xmm0
jne    1178 <AstAlg_solar_declination+0x38>
jp     1178 <AstAlg_solar_declination+0x38>
movsd  0x2ee2(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1243 <AstAlg_solar_declination+0x103>
mov    0x2e69(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe75(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <AstAlg_apparent_obliquity@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x20(%rbp)
mov    0x2e2d(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe39(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <AstAlg_apparent_solar_longitude@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,0x2e3f(%rip)
movsd  -0x18(%rbp),%xmm0
call   1060 <asin@plt>
mov    0x2dce(%rip),%rax
movsd  (%rax),%xmm1
movsd  0xdda(%rip),%xmm2
divsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x2e1a(%rip)
movsd  0x2e12(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AstAlg_solar_declination>:
push   %rbx
sub    $0x20,%rsp
movsd  0x2efb(%rip),%xmm1
ucomisd %xmm0,%xmm1
jne    1162 <AstAlg_solar_declination+0x22>
jp     1162 <AstAlg_solar_declination+0x22>
movsd  0x2ef3(%rip),%xmm0
jmp    11f0 <AstAlg_solar_declination+0xb0>
mov    0x2e7f(%rip),%rbx
movsd  (%rbx),%xmm1
divsd  0xe8b(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
call   1040 <AstAlg_apparent_obliquity@plt>
mulsd  0x8(%rsp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx),%xmm0
divsd  0xe5d(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <AstAlg_apparent_solar_longitude@plt>
mulsd  0x18(%rsp),%xmm0
call   1050 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  %xmm1,0x2e75(%rip)
call   1060 <asin@plt>
movsd  (%rbx),%xmm1
divsd  0xe1c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x2e60(%rip)
add    $0x20,%rsp
pop    %rbx
ret

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

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