#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 /*<<< orphan*/ memset(float *, int /*<<< orphan*/, int);
int /*<<< orphan*/ noisemasker_band(float *, int *, int, int, float *, int *);
int psd_noisemasker(float *psd, int psd_len, int *tone_flag, int *cb_hopbin,
                    float *pnm) {
  int band;
  int lowbin, highbin;
  float nm;
  int nm_pos;
  lowbin = 0;
  memset(pnm, 0, sizeof(float) * psd_len);
  for (band = 0; band < 25; band++) {
    if (cb_hopbin[band] == 0)
      break;
    highbin = cb_hopbin[band] - 1;
    noisemasker_band(psd, tone_flag, lowbin, highbin, &nm, &nm_pos);
    lowbin = highbin + 1;
    pnm[nm_pos] = nm;
  }
  return 0;
}


x86 assembly (clang, -O0):
<psd_noisemasker>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x19,-0x2c(%rbp)
jge    11d4 <psd_noisemasker+0xb4>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    117f <psd_noisemasker+0x5f>
jmp    11d4 <psd_noisemasker+0xb4>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
sub    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%edx
mov    -0x34(%rbp),%ecx
lea    -0x38(%rbp),%r8
lea    -0x3c(%rbp),%r9
call   1040 <noisemasker_band@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
movss  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115e <psd_noisemasker+0x3e>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<psd_noisemasker>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rdi,%r12
lea    0x0(,%rsi,4),%edx
xor    %r13d,%r13d
mov    %r8,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
xor    %edx,%edx
nopl   (%rax)
mov    (%r14,%r13,4),%ebp
test   %ebp,%ebp
je     1189 <psd_noisemasker+0x69>
lea    -0x1(%rbp),%ecx
mov    %r12,%rdi
mov    %r15,%rsi
lea    0x4(%rsp),%r8
mov    %rsp,%r9
call   1040 <noisemasker_band@plt>
movss  0x4(%rsp),%xmm0
movslq (%rsp),%rax
movss  %xmm0,(%rbx,%rax,4)
add    $0x1,%r13
mov    %ebp,%edx
cmp    $0x19,%r13
jne    1150 <psd_noisemasker+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @psd_noisemasker(float* %0, i32 %1, i32* %2, i32* nocapture %3, float* %4) {
%6 = alloca float
%7 = alloca i32
%8 = bitcast float* %6 to i8*
%9 = bitcast i32* %7 to i8*
%10 = shl i32 %1, 2
%11 = tail call i32 @memset(float* %4, i32 0, i32 %10)
br label %12
12: ; preds = %5, %18
%13 = phi i64 [ 0, %5 ], [ %25, %18 ]
%14 = phi i32 [ 0, %5 ], [ %16, %18 ]
%15 = getelementptr inbounds i32, i32* %3, i64 %13
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 0
br i1 %17, label %27, label %18
18: ; preds = %12
%19 = add nsw i32 %16, -1
%20 = call i32 @noisemasker_band(float* %0, i32* %2, i32 %14, i32 %19, float* %6, i32* %7)
%21 = load float, float* %6
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds float, float* %4, i64 %23
store float %21, float* %24
%25 = add nuw nsw i64 %13, 1
%26 = icmp eq i64 %25, 25
br i1 %26, label %27, label %12
27: ; preds = %12, %18
ret i32 0
}