#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(double);
int /*<<< orphan*/ memset(double *, int /*<<< orphan*/, int);
int psd_bark2bin(double *, int, double);
int /*<<< orphan*/ spread_function(double, double *, int, int, int, double *);
int noise_mask_threshold(double *pnm, double *psd_bark, double *spread_effect,
                         double *noise_thres, int psd_len) {
  int k, j;
  double masker_bark;
  double low_bark, high_bark;
  int low_bin, high_bin;
  memset(noise_thres, 0, sizeof(double) * psd_len);
  for (k = 0; k < psd_len; k++) {
    memset(spread_effect, 0, sizeof(double) * psd_len);
    if (pnm[k] > 0) {
      masker_bark = psd_bark[k];
      low_bark = masker_bark - 3;
      high_bark = masker_bark + 8;
      low_bin = psd_bark2bin(psd_bark, psd_len, low_bark);
      high_bin = psd_bark2bin(psd_bark, psd_len, high_bark);
      spread_function(pnm[k], psd_bark, k, low_bin, high_bin, spread_effect);
      for (j = low_bin; j <= high_bin; j++)
        noise_thres[j] +=
            db_inv(pnm[k] - 0.175 * masker_bark + spread_effect[j] - 2.025);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<noise_mask_threshold>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12c7 <noise_mask_threshold+0x187>
mov    -0x18(%rbp),%rdi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12b4 <noise_mask_threshold+0x174>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xe36(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe1d(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
movsd  -0x40(%rbp),%xmm0
call   1040 <psd_bark2bin@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
movsd  -0x48(%rbp),%xmm0
call   1040 <psd_bark2bin@plt>
mov    %eax,-0x50(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x4c(%rbp),%edx
mov    -0x50(%rbp),%ecx
mov    -0x18(%rbp),%r8
call   1050 <spread_function@plt>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x50(%rbp),%eax
jg     12af <noise_mask_threshold+0x16f>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x38(%rbp),%xmm0
movsd  0xdb4(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  0xd8f(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1060 <db_inv@plt>
cvtsi2sd %rax,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    123e <noise_mask_threshold+0xfe>
jmp    12b4 <noise_mask_threshold+0x174>
jmp    12b9 <noise_mask_threshold+0x179>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1178 <noise_mask_threshold+0x38>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<noise_mask_threshold>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r8d,%ebx
mov    %rdx,0x8(%rsp)
mov    %rsi,0x28(%rsp)
mov    %rdi,%r15
lea    0x0(,%rbx,8),%edx
mov    %rcx,0x20(%rsp)
mov    %rcx,%rdi
xor    %esi,%esi
mov    %edx,0x14(%rsp)
call   1030 <memset@plt>
mov    %rbx,0x18(%rsp)
test   %ebx,%ebx
jle    12d2 <noise_mask_threshold+0x192>
mov    0x18(%rsp),%eax
mov    %rax,0x38(%rsp)
xor    %r14d,%r14d
jmp    11af <noise_mask_threshold+0x6f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r14
cmp    0x38(%rsp),%r14
je     12d2 <noise_mask_threshold+0x192>
mov    0x8(%rsp),%rdi
xor    %esi,%esi
mov    0x14(%rsp),%edx
call   1030 <memset@plt>
movsd  (%r15,%r14,8),%xmm0
ucomisd 0xe53(%rip),%xmm0
jbe    11a0 <noise_mask_threshold+0x60>
mov    0x28(%rsp),%rbx
movsd  (%rbx,%r14,8),%xmm1
movapd %xmm1,%xmm0
addsd  0xe1a(%rip),%xmm0
movsd  %xmm1,0x40(%rsp)
addsd  0xe14(%rip),%xmm1
movsd  %xmm1,0x30(%rsp)
mov    %rbx,%rdi
mov    0x18(%rsp),%rbp
mov    %ebp,%esi
call   1040 <psd_bark2bin@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
mov    %ebp,%esi
movsd  0x30(%rsp),%xmm0
call   1040 <psd_bark2bin@plt>
mov    %eax,%ebp
movsd  (%r15,%r14,8),%xmm0
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r12d,%edx
mov    %eax,%ecx
mov    0x8(%rsp),%r8
call   1050 <spread_function@plt>
movsd  0xdd7(%rip),%xmm2
movsd  0xdc7(%rip),%xmm1
cmp    %ebp,%r12d
jg     11a0 <noise_mask_threshold+0x60>
movslq %r12d,%rax
mov    0x8(%rsp),%rcx
mov    %r12d,%edx
lea    (%rcx,%rax,8),%r12
mov    0x20(%rsp),%rcx
lea    (%rcx,%rax,8),%r13
sub    %edx,%ebp
add    $0x1,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  0x40(%rsp),%xmm0
mulsd  %xmm1,%xmm0
addsd  (%r15,%r14,8),%xmm0
addsd  (%r12,%rbx,8),%xmm0
addsd  %xmm2,%xmm0
call   1060 <db_inv@plt>
movsd  0xd71(%rip),%xmm2
movsd  0xd61(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x0(%r13,%rbx,8),%xmm0
movsd  %xmm0,0x0(%r13,%rbx,8)
add    $0x1,%rbx
cmp    %ebx,%ebp
jne    1280 <noise_mask_threshold+0x140>
jmp    11a0 <noise_mask_threshold+0x60>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @noise_mask_threshold(double* %0, double* %1, double* %2, double* %3, i32 %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca i32
%17 = alloca i32
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
store i32 %4, i32* %10
%18 = load double*, double** %9
%19 = load i32, i32* %10
%20 = sext i32 %19 to i64
%21 = mul i64 8, %20
%22 = trunc i64 %21 to i32
%23 = call i32 @memset(double* %18, i32 0, i32 %22)
store i32 0, i32* %11
br label %24
24: ; preds = %103, %5
%25 = load i32, i32* %11
%26 = load i32, i32* %10
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %106
28: ; preds = %24
%29 = load double*, double** %8
%30 = load i32, i32* %10
%31 = sext i32 %30 to i64
%32 = mul i64 8, %31
%33 = trunc i64 %32 to i32
%34 = call i32 @memset(double* %29, i32 0, i32 %33)
%35 = load double*, double** %6
%36 = load i32, i32* %11
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
%39 = load double, double* %38
%40 = fcmp ogt double %39, 0.000000e+00
br i1 %40, label %41, label %102
41: ; preds = %28
%42 = load double*, double** %7
%43 = load i32, i32* %11
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %42, i64 %44
%46 = load double, double* %45
store double %46, double* %13
%47 = load double, double* %13
%48 = fsub double %47, 3.000000e+00
store double %48, double* %14
%49 = load double, double* %13
%50 = fadd double %49, 8.000000e+00
store double %50, double* %15
%51 = load double*, double** %7
%52 = load i32, i32* %10
%53 = load double, double* %14
%54 = call i32 @psd_bark2bin(double* %51, i32 %52, double %53)
store i32 %54, i32* %16
%55 = load double*, double** %7
%56 = load i32, i32* %10
%57 = load double, double* %15
%58 = call i32 @psd_bark2bin(double* %55, i32 %56, double %57)
store i32 %58, i32* %17
%59 = load double*, double** %6
%60 = load i32, i32* %11
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds double, double* %59, i64 %61
%63 = load double, double* %62
%64 = load double*, double** %7
%65 = load i32, i32* %11
%66 = load i32, i32* %16
%67 = load i32, i32* %17
%68 = load double*, double** %8
%69 = call i32 @spread_function(double %63, double* %64, i32 %65, i32 %66, i32 %67, double* %68)
%70 = load i32, i32* %16
store i32 %70, i32* %12
br label %71
71: ; preds = %98, %41
%72 = load i32, i32* %12
%73 = load i32, i32* %17
%74 = icmp sle i32 %72, %73
br i1 %74, label %75, label %101
75: ; preds = %71
%76 = load double*, double** %6
%77 = load i32, i32* %11
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds double, double* %76, i64 %78
%80 = load double, double* %79
%81 = load double, double* %13
%82 = call double @llvm.fmuladd.f64(double -1.750000e-01, double %81, double %80)
%83 = load double*, double** %8
%84 = load i32, i32* %12
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds double, double* %83, i64 %85
%87 = load double, double* %86
%88 = fadd double %82, %87
%89 = fsub double %88, 2.025000e+00
%90 = call i64 @db_inv(double %89)
%91 = sitofp i64 %90 to double
%92 = load double*, double** %9
%93 = load i32, i32* %12
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds double, double* %92, i64 %94
%96 = load double, double* %95
%97 = fadd double %96, %91
store double %97, double* %95
br label %98
98: ; preds = %75
%99 = load i32, i32* %12
%100 = add nsw i32 %99, 1
store i32 %100, i32* %12
br label %71
101: ; preds = %71
br label %102
102: ; preds = %101, %28
br label %103
103: ; preds = %102
%104 = load i32, i32* %11
%105 = add nsw i32 %104, 1
store i32 %105, i32* %11
br label %24
106: ; preds = %24
ret i32 0
}

LLVM IR (-O2):
define i32 @noise_mask_threshold(double* nocapture %0, double* %1, double* %2, double* %3, i32 %4) {
%6 = shl i32 %4, 3
%7 = tail call i32 @memset(double* %3, i32 0, i32 %6)
%8 = icmp sgt i32 %4, 0
br i1 %8, label %9, label %50
9: ; preds = %5
%10 = zext i32 %4 to i64
br label %11
11: ; preds = %9, %47
%12 = phi i64 [ 0, %9 ], [ %48, %47 ]
%13 = tail call i32 @memset(double* %2, i32 0, i32 %6)
%14 = getelementptr inbounds double, double* %0, i64 %12
%15 = load double, double* %14
%16 = fcmp ogt double %15, 0.000000e+00
br i1 %16, label %17, label %47
17: ; preds = %11
%18 = getelementptr inbounds double, double* %1, i64 %12
%19 = load double, double* %18
%20 = fadd double %19, -3.000000e+00
%21 = fadd double %19, 8.000000e+00
%22 = tail call i32 @psd_bark2bin(double* %1, i32 %4, double %20)
%23 = tail call i32 @psd_bark2bin(double* %1, i32 %4, double %21)
%24 = load double, double* %14
%25 = trunc i64 %12 to i32
%26 = tail call i32 @spread_function(double %24, double* %1, i32 %25, i32 %22, i32 %23, double* %2)
%27 = icmp sgt i32 %22, %23
br i1 %27, label %47, label %28
28: ; preds = %17
%29 = sext i32 %22 to i64
%30 = add i32 %23, 1
br label %31
31: ; preds = %28, %31
%32 = phi i64 [ %29, %28 ], [ %44, %31 ]
%33 = load double, double* %14
%34 = tail call double @llvm.fmuladd.f64(double %19, double -1.750000e-01, double %33)
%35 = getelementptr inbounds double, double* %2, i64 %32
%36 = load double, double* %35
%37 = fadd double %34, %36
%38 = fadd double %37, -2.025000e+00
%39 = tail call i64 @db_inv(double %38)
%40 = sitofp i64 %39 to double
%41 = getelementptr inbounds double, double* %3, i64 %32
%42 = load double, double* %41
%43 = fadd double %42, %40
store double %43, double* %41
%44 = add nsw i64 %32, 1
%45 = trunc i64 %44 to i32
%46 = icmp eq i32 %30, %45
br i1 %46, label %47, label %31
47: ; preds = %31, %17, %11
%48 = add nuw nsw i64 %12, 1
%49 = icmp eq i64 %48, %10
br i1 %49, label %50, label %11
50: ; preds = %47, %5
ret i32 0
}