#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);
void height2pressure(double *restrict phlev, const double *restrict hlev,
                     long nphlev) {
  long k;
  double exp_arg;
  double height;
  for (k = 0; k < nphlev; k++) {
    height = hlev[k];
    exp_arg = height / (-7000.);
    phlev[k] = (101325.0) * exp(exp_arg);
  }
}


x86 assembly (clang, -O0):
<height2pressure>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    1199 <height2pressure+0x89>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xeaf(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  0xe89(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112c <height2pressure+0x1c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<height2pressure>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdx,%rdx
jle    115a <height2pressure+0x4a>
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsd  (%r14,%rbx,8),%xmm0
divsd  0xec2(%rip),%xmm0
call   1030 <exp@plt>
mulsd  0xebd(%rip),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <height2pressure+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @height2pressure(double* noalias %0, double* noalias %1, i64 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i64
%7 = alloca i64
%8 = alloca double
%9 = alloca double
store double* %0, double** %4
store double* %1, double** %5
store i64 %2, i64* %6
store i64 0, i64* %7
br label %10
10: ; preds = %27, %3
%11 = load i64, i64* %7
%12 = load i64, i64* %6
%13 = icmp slt i64 %11, %12
br i1 %13, label %14, label %30
14: ; preds = %10
%15 = load double*, double** %5
%16 = load i64, i64* %7
%17 = getelementptr inbounds double, double* %15, i64 %16
%18 = load double, double* %17
store double %18, double* %9
%19 = load double, double* %9
%20 = fdiv double %19, -7.000000e+03
store double %20, double* %8
%21 = load double, double* %8
%22 = call double @exp(double %21)
%23 = fmul double 1.013250e+05, %22
%24 = load double*, double** %4
%25 = load i64, i64* %7
%26 = getelementptr inbounds double, double* %24, i64 %25
store double %23, double* %26
br label %27
27: ; preds = %14
%28 = load i64, i64* %7
%29 = add nsw i64 %28, 1
store i64 %29, i64* %7
br label %10
30: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @height2pressure(double* noalias nocapture writeonly %0, double* noalias nocapture %1, i64 %2) {
%4 = icmp sgt i64 %2, 0
br i1 %4, label %5, label %15
5: ; preds = %3, %5
%6 = phi i64 [ %13, %5 ], [ 0, %3 ]
%7 = getelementptr inbounds double, double* %1, i64 %6
%8 = load double, double* %7
%9 = fdiv double %8, -7.000000e+03
%10 = tail call double @exp(double %9)
%11 = fmul double %10, 1.013250e+05
%12 = getelementptr inbounds double, double* %0, i64 %6
store double %11, double* %12
%13 = add nuw nsw i64 %6, 1
%14 = icmp eq i64 %13, %2
br i1 %14, label %15, label %5
15: ; preds = %5, %3
ret void
}