void estimate_noise_loizou(float *thresh, int fft_size_2, float *p2,
                           float *s_pow_spec, float *prev_s_pow_spec,
                           float *noise_thresholds_p2, float *prev_noise,
                           float *p_min, float *prev_p_min, float *speech_p_p,
                           float *prev_speech_p_p) {
  int k;
  float ratio_ns = 0.f;
  float freq_s[fft_size_2 + 1];
  float speech_p_d[fft_size_2 + 1];
  for (k = 0; k <= fft_size_2; k++) {
    s_pow_spec[k] = 0.7f * prev_s_pow_spec[k] + (1.f - 0.7f) * p2[k];
    if (prev_p_min[k] < s_pow_spec[k]) {
      p_min[k] = 0.998f * prev_p_min[k] +
                 ((1.f - 0.998f) / (1.f - 0.8f)) *
                     (s_pow_spec[k] - 0.8f * prev_s_pow_spec[k]);
    } else {
      p_min[k] = s_pow_spec[k];
    }
    ratio_ns = s_pow_spec[k] / p_min[k];
    if (ratio_ns > thresh[k]) {
      speech_p_d[k] = 1.f;
    } else {
      speech_p_d[k] = 0.f;
    }
    speech_p_p[k] = 0.2f * prev_speech_p_p[k] + (1.f - 0.2f) * speech_p_d[k];
    freq_s[k] = 0.95f + (1.f - 0.95f) * speech_p_p[k];
    noise_thresholds_p2[k] =
        freq_s[k] * prev_noise[k] + (1.f - freq_s[k]) * p2[k];
  }
}


