#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 tan(double);
double TopoAltfromAppAlt(double AppAlt, double TempE, double PresE) {
  double R = 0;
  double retalt = 0;
  if (AppAlt >= -3.5) {
    if (AppAlt > 17.904104638432)
      R = 0.97 / tan(AppAlt * (3.14159265358979323846 / 180.0));
    else
      R = (34.46 + 4.23 * AppAlt + 0.004 * AppAlt * AppAlt) /
          (1 + 0.505 * AppAlt + 0.0845 * AppAlt * AppAlt);
    R = (PresE - 80) / 930 / (1 + 0.00008 * (R + 39) * (TempE - 10)) * R;
    retalt = AppAlt - R * (1.0 / 60.0);
  } else {
    retalt = AppAlt;
  }
  return retalt;
}


x86 assembly (clang, -O0):
<TopoAltfromAppAlt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xebc(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     12a7 <TopoAltfromAppAlt+0x197>
movsd  -0x8(%rbp),%xmm0
movsd  0xead(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1190 <TopoAltfromAppAlt+0x80>
movsd  0xedb(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1030 <tan@plt>
movaps %xmm0,%xmm1
movsd  0xebe(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1207 <TopoAltfromAppAlt+0xf7>
movsd  -0x8(%rbp),%xmm1
movsd  0xe93(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe8f(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xe73(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  0xe44(%rip),%xmm1
mulsd  %xmm1,%xmm2
movsd  0xe40(%rip),%xmm1
addsd  %xmm1,%xmm2
movsd  0xe24(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe64(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe50(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe3c(%rip),%xmm2
addsd  -0x20(%rbp),%xmm2
movsd  0xe27(%rip),%xmm1
mulsd  %xmm2,%xmm1
movsd  -0x10(%rbp),%xmm2
movsd  0xe0e(%rip),%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xdc6(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xdbb(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    12b1 <TopoAltfromAppAlt+0x1a1>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TopoAltfromAppAlt>:
sub    $0x28,%rsp
movapd %xmm0,%xmm4
ucomisd 0xee0(%rip),%xmm0
jae    112b <TopoAltfromAppAlt+0x1b>
movapd %xmm4,%xmm0
add    $0x28,%rsp
ret
ucomisd 0xed5(%rip),%xmm4
jbe    1172 <TopoAltfromAppAlt+0x62>
movsd  0xed3(%rip),%xmm0
mulsd  %xmm4,%xmm0
movsd  %xmm2,0x8(%rsp)
movapd %xmm4,0x10(%rsp)
movsd  %xmm1,(%rsp)
call   1030 <tan@plt>
movsd  (%rsp),%xmm1
movapd 0x10(%rsp),%xmm4
movsd  0x8(%rsp),%xmm2
movsd  0xea8(%rip),%xmm5
jmp    11aa <TopoAltfromAppAlt+0x9a>
movapd %xmm4,%xmm0
unpcklpd %xmm4,%xmm0
movapd 0xede(%rip),%xmm3
mulpd  %xmm0,%xmm3
addpd  0xee2(%rip),%xmm3
movapd 0xeea(%rip),%xmm5
mulpd  %xmm0,%xmm5
mulpd  %xmm0,%xmm5
addpd  %xmm3,%xmm5
movapd %xmm5,%xmm0
unpckhpd %xmm5,%xmm0
divsd  %xmm0,%xmm5
addsd  0xe6a(%rip),%xmm2
movsd  0xe6a(%rip),%xmm0
addsd  %xmm5,%xmm0
mulsd  0xe66(%rip),%xmm0
addsd  0xe66(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xe62(%rip),%xmm1
divsd  0xe62(%rip),%xmm2
divsd  %xmm1,%xmm2
mulsd  %xmm5,%xmm2
mulsd  0xe5a(%rip),%xmm2
addsd  %xmm4,%xmm2
movapd %xmm2,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @TopoAltfromAppAlt(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %8
%9 = load double, double* %4
%10 = fcmp oge double %9, -3.500000e+00
br i1 %10, label %11, label %50
11: ; preds = %3
%12 = load double, double* %4
%13 = fcmp ogt double %12, 0x4031E77366CE3A33
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load double, double* %4
%16 = fmul double %15, 0x3F91DF46A2529D39
%17 = call double @tan(double %16)
%18 = fdiv double 0x3FEF0A3D70A3D70A, %17
store double %18, double* %7
br label %33
19: ; preds = %11
%20 = load double, double* %4
%21 = call double @llvm.fmuladd.f64(double 4.230000e+00, double %20, double 3.446000e+01)
%22 = load double, double* %4
%23 = fmul double 4.000000e-03, %22
%24 = load double, double* %4
%25 = call double @llvm.fmuladd.f64(double %23, double %24, double %21)
%26 = load double, double* %4
%27 = call double @llvm.fmuladd.f64(double 5.050000e-01, double %26, double 1.000000e+00)
%28 = load double, double* %4
%29 = fmul double 8.450000e-02, %28
%30 = load double, double* %4
%31 = call double @llvm.fmuladd.f64(double %29, double %30, double %27)
%32 = fdiv double %25, %31
store double %32, double* %7
br label %33
33: ; preds = %19, %14
%34 = load double, double* %6
%35 = fsub double %34, 8.000000e+01
%36 = fdiv double %35, 9.300000e+02
%37 = load double, double* %7
%38 = fadd double %37, 3.900000e+01
%39 = fmul double 8.000000e-05, %38
%40 = load double, double* %5
%41 = fsub double %40, 1.000000e+01
%42 = call double @llvm.fmuladd.f64(double %39, double %41, double 1.000000e+00)
%43 = fdiv double %36, %42
%44 = load double, double* %7
%45 = fmul double %43, %44
store double %45, double* %7
%46 = load double, double* %4
%47 = load double, double* %7
%48 = fneg double %47
%49 = call double @llvm.fmuladd.f64(double %48, double 0x3F91111111111111, double %46)
store double %49, double* %8
br label %52
50: ; preds = %3
%51 = load double, double* %4
store double %51, double* %8
br label %52
52: ; preds = %50, %33
%53 = load double, double* %8
ret double %53
}

LLVM IR (-O2):
define double @TopoAltfromAppAlt(double %0, double %1, double %2) {
%4 = fcmp ult double %0, -3.500000e+00
br i1 %4, label %31, label %5
5: ; preds = %3
%6 = fcmp ogt double %0, 0x4031E77366CE3A33
br i1 %6, label %7, label %11
7: ; preds = %5
%8 = fmul double %0, 0x3F91DF46A2529D39
%9 = tail call double @tan(double %8)
%10 = fdiv double 0x3FEF0A3D70A3D70A, %9
br label %20
11: ; preds = %5
%12 = insertelement <2 x double> poison, double %0, i64 0
%13 = shufflevector <2 x double> %12, <2 x double> poison, <2 x i32> zeroinitializer
%14 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %13, <2 x double> <double 4.230000e+00, double 5.050000e-01>, <2 x double> <double 3.446000e+01, double 1.000000e+00>)
%15 = fmul <2 x double> %13, <double 4.000000e-03, double 8.450000e-02>
%16 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %15, <2 x double> %13, <2 x double> %14)
%17 = extractelement <2 x double> %16, i64 0
%18 = extractelement <2 x double> %16, i64 1
%19 = fdiv double %17, %18
br label %20
20: ; preds = %11, %7
%21 = phi double [ %10, %7 ], [ %19, %11 ]
%22 = fadd double %2, -8.000000e+01
%23 = fadd double %21, 3.900000e+01
%24 = fmul double %23, 8.000000e-05
%25 = fadd double %1, -1.000000e+01
%26 = tail call double @llvm.fmuladd.f64(double %24, double %25, double 1.000000e+00)
%27 = fdiv double %22, -9.300000e+02
%28 = fdiv double %27, %26
%29 = fmul double %21, %28
%30 = tail call double @llvm.fmuladd.f64(double %29, double 0x3F91111111111111, double %0)
br label %31
31: ; preds = %3, %20
%32 = phi double [ %30, %20 ], [ %0, %3 ]
ret double %32
}