#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_density(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 = b[4] / c[4];
  else
    res = b[layer] / c[layer] * exp(-h_cm / c[layer]);
  return res;
}


x86 assembly (clang, -O0):
<corsika_get_density>:
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_density+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_density+0x63>
mov    -0x40(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    1178 <corsika_get_density+0x68>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1147 <corsika_get_density+0x37>
cmpl   $0x4,-0x3c(%rbp)
jne    11ac <corsika_get_density+0x9c>
mov    -0x18(%rbp),%rax
movsd  0x20(%rax),%xmm0
mov    -0x20(%rbp),%rax
divsd  0x20(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    120a <corsika_get_density+0xfa>
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
divsd  (%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>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<corsika_get_density>:
push   %rax
movsd  0x20(%r8),%xmm1
ucomisd %xmm0,%xmm1
jae    1129 <corsika_get_density+0x19>
movsd  0x20(%rsi),%xmm0
divsd  0x20(%rdx),%xmm0
pop    %rax
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  (%rsi,%rax,8),%xmm2
movsd  (%rdx,%rax,8),%xmm1
divsd  %xmm1,%xmm2
movsd  %xmm2,(%rsp)
xorpd  0xe87(%rip),%xmm0
divsd  %xmm1,%xmm0
call   1030 <exp@plt>
mulsd  (%rsp),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @corsika_get_density(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 %44
36: ; preds = %33
%37 = load double*, double** %9
%38 = getelementptr inbounds double, double* %37, i64 4
%39 = load double, double* %38
%40 = load double*, double** %10
%41 = getelementptr inbounds double, double* %40, i64 4
%42 = load double, double* %41
%43 = fdiv double %39, %42
store double %43, double* %13
br label %66
44: ; preds = %33
%45 = load double*, double** %9
%46 = load i32, i32* %14
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %45, i64 %47
%49 = load double, double* %48
%50 = load double*, double** %10
%51 = load i32, i32* %14
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double, double* %50, i64 %52
%54 = load double, double* %53
%55 = fdiv double %49, %54
%56 = load double, double* %7
%57 = fneg double %56
%58 = load double*, double** %10
%59 = load i32, i32* %14
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %58, i64 %60
%62 = load double, double* %61
%63 = fdiv double %57, %62
%64 = call double @exp(double %63)
%65 = fmul double %55, %64
store double %65, double* %13
br label %66
66: ; preds = %44, %36
%67 = load double, double* %13
ret double %67
}

LLVM IR (-O2):
define double @corsika_get_density(double %0, double* nocapture readnone %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 %16
10: ; preds = %6
%11 = getelementptr inbounds double, double* %2, i64 4
%12 = load double, double* %11
%13 = getelementptr inbounds double, double* %3, i64 4
%14 = load double, double* %13
%15 = fdiv double %12, %14
br label %38
16: ; preds = %6
%17 = getelementptr inbounds double, double* %5, i64 3
%18 = load double, double* %17
%19 = fcmp ult double %18, %0
%20 = getelementptr inbounds double, double* %5, i64 2
%21 = load double, double* %20
%22 = fcmp ult double %21, %0
%23 = getelementptr inbounds double, double* %5, i64 1
%24 = load double, double* %23
%25 = fcmp ult double %24, %0
%26 = zext i1 %25 to i64
%27 = select i1 %22, i64 2, i64 %26
%28 = select i1 %19, i64 3, i64 %27
%29 = getelementptr inbounds double, double* %2, i64 %28
%30 = load double, double* %29
%31 = getelementptr inbounds double, double* %3, i64 %28
%32 = load double, double* %31
%33 = fdiv double %30, %32
%34 = fneg double %0
%35 = fdiv double %34, %32
%36 = tail call double @exp(double %35)
%37 = fmul double %33, %36
br label %38
38: ; preds = %16, %10
%39 = phi double [ %15, %10 ], [ %37, %16 ]
ret double %39
}