x86 assembly (clang, -O0):
<estimate_noise_loizou>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     13a3 <estimate_noise_loizou+0x2a3>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  0xe4d(%rip),%xmm1
mulss  (%rax,%rcx,4),%xmm1
movss  0xe3c(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
ucomiss %xmm1,%xmm0
jbe    1261 <estimate_noise_loizou+0x161>
mov    0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm2
movss  0xde5(%rip),%xmm3
mulss  %xmm3,%xmm2
addss  %xmm1,%xmm2
movss  0xdd1(%rip),%xmm1
mulss  %xmm2,%xmm1
movss  0xdc1(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
jmp    127b <estimate_noise_loizou+0x17b>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
divss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
ucomiss (%rax,%rcx,4),%xmm0
jbe    12cb <estimate_noise_loizou+0x1cb>
mov    -0x58(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  0xd53(%rip),%xmm0
movss  %xmm0,(%rax,%rcx,4)
jmp    12db <estimate_noise_loizou+0x1db>
mov    -0x58(%rbp),%rax
movslq -0x34(%rbp),%rcx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x60(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    0x30(%rbp),%rdx
movslq -0x34(%rbp),%rsi
movss  (%rdx,%rsi,4),%xmm0
movslq -0x34(%rbp),%rdx
movss  0xd28(%rip),%xmm1
mulss  (%rcx,%rdx,4),%xmm1
movss  0xd17(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    0x28(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movss  %xmm0,(%rcx,%rdx,4)
mov    0x28(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movss  (%rcx,%rdx,4),%xmm0
movss  0xce5(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xcdd(%rip),%xmm1
addss  %xmm1,%xmm0
movslq -0x34(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
movslq -0x34(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    0x10(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movss  (%rcx,%rdx,4),%xmm2
movslq -0x34(%rbp),%rcx
movss  0xca6(%rip),%xmm1
subss  (%rax,%rcx,4),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
mulss  (%rax,%rcx,4),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    118e <estimate_noise_loizou+0x8e>
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<estimate_noise_loizou>:
push   %r15
push   %r14
push   %rbx
test   %esi,%esi
js     123e <estimate_noise_loizou+0x13e>
mov    0x40(%rsp),%r10
mov    0x38(%rsp),%r11
mov    0x30(%rsp),%r14
mov    0x28(%rsp),%r15
mov    0x20(%rsp),%rax
add    $0x1,%esi
shl    $0x2,%rsi
xor    %ebx,%ebx
movss  0xec8(%rip),%xmm11
movss  0xec3(%rip),%xmm12
movss  0xebe(%rip),%xmm8
movss  0xeb9(%rip),%xmm9
movss  0xeb4(%rip),%xmm10
movss  0xeb0(%rip),%xmm5
movss  0xeac(%rip),%xmm6
movss  0xea8(%rip),%xmm7
movss  0xea4(%rip),%xmm2
movss  0xea0(%rip),%xmm3
jmp    11ec <estimate_noise_loizou+0xec>
cs nopw 0x0(%rax,%rax,1)
movss  %xmm4,(%r15,%rbx,1)
movss  (%rcx,%rbx,1),%xmm0
divss  %xmm4,%xmm0
movss  (%rdi,%rbx,1),%xmm1
cmpltss %xmm0,%xmm1
andps  %xmm5,%xmm1
movss  (%r10,%rbx,1),%xmm0
mulss  %xmm6,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,(%r11,%rbx,1)
mulss  %xmm7,%xmm0
addss  %xmm2,%xmm0
movaps %xmm3,%xmm1
subss  %xmm0,%xmm1
mulss  (%rdx,%rbx,1),%xmm1
mulss  (%rax,%rbx,1),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,(%r9,%rbx,1)
add    $0x4,%rbx
cmp    %rbx,%rsi
je     123e <estimate_noise_loizou+0x13e>
movss  (%rdx,%rbx,1),%xmm0
mulss  %xmm11,%xmm0
movss  (%r8,%rbx,1),%xmm4
mulss  %xmm12,%xmm4
addss  %xmm0,%xmm4
movss  %xmm4,(%rcx,%rbx,1)
movss  (%r14,%rbx,1),%xmm0
ucomiss %xmm0,%xmm4
jbe    1190 <estimate_noise_loizou+0x90>
movss  (%r8,%rbx,1),%xmm1
mulss  %xmm8,%xmm1
addss  %xmm4,%xmm1
mulss  %xmm9,%xmm1
mulss  %xmm10,%xmm0
addss  %xmm1,%xmm0
movaps %xmm0,%xmm4
jmp    1190 <estimate_noise_loizou+0x90>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @estimate_noise_loizou(float* %0, i32 %1, float* %2, float* %3, float* %4, float* %5, float* %6, float* %7, float* %8, float* %9, float* %10) {
%12 = alloca float*
%13 = alloca i32
%14 = alloca float*
%15 = alloca float*
%16 = alloca float*
%17 = alloca float*
%18 = alloca float*
%19 = alloca float*
%20 = alloca float*
%21 = alloca float*
%22 = alloca float*
%23 = alloca i32
%24 = alloca float
%25 = alloca i8*
%26 = alloca i64
%27 = alloca i64
store float* %0, float** %12
store i32 %1, i32* %13
store float* %2, float** %14
store float* %3, float** %15
store float* %4, float** %16
store float* %5, float** %17
store float* %6, float** %18
store float* %7, float** %19
store float* %8, float** %20
store float* %9, float** %21
store float* %10, float** %22
store float 0.000000e+00, float* %24
%28 = load i32, i32* %13
%29 = add nsw i32 %28, 1
%30 = zext i32 %29 to i64
%31 = call i8* @llvm.stacksave()
store i8* %31, i8** %25
%32 = alloca float, i64 %30
store i64 %30, i64* %26
%33 = load i32, i32* %13
%34 = add nsw i32 %33, 1
%35 = zext i32 %34 to i64
%36 = alloca float, i64 %35
store i64 %35, i64* %27
store i32 0, i32* %23
br label %37
37: ; preds = %179, %11
%38 = load i32, i32* %23
%39 = load i32, i32* %13
%40 = icmp sle i32 %38, %39
br i1 %40, label %41, label %182
41: ; preds = %37
%42 = load float*, float** %16
%43 = load i32, i32* %23
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds float, float* %42, i64 %44
%46 = load float, float* %45
%47 = load float*, float** %14
%48 = load i32, i32* %23
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds float, float* %47, i64 %49
%51 = load float, float* %50
%52 = fmul float 0x3FD3333340000000, %51
%53 = call float @llvm.fmuladd.f32(float 0x3FE6666660000000, float %46, float %52)
%54 = load float*, float** %15
%55 = load i32, i32* %23
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds float, float* %54, i64 %56
store float %53, float* %57
%58 = load float*, float** %20
%59 = load i32, i32* %23
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds float, float* %58, i64 %60
%62 = load float, float* %61
%63 = load float*, float** %15
%64 = load i32, i32* %23
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds float, float* %63, i64 %65
%67 = load float, float* %66
%68 = fcmp olt float %62, %67
br i1 %68, label %69, label %92
69: ; preds = %41
%70 = load float*, float** %20
%71 = load i32, i32* %23
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds float, float* %70, i64 %72
%74 = load float, float* %73
%75 = load float*, float** %15
%76 = load i32, i32* %23
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds float, float* %75, i64 %77
%79 = load float, float* %78
%80 = load float*, float** %16
%81 = load i32, i32* %23
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds float, float* %80, i64 %82
%84 = load float, float* %83
%85 = call float @llvm.fmuladd.f32(float 0xBFE99999A0000000, float %84, float %79)
%86 = fmul float 0x3F847AD020000000, %85
%87 = call float @llvm.fmuladd.f32(float 0x3FEFEF9DC0000000, float %74, float %86)
%88 = load float*, float** %19
%89 = load i32, i32* %23
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds float, float* %88, i64 %90
store float %87, float* %91
br label %102
92: ; preds = %41
%93 = load float*, float** %15
%94 = load i32, i32* %23
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds float, float* %93, i64 %95
%97 = load float, float* %96
%98 = load float*, float** %19
%99 = load i32, i32* %23
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds float, float* %98, i64 %100
store float %97, float* %101
br label %102
102: ; preds = %92, %69
%103 = load float*, float** %15
%104 = load i32, i32* %23
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds float, float* %103, i64 %105
%107 = load float, float* %106
%108 = load float*, float** %19
%109 = load i32, i32* %23
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds float, float* %108, i64 %110
%112 = load float, float* %111
%113 = fdiv float %107, %112
store float %113, float* %24
%114 = load float, float* %24
%115 = load float*, float** %12
%116 = load i32, i32* %23
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds float, float* %115, i64 %117
%119 = load float, float* %118
%120 = fcmp ogt float %114, %119
br i1 %120, label %121, label %125
121: ; preds = %102
%122 = load i32, i32* %23
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds float, float* %36, i64 %123
store float 1.000000e+00, float* %124
br label %129
125: ; preds = %102
%126 = load i32, i32* %23
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds float, float* %36, i64 %127
store float 0.000000e+00, float* %128
br label %129
129: ; preds = %125, %121
%130 = load float*, float** %22
%131 = load i32, i32* %23
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds float, float* %130, i64 %132
%134 = load float, float* %133
%135 = load i32, i32* %23
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds float, float* %36, i64 %136
%138 = load float, float* %137
%139 = fmul float 0x3FE99999A0000000, %138
%140 = call float @llvm.fmuladd.f32(float 0x3FC99999A0000000, float %134, float %139)
%141 = load float*, float** %21
%142 = load i32, i32* %23
%143 = sext i32 %142 to i64
%144 = getelementptr inbounds float, float* %141, i64 %143
store float %140, float* %144
%145 = load float*, float** %21
%146 = load i32, i32* %23
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds float, float* %145, i64 %147
%149 = load float, float* %148
%150 = call float @llvm.fmuladd.f32(float 0x3FA9999A00000000, float %149, float 0x3FEE666660000000)
%151 = load i32, i32* %23
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds float, float* %32, i64 %152
store float %150, float* %153
%154 = load i32, i32* %23
%155 = sext i32 %154 to i64
%156 = getelementptr inbounds float, float* %32, i64 %155
%157 = load float, float* %156
%158 = load float*, float** %18
%159 = load i32, i32* %23
%160 = sext i32 %159 to i64
%161 = getelementptr inbounds float, float* %158, i64 %160
%162 = load float, float* %161
%163 = load i32, i32* %23
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds float, float* %32, i64 %164
%166 = load float, float* %165
%167 = fsub float 1.000000e+00, %166
%168 = load float*, float** %14
%169 = load i32, i32* %23
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds float, float* %168, i64 %170
%172 = load float, float* %171
%173 = fmul float %167, %172
%174 = call float @llvm.fmuladd.f32(float %157, float %162, float %173)
%175 = load float*, float** %17
%176 = load i32, i32* %23
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds float, float* %175, i64 %177
store float %174, float* %178
br label %179
179: ; preds = %129
%180 = load i32, i32* %23
%181 = add nsw i32 %180, 1
store i32 %181, i32* %23
br label %37
182: ; preds = %37
%183 = load i8*, i8** %25
ret void
}

LLVM IR (-O2):
define void @estimate_noise_loizou(float* nocapture %0, i32 %1, float* nocapture %2, float* nocapture %3, float* nocapture %4, float* nocapture writeonly %5, float* nocapture %6, float* nocapture %7, float* nocapture %8, float* nocapture writeonly %9, float* nocapture %10) {
%12 = add i32 %1, 1
%13 = zext i32 %12 to i64
%14 = icmp slt i32 %1, 0
br i1 %14, label %55, label %15
15: ; preds = %11, %32
%16 = phi i64 [ %53, %32 ], [ 0, %11 ]
%17 = getelementptr inbounds float, float* %4, i64 %16
%18 = load float, float* %17
%19 = getelementptr inbounds float, float* %2, i64 %16
%20 = load float, float* %19
%21 = fmul float %20, 0x3FD3333340000000
%22 = tail call float @llvm.fmuladd.f32(float %18, float 0x3FE6666660000000, float %21)
%23 = getelementptr inbounds float, float* %3, i64 %16
store float %22, float* %23
%24 = getelementptr inbounds float, float* %8, i64 %16
%25 = load float, float* %24
%26 = fcmp olt float %25, %22
br i1 %26, label %27, label %32
27: ; preds = %15
%28 = load float, float* %17
%29 = tail call float @llvm.fmuladd.f32(float %28, float 0xBFE99999A0000000, float %22)
%30 = fmul float %29, 0x3F847AD020000000
%31 = tail call float @llvm.fmuladd.f32(float %25, float 0x3FEFEF9DC0000000, float %30)
br label %32
32: ; preds = %15, %27
%33 = phi float [ %31, %27 ], [ %22, %15 ]
%34 = getelementptr inbounds float, float* %7, i64 %16
store float %33, float* %34
%35 = load float, float* %23
%36 = fdiv float %35, %33
%37 = getelementptr inbounds float, float* %0, i64 %16
%38 = load float, float* %37
%39 = fcmp ogt float %36, %38
%40 = select i1 %39, float 0x3FE99999A0000000, float 0.000000e+00
%41 = getelementptr inbounds float, float* %10, i64 %16
%42 = load float, float* %41
%43 = tail call float @llvm.fmuladd.f32(float %42, float 0x3FC99999A0000000, float %40)
%44 = getelementptr inbounds float, float* %9, i64 %16
store float %43, float* %44
%45 = tail call float @llvm.fmuladd.f32(float %43, float 0x3FA9999A00000000, float 0x3FEE666660000000)
%46 = getelementptr inbounds float, float* %6, i64 %16
%47 = load float, float* %46
%48 = fsub float 1.000000e+00, %45
%49 = load float, float* %19
%50 = fmul float %49, %48
%51 = tail call float @llvm.fmuladd.f32(float %45, float %47, float %50)
%52 = getelementptr inbounds float, float* %5, i64 %16
store float %51, float* %52
%53 = add nuw nsw i64 %16, 1
%54 = icmp eq i64 %53, %13
br i1 %54, label %55, label %15
55: ; preds = %32, %11
ret void
}