int sunshine_init(double lat, double dec, double xh[]) {
  double ad, nsa, dsa, arg;
  arg = tan((dec) * (3.14159265358979323846 / 180.0)) *
        tan((lat) * (3.14159265358979323846 / 180.0));
  if (arg >= 1) {
    ad = 90 - 1E-10;
  } else if (arg <= -1) {
    ad = -90 + 1E-10;
  } else {
    ad = (asin(arg) * (180.0 / 3.14159265358979323846));
  }
  nsa = 90 - ad;
  dsa = 90 + ad;
  xh[2] = -2 * nsa / 3;
  xh[3] = -1 * nsa / 3;
  xh[5] = 1 * nsa / 3;
  xh[6] = 2 * nsa / 3;
  xh[8] = -2 * dsa / 3;
  xh[9] = -1 * dsa / 3;
  xh[11] = 1 * dsa / 3;
  xh[12] = 2 * dsa / 3;
  if (fabs(arg) >= 1)
    return (-1);
  return (0);
}


x86 assembly (clang, -O0):
<sunshine_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
movsd  0xeca(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1040 <tan@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  0xeb3(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1040 <tan@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xe83(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1199 <sunshine_init+0x79>
movsd  0xe99(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11de <sunshine_init+0xbe>
movsd  0xe6f(%rip),%xmm0
ucomisd -0x40(%rbp),%xmm0
jb     11be <sunshine_init+0x9e>
movsd  0xe6c(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11d9 <sunshine_init+0xb9>
movsd  -0x40(%rbp),%xmm0
call   1030 <asin@plt>
movsd  0xe48(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11de <sunshine_init+0xbe>
movsd  0xe62(%rip),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe50(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe36(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  0xe19(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  0xde4(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  0xdf7(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x18(%rax)
movsd  0xdb2(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  0xdd5(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x28(%rax)
movsd  0xdc8(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  0xdb3(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x30(%rax)
movsd  0xdae(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  0xd91(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x40(%rax)
movsd  0xd5c(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  0xd6f(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x48(%rax)
movsd  0xd2a(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  0xd4d(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x58(%rax)
movsd  0xd40(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  0xd2b(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x60(%rax)
movsd  -0x40(%rbp),%xmm0
movaps 0xd32(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xcd6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1340 <sunshine_init+0x220>
movl   $0xffffffff,-0x4(%rbp)
jmp    1347 <sunshine_init+0x227>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sunshine_init>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
movsd  %xmm0,(%rsp)
mulsd  0xecb(%rip),%xmm1
movapd %xmm1,%xmm0
call   1040 <tan@plt>
movsd  %xmm0,0x18(%rsp)
movsd  (%rsp),%xmm0
mulsd  0xeaf(%rip),%xmm0
call   1040 <tan@plt>
movapd %xmm0,%xmm5
mulsd  0x18(%rsp),%xmm5
ucomisd 0xea8(%rip),%xmm5
jae    1195 <sunshine_init+0x75>
movsd  0xeae(%rip),%xmm0
ucomisd %xmm5,%xmm0
jae    119f <sunshine_init+0x7f>
movapd %xmm5,%xmm0
movapd %xmm5,(%rsp)
call   1030 <asin@plt>
movapd (%rsp),%xmm5
mulsd  0xe95(%rip),%xmm0
jmp    11a7 <sunshine_init+0x87>
movsd  0xe6b(%rip),%xmm0
jmp    11a7 <sunshine_init+0x87>
movsd  0xe71(%rip),%xmm0
movsd  0xe81(%rip),%xmm1
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
addsd  %xmm1,%xmm0
movsd  0xe75(%rip),%xmm1
movapd %xmm2,%xmm3
mulsd  %xmm1,%xmm3
unpcklpd %xmm2,%xmm3
movapd 0xe69(%rip),%xmm4
divpd  %xmm4,%xmm3
movupd %xmm3,0x10(%rbx)
movapd %xmm2,%xmm3
addsd  %xmm2,%xmm3
unpcklpd %xmm3,%xmm2
movapd 0xe5c(%rip),%xmm3
divpd  %xmm3,%xmm2
movupd %xmm2,0x28(%rbx)
mulsd  %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
divpd  %xmm4,%xmm1
movupd %xmm1,0x40(%rbx)
movapd %xmm0,%xmm1
addsd  %xmm0,%xmm1
unpcklpd %xmm1,%xmm0
andpd  0xe3e(%rip),%xmm5
xor    %eax,%eax
ucomisd 0xde4(%rip),%xmm5
divpd  %xmm3,%xmm0
movupd %xmm0,0x58(%rbx)
adc    $0xffffffff,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @sunshine_init(double %0, double %1, double* %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double*
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double %0, double* %5
store double %1, double* %6
store double* %2, double** %7
%12 = load double, double* %6
%13 = fmul double %12, 0x3F91DF46A2529D39
%14 = call double @tan(double %13)
%15 = load double, double* %5
%16 = fmul double %15, 0x3F91DF46A2529D39
%17 = call double @tan(double %16)
%18 = fmul double %14, %17
store double %18, double* %11
%19 = load double, double* %11
%20 = fcmp oge double %19, 1.000000e+00
br i1 %20, label %21, label %22
21: ; preds = %3
store double 0x40567FFFFFFFE483, double* %8
br label %31
22: ; preds = %3
%23 = load double, double* %11
%24 = fcmp ole double %23, -1.000000e+00
br i1 %24, label %25, label %26
25: ; preds = %22
store double 0xC0567FFFFFFFE483, double* %8
br label %30
26: ; preds = %22
%27 = load double, double* %11
%28 = call double @asin(double %27)
%29 = fmul double %28, 0x404CA5DC1A63C1F8
store double %29, double* %8
br label %30
30: ; preds = %26, %25
br label %31
31: ; preds = %30, %21
%32 = load double, double* %8
%33 = fsub double 9.000000e+01, %32
store double %33, double* %9
%34 = load double, double* %8
%35 = fadd double 9.000000e+01, %34
store double %35, double* %10
%36 = load double, double* %9
%37 = fmul double -2.000000e+00, %36
%38 = fdiv double %37, 3.000000e+00
%39 = load double*, double** %7
%40 = getelementptr inbounds double, double* %39, i64 2
store double %38, double* %40
%41 = load double, double* %9
%42 = fmul double -1.000000e+00, %41
%43 = fdiv double %42, 3.000000e+00
%44 = load double*, double** %7
%45 = getelementptr inbounds double, double* %44, i64 3
store double %43, double* %45
%46 = load double, double* %9
%47 = fmul double 1.000000e+00, %46
%48 = fdiv double %47, 3.000000e+00
%49 = load double*, double** %7
%50 = getelementptr inbounds double, double* %49, i64 5
store double %48, double* %50
%51 = load double, double* %9
%52 = fmul double 2.000000e+00, %51
%53 = fdiv double %52, 3.000000e+00
%54 = load double*, double** %7
%55 = getelementptr inbounds double, double* %54, i64 6
store double %53, double* %55
%56 = load double, double* %10
%57 = fmul double -2.000000e+00, %56
%58 = fdiv double %57, 3.000000e+00
%59 = load double*, double** %7
%60 = getelementptr inbounds double, double* %59, i64 8
store double %58, double* %60
%61 = load double, double* %10
%62 = fmul double -1.000000e+00, %61
%63 = fdiv double %62, 3.000000e+00
%64 = load double*, double** %7
%65 = getelementptr inbounds double, double* %64, i64 9
store double %63, double* %65
%66 = load double, double* %10
%67 = fmul double 1.000000e+00, %66
%68 = fdiv double %67, 3.000000e+00
%69 = load double*, double** %7
%70 = getelementptr inbounds double, double* %69, i64 11
store double %68, double* %70
%71 = load double, double* %10
%72 = fmul double 2.000000e+00, %71
%73 = fdiv double %72, 3.000000e+00
%74 = load double*, double** %7
%75 = getelementptr inbounds double, double* %74, i64 12
store double %73, double* %75
%76 = load double, double* %11
%77 = call double @llvm.fabs.f64(double %76)
%78 = fcmp oge double %77, 1.000000e+00
br i1 %78, label %79, label %80
79: ; preds = %31
store i32 -1, i32* %4
br label %81
80: ; preds = %31
store i32 0, i32* %4
br label %81
81: ; preds = %80, %79
%82 = load i32, i32* %4
ret i32 %82
}

LLVM IR (-O2):
define i32 @sunshine_init(double %0, double %1, double* nocapture writeonly %2) {
%4 = fmul double %1, 0x3F91DF46A2529D39
%5 = tail call double @tan(double %4)
%6 = fmul double %0, 0x3F91DF46A2529D39
%7 = tail call double @tan(double %6)
%8 = fmul double %5, %7
%9 = fcmp ult double %8, 1.000000e+00
br i1 %9, label %10, label %15
10: ; preds = %3
%11 = fcmp ugt double %8, -1.000000e+00
br i1 %11, label %12, label %15
12: ; preds = %10
%13 = tail call double @asin(double %8)
%14 = fmul double %13, 0x404CA5DC1A63C1F8
br label %15
15: ; preds = %10, %3, %12
%16 = phi double [ %14, %12 ], [ 0x40567FFFFFFFE483, %3 ], [ 0xC0567FFFFFFFE483, %10 ]
%17 = fsub double 9.000000e+01, %16
%18 = fadd double %16, 9.000000e+01
%19 = fmul double %17, -2.000000e+00
%20 = getelementptr inbounds double, double* %2, i64 2
%21 = insertelement <2 x double> poison, double %19, i64 0
%22 = insertelement <2 x double> %21, double %17, i64 1
%23 = fdiv <2 x double> %22, <double 3.000000e+00, double -3.000000e+00>
%24 = bitcast double* %20 to <2 x double>*
store <2 x double> %23, <2 x double>* %24
%25 = getelementptr inbounds double, double* %2, i64 5
%26 = fmul double %17, 2.000000e+00
%27 = insertelement <2 x double> poison, double %17, i64 0
%28 = insertelement <2 x double> %27, double %26, i64 1
%29 = fdiv <2 x double> %28, <double 3.000000e+00, double 3.000000e+00>
%30 = bitcast double* %25 to <2 x double>*
store <2 x double> %29, <2 x double>* %30
%31 = fmul double %18, -2.000000e+00
%32 = getelementptr inbounds double, double* %2, i64 8
%33 = insertelement <2 x double> poison, double %31, i64 0
%34 = insertelement <2 x double> %33, double %18, i64 1
%35 = fdiv <2 x double> %34, <double 3.000000e+00, double -3.000000e+00>
%36 = bitcast double* %32 to <2 x double>*
store <2 x double> %35, <2 x double>* %36
%37 = getelementptr inbounds double, double* %2, i64 11
%38 = fmul double %18, 2.000000e+00
%39 = insertelement <2 x double> poison, double %18, i64 0
%40 = insertelement <2 x double> %39, double %38, i64 1
%41 = fdiv <2 x double> %40, <double 3.000000e+00, double 3.000000e+00>
%42 = bitcast double* %37 to <2 x double>*
store <2 x double> %41, <2 x double>* %42
%43 = tail call double @llvm.fabs.f64(double %8)
%44 = fcmp oge double %43, 1.000000e+00
%45 = sext i1 %44 to i32
ret i32 %45
}