#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 */
float turbine_power(unsigned long, float, float);
void arr_turbine_hk_and_p(unsigned long int uTurb, float h, float *pHK,
                          float *pPow, float *pFloStates, unsigned long int n) {
  float fTol = 1E-6;
  unsigned long int i = 0;
  float q, p;
  for (i = 0; i < n; i++) {
    q = pFloStates[i];
    p = (q < fTol) ? 0 : turbine_power(uTurb, h, q);
    pHK[i] = (q < fTol) ? 0 : p / q;
    pPow[i] = p;
  }
}


x86 assembly (clang, -O0):
<arr_turbine_hk_and_p>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
movss  0xec7(%rip),%xmm0
movss  %xmm0,-0x34(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    1214 <arr_turbine_hk_and_p+0x104>
mov    -0x28(%rbp),%rax
mov    -0x40(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x44(%rbp)
movss  -0x44(%rbp),%xmm1
movss  -0x34(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    118e <arr_turbine_hk_and_p+0x7e>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4c(%rbp)
jmp    11a6 <arr_turbine_hk_and_p+0x96>
mov    -0x8(%rbp),%rdi
movss  -0xc(%rbp),%xmm0
movss  -0x44(%rbp),%xmm1
call   1030 <turbine_power@plt>
movss  %xmm0,-0x4c(%rbp)
movss  -0x4c(%rbp),%xmm0
movss  %xmm0,-0x48(%rbp)
movss  -0x44(%rbp),%xmm1
movss  -0x34(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11d0 <arr_turbine_hk_and_p+0xc0>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x50(%rbp)
jmp    11df <arr_turbine_hk_and_p+0xcf>
movss  -0x48(%rbp),%xmm0
divss  -0x44(%rbp),%xmm0
movss  %xmm0,-0x50(%rbp)
movss  -0x50(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x40(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
movss  -0x48(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x40(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    114e <arr_turbine_hk_and_p+0x3e>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arr_turbine_hk_and_p>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movss  %xmm0,(%rsp)
test   %r8,%r8
je     119b <arr_turbine_hk_and_p+0x8b>
mov    %r8,%rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
xor    %ebp,%ebp
movss  0xec2(%rip),%xmm1
jmp    1155 <arr_turbine_hk_and_p+0x45>
movss  %xmm2,(%r12,%rbp,4)
movss  %xmm0,(%r15,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%rbx
je     119b <arr_turbine_hk_and_p+0x8b>
movss  (%r14,%rbp,4),%xmm3
xorps  %xmm2,%xmm2
ucomiss %xmm3,%xmm1
xorps  %xmm0,%xmm0
ja     118d <arr_turbine_hk_and_p+0x7d>
mov    %r13,%rdi
movss  (%rsp),%xmm0
movaps %xmm3,%xmm1
movss  %xmm3,0x4(%rsp)
call   1030 <turbine_power@plt>
movss  0x4(%rsp),%xmm3
xorps  %xmm2,%xmm2
movss  0xe73(%rip),%xmm1
ucomiss %xmm3,%xmm1
ja     1140 <arr_turbine_hk_and_p+0x30>
movaps %xmm0,%xmm2
divss  %xmm3,%xmm2
jmp    1140 <arr_turbine_hk_and_p+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @arr_turbine_hk_and_p(i64 %0, float %1, float* %2, float* %3, float* %4, i64 %5) {
%7 = alloca i64
%8 = alloca float
%9 = alloca float*
%10 = alloca float*
%11 = alloca float*
%12 = alloca i64
%13 = alloca float
%14 = alloca i64
%15 = alloca float
%16 = alloca float
store i64 %0, i64* %7
store float %1, float* %8
store float* %2, float** %9
store float* %3, float** %10
store float* %4, float** %11
store i64 %5, i64* %12
store float 0x3EB0C6F7A0000000, float* %13
store i64 0, i64* %14
store i64 0, i64* %14
br label %17
17: ; preds = %54, %6
%18 = load i64, i64* %14
%19 = load i64, i64* %12
%20 = icmp ult i64 %18, %19
br i1 %20, label %21, label %57
21: ; preds = %17
%22 = load float*, float** %11
%23 = load i64, i64* %14
%24 = getelementptr inbounds float, float* %22, i64 %23
%25 = load float, float* %24
store float %25, float* %15
%26 = load float, float* %15
%27 = load float, float* %13
%28 = fcmp olt float %26, %27
br i1 %28, label %29, label %30
29: ; preds = %21
br label %35
30: ; preds = %21
%31 = load i64, i64* %7
%32 = load float, float* %8
%33 = load float, float* %15
%34 = call float @turbine_power(i64 %31, float %32, float %33)
br label %35
35: ; preds = %30, %29
%36 = phi float [ 0.000000e+00, %29 ], [ %34, %30 ]
store float %36, float* %16
%37 = load float, float* %15
%38 = load float, float* %13
%39 = fcmp olt float %37, %38
br i1 %39, label %40, label %41
40: ; preds = %35
br label %45
41: ; preds = %35
%42 = load float, float* %16
%43 = load float, float* %15
%44 = fdiv float %42, %43
br label %45
45: ; preds = %41, %40
%46 = phi float [ 0.000000e+00, %40 ], [ %44, %41 ]
%47 = load float*, float** %9
%48 = load i64, i64* %14
%49 = getelementptr inbounds float, float* %47, i64 %48
store float %46, float* %49
%50 = load float, float* %16
%51 = load float*, float** %10
%52 = load i64, i64* %14
%53 = getelementptr inbounds float, float* %51, i64 %52
store float %50, float* %53
br label %54
54: ; preds = %45
%55 = load i64, i64* %14
%56 = add i64 %55, 1
store i64 %56, i64* %14
br label %17
57: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @arr_turbine_hk_and_p(i64 %0, float %1, float* nocapture writeonly %2, float* nocapture writeonly %3, float* nocapture %4, i64 %5) {
%7 = icmp eq i64 %5, 0
br i1 %7, label %23, label %8
8: ; preds = %6, %15
%9 = phi i64 [ %21, %15 ], [ 0, %6 ]
%10 = getelementptr inbounds float, float* %4, i64 %9
%11 = load float, float* %10
%12 = fcmp olt float %11, 0x3EB0C6F7A0000000
br i1 %12, label %15, label %13
13: ; preds = %8
%14 = tail call float @turbine_power(i64 %0, float %1, float %11)
br label %15
15: ; preds = %8, %13
%16 = phi float [ %14, %13 ], [ 0.000000e+00, %8 ]
%17 = fdiv float %16, %11
%18 = select i1 %12, float 0.000000e+00, float %17
%19 = getelementptr inbounds float, float* %2, i64 %9
store float %18, float* %19
%20 = getelementptr inbounds float, float* %3, i64 %9
store float %16, float* %20
%21 = add nuw i64 %9, 1
%22 = icmp eq i64 %21, %5
br i1 %22, label %23, label %8
23: ; preds = %15, %6
ret void
}