#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 corsika_get_m_overburden(double h_cm, double *a, double *b, double *c,
                                double *t, double *hl) {
  double res = 0.0;
  int layer = 0;
  int i;
  for (i = 0; i < 5; ++i)
    if (!(h_cm <= hl[i]))
      layer = i;
  if (layer == 4)
    res = a[4] - b[4] / c[4] * h_cm;
  else
    res = a[layer] + b[layer] * exp(-h_cm / c[layer]);
  return res;
}


x86 assembly (clang, -O0):
<corsika_get_m_overburden>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
cmpl   $0x5,-0x40(%rbp)
jge    1186 <corsika_get_m_overburden+0x76>
movsd  -0x8(%rbp),%xmm1
mov    -0x30(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jae    1173 <corsika_get_m_overburden+0x63>
mov    -0x40(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    1178 <corsika_get_m_overburden+0x68>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1147 <corsika_get_m_overburden+0x37>
cmpl   $0x4,-0x3c(%rbp)
jne    11d9 <corsika_get_m_overburden+0xc9>
mov    -0x10(%rbp),%rax
movsd  0x20(%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  0x20(%rax),%xmm0
mov    -0x20(%rbp),%rax
divsd  0x20(%rax),%xmm0
movsd  -0x8(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1245 <corsika_get_m_overburden+0x135>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
call   1030 <exp@plt>
movsd  -0x50(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<corsika_get_m_overburden>:
sub    $0x18,%rsp
movsd  0x20(%r8),%xmm1
ucomisd %xmm0,%xmm1
jae    1140 <corsika_get_m_overburden+0x30>
movsd  0x20(%rdi),%xmm1
movsd  0x20(%rsi),%xmm2
divsd  0x20(%rdx),%xmm2
mulsd  %xmm0,%xmm2
subsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret
movsd  0x8(%r8),%xmm1
xor    %eax,%eax
ucomisd %xmm0,%xmm1
movsd  0x10(%r8),%xmm1
setb   %al
ucomisd %xmm0,%xmm1
mov    $0x2,%ecx
cmovae %rax,%rcx
movsd  0x18(%r8),%xmm1
ucomisd %xmm0,%xmm1
mov    $0x3,%eax
cmovae %rcx,%rax
movsd  (%rdi,%rax,8),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  (%rsi,%rax,8),%xmm1
movsd  %xmm1,0x8(%rsp)
xorpd  0xe6d(%rip),%xmm0
divsd  (%rdx,%rax,8),%xmm0
call   1030 <exp@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @corsika_get_m_overburden(double %0, double* %1, double* %2, double* %3, double* %4, double* %5) {
%7 = alloca double
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double
%14 = alloca i32
%15 = alloca i32
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
store double* %5, double** %12
store double 0.000000e+00, double* %13
store i32 0, i32* %14
store i32 0, i32* %15
br label %16
16: ; preds = %30, %6
%17 = load i32, i32* %15
%18 = icmp slt i32 %17, 5
br i1 %18, label %19, label %33
19: ; preds = %16
%20 = load double, double* %7
%21 = load double*, double** %12
%22 = load i32, i32* %15
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
%25 = load double, double* %24
%26 = fcmp ole double %20, %25
br i1 %26, label %29, label %27
27: ; preds = %19
%28 = load i32, i32* %15
store i32 %28, i32* %14
br label %29
29: ; preds = %27, %19
br label %30
30: ; preds = %29
%31 = load i32, i32* %15
%32 = add nsw i32 %31, 1
store i32 %32, i32* %15
br label %16
33: ; preds = %16
%34 = load i32, i32* %14
%35 = icmp eq i32 %34, 4
br i1 %35, label %36, label %50
36: ; preds = %33
%37 = load double*, double** %8
%38 = getelementptr inbounds double, double* %37, i64 4
%39 = load double, double* %38
%40 = load double*, double** %9
%41 = getelementptr inbounds double, double* %40, i64 4
%42 = load double, double* %41
%43 = load double*, double** %10
%44 = getelementptr inbounds double, double* %43, i64 4
%45 = load double, double* %44
%46 = fdiv double %42, %45
%47 = load double, double* %7
%48 = fneg double %46
%49 = call double @llvm.fmuladd.f64(double %48, double %47, double %39)
store double %49, double* %13
br label %71
50: ; preds = %33
%51 = load double*, double** %8
%52 = load i32, i32* %14
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
%55 = load double, double* %54
%56 = load double*, double** %9
%57 = load i32, i32* %14
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %56, i64 %58
%60 = load double, double* %59
%61 = load double, double* %7
%62 = fneg double %61
%63 = load double*, double** %10
%64 = load i32, i32* %14
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double, double* %63, i64 %65
%67 = load double, double* %66
%68 = fdiv double %62, %67
%69 = call double @exp(double %68)
%70 = call double @llvm.fmuladd.f64(double %60, double %69, double %55)
store double %70, double* %13
br label %71
71: ; preds = %50, %36
%72 = load double, double* %13
ret double %72
}

LLVM IR (-O2):
define double @corsika_get_m_overburden(double %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, double* nocapture readnone %4, double* nocapture %5) {
%7 = getelementptr inbounds double, double* %5, i64 4
%8 = load double, double* %7
%9 = fcmp ult double %8, %0
br i1 %9, label %10, label %20
10: ; preds = %6
%11 = getelementptr inbounds double, double* %1, i64 4
%12 = load double, double* %11
%13 = getelementptr inbounds double, double* %2, i64 4
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %3, i64 4
%16 = load double, double* %15
%17 = fneg double %14
%18 = fdiv double %17, %16
%19 = tail call double @llvm.fmuladd.f64(double %18, double %0, double %12)
br label %43
20: ; preds = %6
%21 = getelementptr inbounds double, double* %5, i64 3
%22 = load double, double* %21
%23 = fcmp ult double %22, %0
%24 = getelementptr inbounds double, double* %5, i64 2
%25 = load double, double* %24
%26 = fcmp ult double %25, %0
%27 = getelementptr inbounds double, double* %5, i64 1
%28 = load double, double* %27
%29 = fcmp ult double %28, %0
%30 = zext i1 %29 to i64
%31 = select i1 %26, i64 2, i64 %30
%32 = select i1 %23, i64 3, i64 %31
%33 = getelementptr inbounds double, double* %1, i64 %32
%34 = load double, double* %33
%35 = getelementptr inbounds double, double* %2, i64 %32
%36 = load double, double* %35
%37 = fneg double %0
%38 = getelementptr inbounds double, double* %3, i64 %32
%39 = load double, double* %38
%40 = fdiv double %37, %39
%41 = tail call double @exp(double %40)
%42 = tail call double @llvm.fmuladd.f64(double %36, double %41, double %34)
br label %43
43: ; preds = %20, %10
%44 = phi double [ %19, %10 ], [ %42, %20 ]
ret double %44
}