#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 /*<<< orphan*/ acos(double);
int calcEquationOfTime(double);
double calcSunDeclination(double);
double cos(int /*<<< orphan*/);
int /*<<< orphan*/ deg2rad(double);
double jd2jcent(scalar_t__);
scalar_t__ mdy2jd(int, int, int);
double rad2deg(int /*<<< orphan*/);
double sin(int /*<<< orphan*/);
double tan(int /*<<< orphan*/);
double calcSolarZenith(double latitude, double longitude, int year, int month,
                       int day, int timeUTC) {
  double T, trueSolarTime, hourAngle, solarDec, csz, zenith, exoatmElevation,
      te, refractionCorrection;
  T = jd2jcent(mdy2jd(year, month, day) + timeUTC / 1440.0);
  trueSolarTime = timeUTC + calcEquationOfTime(T) - 4.0 * longitude;
  hourAngle = trueSolarTime / 4.0 - 180.0;
  solarDec = calcSunDeclination(T);
  csz =
      sin(deg2rad(latitude)) * sin(deg2rad(solarDec)) +
      cos(deg2rad(latitude)) * cos(deg2rad(solarDec)) * cos(deg2rad(hourAngle));
  zenith = rad2deg(acos(csz));
  exoatmElevation = 90.0 - zenith;
  if (exoatmElevation > 85.0) {
    refractionCorrection = 0.0;
  } else {
    te = tan(deg2rad(exoatmElevation));
    if (exoatmElevation > 5.0) {
      refractionCorrection = 58.1 / te - 0.07 / (te * te * te) +
                             0.000086 / (te * te * te * te * te);
    } else if (exoatmElevation > -0.575) {
      refractionCorrection =
          1735.0 +
          exoatmElevation *
              (-518.2 + exoatmElevation *
                            (103.4 + exoatmElevation *
                                         (-12.79 + exoatmElevation * 0.711)));
    } else {
      refractionCorrection = -20.774 / te;
    }
    refractionCorrection = refractionCorrection / 3600.0;
  }
  return zenith - refractionCorrection;
}


