#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 M_PI;
double tan(double);
double sunmodel_atmo_refraction_correction(double elevation) {
  double value, te;
  if (elevation > (M_PI * (85.0) / 180.0)) {
    value = 0.0;
  } else {
    te = tan(elevation);
    if (elevation > (M_PI * (5.0) / 180.0)) {
      value = 58.1 / te - 0.07 / (te * te * te) +
              0.000086 / (te * te * te * te * te);
    } else {
      if (elevation > (M_PI * (-0.575) / 180.0)) {
        value = 1735.0 +
                elevation *
                    (-518.2 +
                     elevation *
                         (103.4 + elevation * (-12.79 + elevation * 0.711)));
      } else {
        value = -20.774 / te;
      }
    }
    value = (M_PI * (value / 3600.0) / 180.0);
  }
  return value;
}


x86 assembly (clang, -O0):
<sunmodel_atmo_refraction_correction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xede(%rip),%xmm1
mov    0x2eb7(%rip),%rax
mulsd  (%rax),%xmm1
movsd  0xec3(%rip),%xmm2
divsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    1158 <sunmodel_atmo_refraction_correction+0x48>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    12d0 <sunmodel_atmo_refraction_correction+0x1c0>
movsd  -0x8(%rbp),%xmm0
call   1030 <tan@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe9c(%rip),%xmm1
mov    0x2e6d(%rip),%rax
mulsd  (%rax),%xmm1
movsd  0xe79(%rip),%xmm2
divsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    11f4 <sunmodel_atmo_refraction_correction+0xe4>
movsd  0xec3(%rip),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
mulsd  -0x18(%rbp),%xmm2
mulsd  -0x18(%rbp),%xmm2
movsd  0xe9f(%rip),%xmm1
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm2
mulsd  -0x18(%rbp),%xmm2
mulsd  -0x18(%rbp),%xmm2
mulsd  -0x18(%rbp),%xmm2
mulsd  -0x18(%rbp),%xmm2
movsd  0xe6e(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    129f <sunmodel_atmo_refraction_correction+0x18f>
movsd  -0x8(%rbp),%xmm0
movsd  0xe17(%rip),%xmm1
mov    0x2de0(%rip),%rax
mulsd  (%rax),%xmm1
movsd  0xdec(%rip),%xmm2
divsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    1288 <sunmodel_atmo_refraction_correction+0x178>
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
movsd  -0x8(%rbp),%xmm3
movsd  0xe02(%rip),%xmm4
mulsd  %xmm4,%xmm3
movsd  0xdfe(%rip),%xmm4
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm2
movsd  0xdde(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xdc6(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdae(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    129a <sunmodel_atmo_refraction_correction+0x18a>
movsd  0xd90(%rip),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    129f <sunmodel_atmo_refraction_correction+0x18f>
mov    0x2d42(%rip),%rax
movsd  (%rax),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xdb1(%rip),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd39(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sunmodel_atmo_refraction_correction>:
push   %rbx
sub    $0x10,%rsp
mov    0x2ecc(%rip),%rbx
movsd  (%rbx),%xmm1
mulsd  0xed8(%rip),%xmm1
divsd  0xed8(%rip),%xmm1
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm2
ja     122b <sunmodel_atmo_refraction_correction+0x11b>
movapd %xmm2,%xmm0
movsd  %xmm2,0x8(%rsp)
call   1030 <tan@plt>
movsd  0x8(%rsp),%xmm3
movapd %xmm0,%xmm1
movsd  (%rbx),%xmm0
movsd  0xea9(%rip),%xmm2
mulsd  %xmm0,%xmm2
divsd  0xe95(%rip),%xmm2
ucomisd %xmm2,%xmm3
jbe    11b7 <sunmodel_atmo_refraction_correction+0xa7>
movapd %xmm1,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm2
movsd  0xec3(%rip),%xmm3
divsd  %xmm2,%xmm3
mulsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm2
unpcklpd %xmm2,%xmm1
movapd 0xebb(%rip),%xmm2
divpd  %xmm1,%xmm2
addsd  %xmm2,%xmm3
unpckhpd %xmm2,%xmm2
addsd  %xmm3,%xmm2
jmp    1217 <sunmodel_atmo_refraction_correction+0x107>
movsd  0xe59(%rip),%xmm2
mulsd  %xmm0,%xmm2
divsd  0xe3d(%rip),%xmm2
ucomisd %xmm2,%xmm3
jbe    120b <sunmodel_atmo_refraction_correction+0xfb>
movsd  0xe4f(%rip),%xmm2
mulsd  %xmm3,%xmm2
addsd  0xe4b(%rip),%xmm2
mulsd  %xmm3,%xmm2
addsd  0xe47(%rip),%xmm2
mulsd  %xmm3,%xmm2
addsd  0xe43(%rip),%xmm2
mulsd  %xmm3,%xmm2
addsd  0xe3f(%rip),%xmm2
jmp    1217 <sunmodel_atmo_refraction_correction+0x107>
movsd  0xe0d(%rip),%xmm2
divsd  %xmm1,%xmm2
divsd  0xe39(%rip),%xmm2
mulsd  %xmm2,%xmm0
divsd  0xddd(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double @sunmodel_atmo_refraction_correction(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
store double %0, double* %2
%5 = load double, double* %2
%6 = load double, double* @M_PI
%7 = fmul double %6, 8.500000e+01
%8 = fdiv double %7, 1.800000e+02
%9 = fcmp ogt double %5, %8
br i1 %9, label %10, label %11
10: ; preds = %1
store double 0.000000e+00, double* %3
br label %65
11: ; preds = %1
%12 = load double, double* %2
%13 = call double @tan(double %12)
store double %13, double* %4
%14 = load double, double* %2
%15 = load double, double* @M_PI
%16 = fmul double %15, 5.000000e+00
%17 = fdiv double %16, 1.800000e+02
%18 = fcmp ogt double %14, %17
br i1 %18, label %19, label %40
19: ; preds = %11
%20 = load double, double* %4
%21 = fdiv double 5.810000e+01, %20
%22 = load double, double* %4
%23 = load double, double* %4
%24 = fmul double %22, %23
%25 = load double, double* %4
%26 = fmul double %24, %25
%27 = fdiv double 7.000000e-02, %26
%28 = fsub double %21, %27
%29 = load double, double* %4
%30 = load double, double* %4
%31 = fmul double %29, %30
%32 = load double, double* %4
%33 = fmul double %31, %32
%34 = load double, double* %4
%35 = fmul double %33, %34
%36 = load double, double* %4
%37 = fmul double %35, %36
%38 = fdiv double 8.600000e-05, %37
%39 = fadd double %28, %38
store double %39, double* %3
br label %59
40: ; preds = %11
%41 = load double, double* %2
%42 = load double, double* @M_PI
%43 = fmul double %42, -5.750000e-01
%44 = fdiv double %43, 1.800000e+02
%45 = fcmp ogt double %41, %44
br i1 %45, label %46, label %55
46: ; preds = %40
%47 = load double, double* %2
%48 = load double, double* %2
%49 = load double, double* %2
%50 = load double, double* %2
%51 = call double @llvm.fmuladd.f64(double %50, double 7.110000e-01, double -1.279000e+01)
%52 = call double @llvm.fmuladd.f64(double %49, double %51, double 1.034000e+02)
%53 = call double @llvm.fmuladd.f64(double %48, double %52, double -5.182000e+02)
%54 = call double @llvm.fmuladd.f64(double %47, double %53, double 1.735000e+03)
store double %54, double* %3
br label %58
55: ; preds = %40
%56 = load double, double* %4
%57 = fdiv double -2.077400e+01, %56
store double %57, double* %3
br label %58
58: ; preds = %55, %46
br label %59
59: ; preds = %58, %19
%60 = load double, double* @M_PI
%61 = load double, double* %3
%62 = fdiv double %61, 3.600000e+03
%63 = fmul double %60, %62
%64 = fdiv double %63, 1.800000e+02
store double %64, double* %3
br label %65
65: ; preds = %59, %10
%66 = load double, double* %3
ret double %66
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @sunmodel_atmo_refraction_correction(double %0) {
%2 = load double, double* @M_PI
%3 = fmul double %2, 8.500000e+01
%4 = fdiv double %3, 1.800000e+02
%5 = fcmp olt double %4, %0
br i1 %5, label %41, label %6
6: ; preds = %1
%7 = tail call double @tan(double %0)
%8 = load double, double* @M_PI
%9 = fmul double %8, 5.000000e+00
%10 = fdiv double %9, 1.800000e+02
%11 = fcmp olt double %10, %0
br i1 %11, label %12, label %25
12: ; preds = %6
%13 = fmul double %7, %7
%14 = fmul double %7, %13
%15 = fdiv double 7.000000e-02, %14
%16 = fmul double %7, %14
%17 = fmul double %7, %16
%18 = insertelement <2 x double> poison, double %7, i64 0
%19 = insertelement <2 x double> %18, double %17, i64 1
%20 = fdiv <2 x double> <double 5.810000e+01, double 8.600000e-05>, %19
%21 = extractelement <2 x double> %20, i64 0
%22 = fsub double %21, %15
%23 = extractelement <2 x double> %20, i64 1
%24 = fadd double %22, %23
br label %36
25: ; preds = %6
%26 = fmul double %8, -5.750000e-01
%27 = fdiv double %26, 1.800000e+02
%28 = fcmp olt double %27, %0
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = tail call double @llvm.fmuladd.f64(double %0, double 7.110000e-01, double -1.279000e+01)
%31 = tail call double @llvm.fmuladd.f64(double %0, double %30, double 1.034000e+02)
%32 = tail call double @llvm.fmuladd.f64(double %0, double %31, double -5.182000e+02)
%33 = tail call double @llvm.fmuladd.f64(double %0, double %32, double 1.735000e+03)
br label %36
34: ; preds = %25
%35 = fdiv double -2.077400e+01, %7
br label %36
36: ; preds = %29, %34, %12
%37 = phi double [ %24, %12 ], [ %33, %29 ], [ %35, %34 ]
%38 = fdiv double %37, 3.600000e+03
%39 = fmul double %8, %38
%40 = fdiv double %39, 1.800000e+02
br label %41
41: ; preds = %1, %36
%42 = phi double [ %40, %36 ], [ 0.000000e+00, %1 ]
ret double %42
}