#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 */
int atan(double);
double cos(double);
int fabs(double);
double sin(double);
double tan(double);
double SunPosition(double j) {
  double n, x, e, l, dl, v;
  int i;
  n = 360 / 365.2422 * j;
  i = (int)n / 360;
  n = n - i * 360.0;
  x = n - 3.762863;
  if (x < 0) {
    x = x + 360.0;
  }
  x = x * (3.1415926535897932384626433832795 / 180.0);
  e = x;
  do {
    dl = (double)(e - .016718 * sin(e) - x);
    e = (double)(e - dl / (1 - .016718 * cos(e)));
  } while (fabs(dl) >= (1e-12));
  v = 360 / 3.1415926535897932384626433832795 *
      atan(1.01686011182 * tan(e / 2));
  l = v + 282.596403;
  i = (int)(l / 360.0);
  l = l - i * 360;
  return l;
}


x86 assembly (clang, -O0):
<SunPosition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xeab(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
cvttsd2si -0x10(%rbp),%eax
mov    $0x168,%ecx
cltd
idiv   %ecx
mov    %eax,-0x3c(%rbp)
movsd  -0x10(%rbp),%xmm1
cvtsi2sdl -0x3c(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe60(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe3e(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11eb <SunPosition+0x9b>
movsd  0xe27(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe25(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <sin@plt>
movsd  -0x58(%rbp),%xmm1
movsd  0xdf8(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1070 <cos@plt>
movsd  -0x50(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
movsd  0xdb3(%rip),%xmm3
mulsd  %xmm3,%xmm2
movsd  0xdaf(%rip),%xmm3
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xd90(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    1207 <SunPosition+0xb7>
movsd  -0x20(%rbp),%xmm0
movsd  0xd99(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1060 <tan@plt>
movaps %xmm0,%xmm1
movsd  0xd7d(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1050 <atan@plt>
cvtsi2sd %eax,%xmm1
movsd  0xd60(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xd47(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xd00(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x3c(%rbp)
movsd  -0x28(%rbp),%xmm0
imul   $0x168,-0x3c(%rbp),%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SunPosition>:
sub    $0x28,%rsp
mulsd  0xea4(%rip),%xmm0
cvttsd2si %xmm0,%eax
cltq
imul   $0xffffffffb60b60b7,%rax,%rcx
shr    $0x20,%rcx
add    %ecx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x8,%eax
add    %ecx,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe83(%rip),%xmm2
mulsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
addsd  0xe7b(%rip),%xmm0
addsd  %xmm0,%xmm2
xorpd  %xmm1,%xmm1
movapd %xmm0,%xmm3
cmpltsd %xmm1,%xmm3
andpd  %xmm3,%xmm2
andnpd %xmm0,%xmm3
orpd   %xmm2,%xmm3
mulsd  0xe5e(%rip),%xmm3
movapd %xmm3,0x10(%rsp)
movsd  %xmm3,(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rsp),%xmm0
call   1040 <sin@plt>
movapd %xmm0,%xmm1
movsd  0xe3a(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
addsd  %xmm0,%xmm1
subsd  0x10(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
call   1070 <cos@plt>
mulsd  0xe14(%rip),%xmm0
addsd  0xe14(%rip),%xmm0
movsd  0x8(%rsp),%xmm2
movapd %xmm2,%xmm1
divsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
movapd %xmm2,%xmm0
call   1030 <fabs@plt>
test   %eax,%eax
jg     11d0 <SunPosition+0x80>
movsd  (%rsp),%xmm0
mulsd  0xde6(%rip),%xmm0
call   1060 <tan@plt>
mulsd  0xde1(%rip),%xmm0
call   1050 <atan@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xdd5(%rip),%xmm0
addsd  0xdd5(%rip),%xmm0
movapd %xmm0,%xmm1
divsd  0xd89(%rip),%xmm1
cvttsd2si %xmm1,%eax
imul   $0x168,%eax,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @SunPosition(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 i32
store double %0, double* %2
%10 = load double, double* %2
%11 = fmul double 0x3FEF8A6C46182ABA, %10
store double %11, double* %3
%12 = load double, double* %3
%13 = fptosi double %12 to i32
%14 = sdiv i32 %13, 360
store i32 %14, i32* %9
%15 = load double, double* %3
%16 = load i32, i32* %9
%17 = sitofp i32 %16 to double
%18 = fneg double %17
%19 = call double @llvm.fmuladd.f64(double %18, double 3.600000e+02, double %15)
store double %19, double* %3
%20 = load double, double* %3
%21 = fsub double %20, 0x400E1A57EAA2A0A9
store double %21, double* %4
%22 = load double, double* %4
%23 = fcmp olt double %22, 0.000000e+00
br i1 %23, label %24, label %27
24: ; preds = %1
%25 = load double, double* %4
%26 = fadd double %25, 3.600000e+02
store double %26, double* %4
br label %27
27: ; preds = %24, %1
%28 = load double, double* %4
%29 = fmul double %28, 0x3F91DF46A2529D39
store double %29, double* %4
%30 = load double, double* %4
store double %30, double* %5
br label %31
31: ; preds = %45, %27
%32 = load double, double* %5
%33 = load double, double* %5
%34 = call double @sin(double %33)
%35 = call double @llvm.fmuladd.f64(double -1.671800e-02, double %34, double %32)
%36 = load double, double* %4
%37 = fsub double %35, %36
store double %37, double* %7
%38 = load double, double* %5
%39 = load double, double* %7
%40 = load double, double* %5
%41 = call double @cos(double %40)
%42 = call double @llvm.fmuladd.f64(double -1.671800e-02, double %41, double 1.000000e+00)
%43 = fdiv double %39, %42
%44 = fsub double %38, %43
store double %44, double* %5
br label %45
45: ; preds = %31
%46 = load double, double* %7
%47 = call i32 @fabs(double %46)
%48 = sitofp i32 %47 to double
%49 = fcmp oge double %48, 0x3D719799812DEA11
br i1 %49, label %31, label %50
50: ; preds = %45
%51 = load double, double* %5
%52 = fdiv double %51, 2.000000e+00
%53 = call double @tan(double %52)
%54 = fmul double 0x3FF0450F1BCDFB19, %53
%55 = call i32 @atan(double %54)
%56 = sitofp i32 %55 to double
%57 = fmul double 0x405CA5DC1A63C1F8, %56
store double %57, double* %8
%58 = load double, double* %8
%59 = fadd double %58, 0x4071A98ADDDF43C8
store double %59, double* %6
%60 = load double, double* %6
%61 = fdiv double %60, 3.600000e+02
%62 = fptosi double %61 to i32
store i32 %62, i32* %9
%63 = load double, double* %6
%64 = load i32, i32* %9
%65 = mul nsw i32 %64, 360
%66 = sitofp i32 %65 to double
%67 = fsub double %63, %66
store double %67, double* %6
%68 = load double, double* %6
ret double %68
}

LLVM IR (-O2):
define double @SunPosition(double %0) {
%2 = fmul double %0, 0x3FEF8A6C46182ABA
%3 = fptosi double %2 to i32
%4 = sdiv i32 %3, 360
%5 = sitofp i32 %4 to double
%6 = fneg double %5
%7 = tail call double @llvm.fmuladd.f64(double %6, double 3.600000e+02, double %2)
%8 = fadd double %7, 0xC00E1A57EAA2A0A9
%9 = fcmp olt double %8, 0.000000e+00
%10 = fadd double %8, 3.600000e+02
%11 = select i1 %9, double %10, double %8
%12 = fmul double %11, 0x3F91DF46A2529D39
br label %13
13: ; preds = %13, %1
%14 = phi double [ %12, %1 ], [ %21, %13 ]
%15 = tail call double @sin(double %14)
%16 = tail call double @llvm.fmuladd.f64(double %15, double -1.671800e-02, double %14)
%17 = fsub double %16, %12
%18 = tail call double @cos(double %14)
%19 = tail call double @llvm.fmuladd.f64(double %18, double -1.671800e-02, double 1.000000e+00)
%20 = fdiv double %17, %19
%21 = fsub double %14, %20
%22 = tail call i32 @fabs(double %17)
%23 = icmp sgt i32 %22, 0
br i1 %23, label %13, label %24
24: ; preds = %13
%25 = fmul double %21, 5.000000e-01
%26 = tail call double @tan(double %25)
%27 = fmul double %26, 0x3FF0450F1BCDFB19
%28 = tail call i32 @atan(double %27)
%29 = sitofp i32 %28 to double
%30 = fmul double %29, 0x405CA5DC1A63C1F8
%31 = fadd double %30, 0x4071A98ADDDF43C8
%32 = fdiv double %31, 3.600000e+02
%33 = fptosi double %32 to i32
%34 = mul nsw i32 %33, 360
%35 = sitofp i32 %34 to double
%36 = fsub double %31, %35
ret double %36
}