#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 */
scalar_t__ db_inv(float);
float db_pos(float);
int nm_pos_geomean(int, int);
int noisemasker_band(float *psd, int *tone_flag, int lowbin, int highbin,
                     float *nm, int *nm_pos) {
  int k;
  float tmp;
  *nm = 0;
  tmp = 0;
  for (k = lowbin; k <= highbin; k++) {
    if (!tone_flag[k]) {
      tmp += db_inv(psd[k]);
    }
  }
  *nm = db_pos(tmp);
  *nm_pos = nm_pos_geomean(lowbin + 1, highbin + 1) - 1;
  return 0;
}


x86 assembly (clang, -O0):
<noisemasker_band>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11b9 <noisemasker_band+0x89>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    11a6 <noisemasker_band+0x76>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
call   1040 <db_inv@plt>
cvtsi2ss %rax,%xmm0
addss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
jmp    11ab <noisemasker_band+0x7b>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1167 <noisemasker_band+0x37>
movss  -0x30(%rbp),%xmm0
call   1030 <db_pos@plt>
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x14(%rbp),%edi
add    $0x1,%edi
mov    -0x18(%rbp),%esi
add    $0x1,%esi
call   1050 <nm_pos_geomean@plt>
mov    %eax,%ecx
sub    $0x1,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<noisemasker_band>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%rbx
mov    %r8,%rbp
mov    %ecx,%r12d
mov    %edx,%r13d
movl   $0x0,(%r8)
cmp    %ecx,%edx
jle    115e <noisemasker_band+0x2e>
add    $0x1,%r12d
xorps  %xmm0,%xmm0
jmp    11dc <noisemasker_band+0xac>
mov    %rbp,0x8(%rsp)
mov    %rbx,0x10(%rsp)
movslq %r13d,%rax
add    $0x1,%r12d
lea    (%rsi,%rax,4),%rbp
lea    (%rdi,%rax,4),%rbx
mov    %r12d,%r14d
sub    %r13d,%r14d
xorps  %xmm0,%xmm0
xor    %r15d,%r15d
jmp    1199 <noisemasker_band+0x69>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r15
cmp    %r15d,%r14d
je     11d2 <noisemasker_band+0xa2>
cmpl   $0x0,0x0(%rbp,%r15,4)
jne    1190 <noisemasker_band+0x60>
movss  %xmm0,0x4(%rsp)
movss  (%rbx,%r15,4),%xmm0
call   1040 <db_inv@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  0x4(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
movss  0x4(%rsp),%xmm0
jmp    1190 <noisemasker_band+0x60>
mov    0x10(%rsp),%rbx
mov    0x8(%rsp),%rbp
call   1030 <db_pos@plt>
movss  %xmm0,0x0(%rbp)
add    $0x1,%r13d
mov    %r13d,%edi
mov    %r12d,%esi
call   1050 <nm_pos_geomean@plt>
add    $0xffffffff,%eax
mov    %eax,(%rbx)
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @noisemasker_band(float* %0, i32* %1, i32 %2, i32 %3, float* %4, i32* %5) {
%7 = alloca float*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca float*
%12 = alloca i32*
%13 = alloca i32
%14 = alloca float
store float* %0, float** %7
store i32* %1, i32** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store float* %4, float** %11
store i32* %5, i32** %12
%15 = load float*, float** %11
store float 0.000000e+00, float* %15
store float 0.000000e+00, float* %14
%16 = load i32, i32* %9
store i32 %16, i32* %13
br label %17
17: ; preds = %39, %6
%18 = load i32, i32* %13
%19 = load i32, i32* %10
%20 = icmp sle i32 %18, %19
br i1 %20, label %21, label %42
21: ; preds = %17
%22 = load i32*, i32** %8
%23 = load i32, i32* %13
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = load i32, i32* %25
%27 = icmp ne i32 %26, 0
br i1 %27, label %38, label %28
28: ; preds = %21
%29 = load float*, float** %7
%30 = load i32, i32* %13
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds float, float* %29, i64 %31
%33 = load float, float* %32
%34 = call i64 @db_inv(float %33)
%35 = sitofp i64 %34 to float
%36 = load float, float* %14
%37 = fadd float %36, %35
store float %37, float* %14
br label %38
38: ; preds = %28, %21
br label %39
39: ; preds = %38
%40 = load i32, i32* %13
%41 = add nsw i32 %40, 1
store i32 %41, i32* %13
br label %17
42: ; preds = %17
%43 = load float, float* %14
%44 = call float @db_pos(float %43)
%45 = load float*, float** %11
store float %44, float* %45
%46 = load i32, i32* %9
%47 = add nsw i32 %46, 1
%48 = load i32, i32* %10
%49 = add nsw i32 %48, 1
%50 = call i32 @nm_pos_geomean(i32 %47, i32 %49)
%51 = sub nsw i32 %50, 1
%52 = load i32*, i32** %12
store i32 %51, i32* %52
ret i32 0
}

LLVM IR (-O2):
define i32 @noisemasker_band(float* nocapture %0, i32* nocapture %1, i32 %2, i32 %3, float* nocapture writeonly %4, i32* nocapture writeonly %5) {
store float 0.000000e+00, float* %4
%7 = icmp sgt i32 %2, %3
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = add nsw i32 %3, 1
br label %30
10: ; preds = %6
%11 = sext i32 %2 to i64
%12 = add i32 %3, 1
br label %13
13: ; preds = %10, %25
%14 = phi i64 [ %11, %10 ], [ %27, %25 ]
%15 = phi float [ 0.000000e+00, %10 ], [ %26, %25 ]
%16 = getelementptr inbounds i32, i32* %1, i64 %14
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %13
%20 = getelementptr inbounds float, float* %0, i64 %14
%21 = load float, float* %20
%22 = tail call i64 @db_inv(float %21)
%23 = sitofp i64 %22 to float
%24 = fadd float %15, %23
br label %25
25: ; preds = %13, %19
%26 = phi float [ %15, %13 ], [ %24, %19 ]
%27 = add nsw i64 %14, 1
%28 = trunc i64 %27 to i32
%29 = icmp eq i32 %12, %28
br i1 %29, label %30, label %13
30: ; preds = %25, %8
%31 = phi i32 [ %9, %8 ], [ %12, %25 ]
%32 = phi float [ 0.000000e+00, %8 ], [ %26, %25 ]
%33 = tail call float @db_pos(float %32)
store float %33, float* %4
%34 = add nsw i32 %2, 1
%35 = tail call i32 @nm_pos_geomean(i32 %34, i32 %31)
%36 = add nsw i32 %35, -1
store i32 %36, i32* %5
ret i32 0
}