x86 assembly (clang, -O0):
<calcSolarZenith>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    %esi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   10c0 <mdy2jd@plt>
cvtsi2sd %rax,%xmm0
cvtsi2sdl -0x20(%rbp),%xmm1
movsd  0xe47(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1030 <jd2jcent@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x8c(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <calcEquationOfTime@plt>
mov    %eax,%ecx
mov    -0x8c(%rbp),%eax
add    %ecx,%eax
cvtsi2sd %eax,%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  0xdfa(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xdd8(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xdc4(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1060 <calcSunDeclination@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1070 <deg2rad@plt>
mov    %eax,%edi
call   1080 <sin@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1070 <deg2rad@plt>
mov    %eax,%edi
call   1080 <sin@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1070 <deg2rad@plt>
mov    %eax,%edi
call   10b0 <cos@plt>
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
call   1070 <deg2rad@plt>
mov    %eax,%edi
call   10b0 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x88(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1070 <deg2rad@plt>
mov    %eax,%edi
call   10b0 <cos@plt>
movsd  -0x80(%rbp),%xmm1
movsd  -0x78(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1050 <acos@plt>
mov    %eax,%edi
call   1090 <rad2deg@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  0xce8(%rip),%xmm0
subsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  0xcc9(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    134e <calcSolarZenith+0x1ae>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    1484 <calcSolarZenith+0x2e4>
movsd  -0x58(%rbp),%xmm0
call   1070 <deg2rad@plt>
mov    %eax,%edi
call   10a0 <tan@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  0xcbf(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    13da <calcSolarZenith+0x23a>
movsd  0xcfd(%rip),%xmm0
divsd  -0x60(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm2
mulsd  -0x60(%rbp),%xmm2
mulsd  -0x60(%rbp),%xmm2
movsd  0xcd9(%rip),%xmm1
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  -0x60(%rbp),%xmm2
mulsd  -0x60(%rbp),%xmm2
mulsd  -0x60(%rbp),%xmm2
mulsd  -0x60(%rbp),%xmm2
mulsd  -0x60(%rbp),%xmm2
movsd  0xca8(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    146e <calcSolarZenith+0x2ce>
movsd  -0x58(%rbp),%xmm0
movsd  0xc51(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1457 <calcSolarZenith+0x2b7>
movsd  -0x58(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm3
movsd  0xc53(%rip),%xmm4
mulsd  %xmm4,%xmm3
movsd  0xc4f(%rip),%xmm4
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm2
movsd  0xc2f(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xc17(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xbff(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    1469 <calcSolarZenith+0x2c9>
movsd  0xbe1(%rip),%xmm0
divsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    146e <calcSolarZenith+0x2ce>
movsd  -0x68(%rbp),%xmm0
movsd  0xc0d(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x50(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcSolarZenith>:
push   %rbx
sub    $0x30,%rsp
mov    %ecx,%ebx
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
call   10c0 <mdy2jd@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
divsd  0xe31(%rip),%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
call   1030 <jd2jcent@plt>
movsd  %xmm0,0x18(%rsp)
call   1040 <calcEquationOfTime@plt>
add    %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  0xe09(%rip),%xmm1
addsd  %xmm0,%xmm1
mulsd  0xe05(%rip),%xmm1
addsd  0xe05(%rip),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
call   1060 <calcSunDeclination@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
call   1070 <deg2rad@plt>
mov    %eax,%edi
call   1080 <sin@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x18(%rsp),%xmm0
call   1070 <deg2rad@plt>
mov    %eax,%edi
call   1080 <sin@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1070 <deg2rad@plt>
mov    %eax,%edi
call   10b0 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1070 <deg2rad@plt>
mov    %eax,%edi
call   10b0 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1070 <deg2rad@plt>
mov    %eax,%edi
call   10b0 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
mulsd  0x28(%rsp),%xmm1
addsd  %xmm1,%xmm0
call   1050 <acos@plt>
mov    %eax,%edi
call   1090 <rad2deg@plt>
movsd  0xd54(%rip),%xmm2
subsd  %xmm0,%xmm2
xorpd  %xmm1,%xmm1
ucomisd 0xd4c(%rip),%xmm2
ja     13aa <calcSolarZenith+0x20a>
movsd  %xmm0,0x10(%rsp)
movapd %xmm2,%xmm0
movsd  %xmm2,0x8(%rsp)
call   1070 <deg2rad@plt>
mov    %eax,%edi
call   10a0 <tan@plt>
movsd  0x8(%rsp),%xmm2
ucomisd 0xd24(%rip),%xmm2
jbe    134c <calcSolarZenith+0x1ac>
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movsd  0xd4e(%rip),%xmm2
divsd  %xmm1,%xmm2
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
unpcklpd %xmm1,%xmm0
movapd 0xd46(%rip),%xmm1
divpd  %xmm0,%xmm1
addsd  %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
jmp    139c <calcSolarZenith+0x1fc>
ucomisd 0xce4(%rip),%xmm2
jbe    1390 <calcSolarZenith+0x1f0>
movsd  0xcea(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  0xce6(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  0xce2(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  0xcde(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  0xcda(%rip),%xmm1
jmp    139c <calcSolarZenith+0x1fc>
movsd  0xca8(%rip),%xmm1
divsd  %xmm0,%xmm1
divsd  0xcd4(%rip),%xmm1
movsd  0x10(%rsp),%xmm0
subsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @calcSolarZenith(double %0, double %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
store double %0, double* %7
store double %1, double* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%22 = load i32, i32* %9
%23 = load i32, i32* %10
%24 = load i32, i32* %11
%25 = call i64 @mdy2jd(i32 %22, i32 %23, i32 %24)
%26 = sitofp i64 %25 to double
%27 = load i32, i32* %12
%28 = sitofp i32 %27 to double
%29 = fdiv double %28, 1.440000e+03
%30 = fadd double %26, %29
%31 = fptosi double %30 to i64
%32 = call double @jd2jcent(i64 %31)
store double %32, double* %13
%33 = load i32, i32* %12
%34 = load double, double* %13
%35 = call i32 @calcEquationOfTime(double %34)
%36 = add nsw i32 %33, %35
%37 = sitofp i32 %36 to double
%38 = load double, double* %8
%39 = call double @llvm.fmuladd.f64(double -4.000000e+00, double %38, double %37)
store double %39, double* %14
%40 = load double, double* %14
%41 = fdiv double %40, 4.000000e+00
%42 = fsub double %41, 1.800000e+02
store double %42, double* %15
%43 = load double, double* %13
%44 = call double @calcSunDeclination(double %43)
store double %44, double* %16
%45 = load double, double* %7
%46 = call i32 @deg2rad(double %45)
%47 = call double @sin(i32 %46)
%48 = load double, double* %16
%49 = call i32 @deg2rad(double %48)
%50 = call double @sin(i32 %49)
%51 = load double, double* %7
%52 = call i32 @deg2rad(double %51)
%53 = call double @cos(i32 %52)
%54 = load double, double* %16
%55 = call i32 @deg2rad(double %54)
%56 = call double @cos(i32 %55)
%57 = fmul double %53, %56
%58 = load double, double* %15
%59 = call i32 @deg2rad(double %58)
%60 = call double @cos(i32 %59)
%61 = fmul double %57, %60
%62 = call double @llvm.fmuladd.f64(double %47, double %50, double %61)
store double %62, double* %17
%63 = load double, double* %17
%64 = call i32 @acos(double %63)
%65 = call double @rad2deg(i32 %64)
store double %65, double* %18
%66 = load double, double* %18
%67 = fsub double 9.000000e+01, %66
store double %67, double* %19
%68 = load double, double* %19
%69 = fcmp ogt double %68, 8.500000e+01
br i1 %69, label %70, label %71
70: ; preds = %6
store double 0.000000e+00, double* %21
br label %117
71: ; preds = %6
%72 = load double, double* %19
%73 = call i32 @deg2rad(double %72)
%74 = call double @tan(i32 %73)
store double %74, double* %20
%75 = load double, double* %19
%76 = fcmp ogt double %75, 5.000000e+00
br i1 %76, label %77, label %98
77: ; preds = %71
%78 = load double, double* %20
%79 = fdiv double 5.810000e+01, %78
%80 = load double, double* %20
%81 = load double, double* %20
%82 = fmul double %80, %81
%83 = load double, double* %20
%84 = fmul double %82, %83
%85 = fdiv double 7.000000e-02, %84
%86 = fsub double %79, %85
%87 = load double, double* %20
%88 = load double, double* %20
%89 = fmul double %87, %88
%90 = load double, double* %20
%91 = fmul double %89, %90
%92 = load double, double* %20
%93 = fmul double %91, %92
%94 = load double, double* %20
%95 = fmul double %93, %94
%96 = fdiv double 8.600000e-05, %95
%97 = fadd double %86, %96
store double %97, double* %21
br label %114
98: ; preds = %71
%99 = load double, double* %19
%100 = fcmp ogt double %99, -5.750000e-01
br i1 %100, label %101, label %110
101: ; preds = %98
%102 = load double, double* %19
%103 = load double, double* %19
%104 = load double, double* %19
%105 = load double, double* %19
%106 = call double @llvm.fmuladd.f64(double %105, double 7.110000e-01, double -1.279000e+01)
%107 = call double @llvm.fmuladd.f64(double %104, double %106, double 1.034000e+02)
%108 = call double @llvm.fmuladd.f64(double %103, double %107, double -5.182000e+02)
%109 = call double @llvm.fmuladd.f64(double %102, double %108, double 1.735000e+03)
store double %109, double* %21
br label %113
110: ; preds = %98
%111 = load double, double* %20
%112 = fdiv double -2.077400e+01, %111
store double %112, double* %21
br label %113
113: ; preds = %110, %101
br label %114
114: ; preds = %113, %77
%115 = load double, double* %21
%116 = fdiv double %115, 3.600000e+03
store double %116, double* %21
br label %117
117: ; preds = %114, %70
%118 = load double, double* %18
%119 = load double, double* %21
%120 = fsub double %118, %119
ret double %120
}

LLVM IR (-O2):
define double @calcSolarZenith(double %0, double %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = tail call i64 @mdy2jd(i32 %2, i32 %3, i32 %4)
%8 = sitofp i64 %7 to double
%9 = sitofp i32 %5 to double
%10 = fdiv double %9, 1.440000e+03
%11 = fadd double %10, %8
%12 = fptosi double %11 to i64
%13 = tail call double @jd2jcent(i64 %12)
%14 = tail call i32 @calcEquationOfTime(double %13)
%15 = add nsw i32 %14, %5
%16 = sitofp i32 %15 to double
%17 = tail call double @llvm.fmuladd.f64(double %1, double -4.000000e+00, double %16)
%18 = fmul double %17, 2.500000e-01
%19 = fadd double %18, -1.800000e+02
%20 = tail call double @calcSunDeclination(double %13)
%21 = tail call i32 @deg2rad(double %0)
%22 = tail call double @sin(i32 %21)
%23 = tail call i32 @deg2rad(double %20)
%24 = tail call double @sin(i32 %23)
%25 = tail call i32 @deg2rad(double %0)
%26 = tail call double @cos(i32 %25)
%27 = tail call i32 @deg2rad(double %20)
%28 = tail call double @cos(i32 %27)
%29 = fmul double %26, %28
%30 = tail call i32 @deg2rad(double %19)
%31 = tail call double @cos(i32 %30)
%32 = fmul double %29, %31
%33 = tail call double @llvm.fmuladd.f64(double %22, double %24, double %32)
%34 = tail call i32 @acos(double %33)
%35 = tail call double @rad2deg(i32 %34)
%36 = fsub double 9.000000e+01, %35
%37 = fcmp ogt double %36, 8.500000e+01
br i1 %37, label %67, label %38
38: ; preds = %6
%39 = tail call i32 @deg2rad(double %36)
%40 = tail call double @tan(i32 %39)
%41 = fcmp ogt double %36, 5.000000e+00
br i1 %41, label %42, label %55
42: ; preds = %38
%43 = fmul double %40, %40
%44 = fmul double %40, %43
%45 = fdiv double 7.000000e-02, %44
%46 = fmul double %40, %44
%47 = fmul double %40, %46
%48 = insertelement <2 x double> poison, double %40, i64 0
%49 = insertelement <2 x double> %48, double %47, i64 1
%50 = fdiv <2 x double> <double 5.810000e+01, double 8.600000e-05>, %49
%51 = extractelement <2 x double> %50, i64 0
%52 = fsub double %51, %45
%53 = extractelement <2 x double> %50, i64 1
%54 = fadd double %52, %53
br label %64
55: ; preds = %38
%56 = fcmp ogt double %36, -5.750000e-01
br i1 %56, label %57, label %62
57: ; preds = %55
%58 = tail call double @llvm.fmuladd.f64(double %36, double 7.110000e-01, double -1.279000e+01)
%59 = tail call double @llvm.fmuladd.f64(double %36, double %58, double 1.034000e+02)
%60 = tail call double @llvm.fmuladd.f64(double %36, double %59, double -5.182000e+02)
%61 = tail call double @llvm.fmuladd.f64(double %36, double %60, double 1.735000e+03)
br label %64
62: ; preds = %55
%63 = fdiv double -2.077400e+01, %40
br label %64
64: ; preds = %57, %62, %42
%65 = phi double [ %54, %42 ], [ %61, %57 ], [ %63, %62 ]
%66 = fdiv double %65, 3.600000e+03
br label %67
67: ; preds = %6, %64
%68 = phi double [ %66, %64 ], [ 0.000000e+00, %6 ]
%69 = fsub double %35, %68
ret double %69
}