#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 */
int log(double const);
void pressure2height(double *restrict hlev, const double *restrict plev,
                     long nphlev) {
  long k;
  for (k = 0; k < nphlev; k++) {
    hlev[k] = log(plev[k] / (101325.0)) * (-7000.);
  }
}


x86 assembly (clang, -O0):
<pressure2height>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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    1186 <pressure2height+0x76>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xeb9(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <log@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe9c(%rip),%xmm1
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 <pressure2height+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pressure2height>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdx,%rdx
jle    1161 <pressure2height+0x51>
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 <log@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xeb6(%rip),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <pressure2height+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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