#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 exp(double);
double ccor2(double alt, double r, double h1, double zh, double h2) {
  double e1, e2;
  double ex1, ex2;
  double ccor2v;
  e1 = (alt - zh) / h1;
  e2 = (alt - zh) / h2;
  if ((e1 > 70) || (e2 > 70))
    return exp(0);
  if ((e1 < -70) && (e2 < -70))
    return exp(r);
  ex1 = exp(e1);
  ex2 = exp(e2);
  ccor2v = r / (1.0 + 0.5 * (ex1 + ex2));
  return exp(ccor2v);
}


x86 assembly (clang, -O0):
<ccor2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xe9a(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1187 <ccor2+0x77>
movsd  -0x40(%rbp),%xmm0
movsd  0xe83(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1199 <ccor2+0x89>
xorps  %xmm0,%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1230 <ccor2+0x120>
movsd  0xe67(%rip),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    11d3 <ccor2+0xc3>
movsd  0xe54(%rip),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    11d3 <ccor2+0xc3>
movsd  -0x18(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1230 <ccor2+0x120>
movsd  -0x38(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
addsd  -0x50(%rbp),%xmm1
movsd  0xe08(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe04(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ccor2>:
sub    $0x28,%rsp
subsd  %xmm3,%xmm0
unpcklpd %xmm0,%xmm0
unpcklpd %xmm4,%xmm2
divpd  %xmm2,%xmm0
ucomisd 0xed4(%rip),%xmm0
ja     11a2 <ccor2+0x92>
movapd %xmm0,%xmm3
unpckhpd %xmm0,%xmm3
ucomisd 0xec2(%rip),%xmm3
ja     11a2 <ccor2+0x92>
movapd %xmm0,%xmm2
cmpltpd 0xed3(%rip),%xmm2
movmskpd %xmm2,%eax
cmp    $0x3,%al
je     1195 <ccor2+0x85>
movsd  %xmm1,0x8(%rsp)
movapd %xmm3,0x10(%rsp)
call   1030 <exp@plt>
movsd  %xmm0,(%rsp)
movapd 0x10(%rsp),%xmm0
call   1030 <exp@plt>
movsd  0x8(%rsp),%xmm1
addsd  (%rsp),%xmm0
mulsd  0xe7f(%rip),%xmm0
addsd  0xe7f(%rip),%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
jmp    1030 <exp@plt>
movsd  0xe66(%rip),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @ccor2(double %0, double %1, double %2, double %3, double %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store double %4, double* %11
%17 = load double, double* %7
%18 = load double, double* %10
%19 = fsub double %17, %18
%20 = load double, double* %9
%21 = fdiv double %19, %20
store double %21, double* %12
%22 = load double, double* %7
%23 = load double, double* %10
%24 = fsub double %22, %23
%25 = load double, double* %11
%26 = fdiv double %24, %25
store double %26, double* %13
%27 = load double, double* %12
%28 = fcmp ogt double %27, 7.000000e+01
br i1 %28, label %32, label %29
29: ; preds = %5
%30 = load double, double* %13
%31 = fcmp ogt double %30, 7.000000e+01
br i1 %31, label %32, label %34
32: ; preds = %29, %5
%33 = call double @exp(double 0.000000e+00)
store double %33, double* %6
br label %56
34: ; preds = %29
%35 = load double, double* %12
%36 = fcmp olt double %35, -7.000000e+01
br i1 %36, label %37, label %43
37: ; preds = %34
%38 = load double, double* %13
%39 = fcmp olt double %38, -7.000000e+01
br i1 %39, label %40, label %43
40: ; preds = %37
%41 = load double, double* %8
%42 = call double @exp(double %41)
store double %42, double* %6
br label %56
43: ; preds = %37, %34
%44 = load double, double* %12
%45 = call double @exp(double %44)
store double %45, double* %14
%46 = load double, double* %13
%47 = call double @exp(double %46)
store double %47, double* %15
%48 = load double, double* %8
%49 = load double, double* %14
%50 = load double, double* %15
%51 = fadd double %49, %50
%52 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %51, double 1.000000e+00)
%53 = fdiv double %48, %52
store double %53, double* %16
%54 = load double, double* %16
%55 = call double @exp(double %54)
store double %55, double* %6
br label %56
56: ; preds = %43, %40, %32
%57 = load double, double* %6
ret double %57
}

LLVM IR (-O2):
define double @ccor2(double %0, double %1, double %2, double %3, double %4) {
%6 = fsub double %0, %3
%7 = insertelement <2 x double> poison, double %6, i64 0
%8 = shufflevector <2 x double> %7, <2 x double> poison, <2 x i32> zeroinitializer
%9 = insertelement <2 x double> poison, double %2, i64 0
%10 = insertelement <2 x double> %9, double %4, i64 1
%11 = fdiv <2 x double> %8, %10
%12 = extractelement <2 x double> %11, i64 0
%13 = fcmp ogt double %12, 7.000000e+01
%14 = extractelement <2 x double> %11, i64 1
%15 = fcmp ogt double %14, 7.000000e+01
%16 = or i1 %13, %15
br i1 %16, label %31, label %17
17: ; preds = %5
%18 = fcmp olt <2 x double> %11, <double -7.000000e+01, double -7.000000e+01>
%19 = shufflevector <2 x i1> %18, <2 x i1> poison, <2 x i32> <i32 1, i32 undef>
%20 = and <2 x i1> %18, %19
%21 = extractelement <2 x i1> %20, i64 0
br i1 %21, label %28, label %22
22: ; preds = %17
%23 = tail call double @exp(double %12)
%24 = tail call double @exp(double %14)
%25 = fadd double %23, %24
%26 = tail call double @llvm.fmuladd.f64(double %25, double 5.000000e-01, double 1.000000e+00)
%27 = fdiv double %1, %26
br label %28
28: ; preds = %17, %22
%29 = phi double [ %27, %22 ], [ %1, %17 ]
%30 = tail call double @exp(double %29)
br label %31
31: ; preds = %28, %5
%32 = phi double [ 1.000000e+00, %5 ], [ %30, %28 ]
ret double %32
}