#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(scalar_t__);
int global_threshold(float *tone_thres, float *noise_thres, float *psd_ath,
                     float *global_thres, int psd_len) {
  int k;
  for (k = 0; k < psd_len; k++)
    global_thres[k] =
        db_pos(tone_thres[k] + noise_thres[k] + db_inv(psd_ath[k]));
  return 0;
}


x86 assembly (clang, -O0):
<global_threshold>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11b3 <global_threshold+0x93>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
addss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
call   1040 <db_inv@plt>
movss  -0x2c(%rbp),%xmm0
cvtsi2ss %rax,%xmm1
addss  %xmm1,%xmm0
cvttss2si %xmm0,%rdi
call   1030 <db_pos@plt>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1143 <global_threshold+0x23>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<global_threshold>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %r8d,%r8d
jle    1195 <global_threshold+0x75>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
mov    %r8d,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  0x0(%r13,%rbp,4),%xmm0
addss  (%r12,%rbp,4),%xmm0
movss  %xmm0,0x4(%rsp)
movss  (%r15,%rbp,4),%xmm0
call   1040 <db_inv@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  0x4(%rsp),%xmm0
cvttss2si %xmm0,%rdi
call   1030 <db_pos@plt>
movss  %xmm0,(%r14,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1150 <global_threshold+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 @global_threshold(float* %0, float* %1, float* %2, float* %3, i32 %4) {
%6 = alloca float*
%7 = alloca float*
%8 = alloca float*
%9 = alloca float*
%10 = alloca i32
%11 = alloca i32
store float* %0, float** %6
store float* %1, float** %7
store float* %2, float** %8
store float* %3, float** %9
store i32 %4, i32* %10
store i32 0, i32* %11
br label %12
12: ; preds = %42, %5
%13 = load i32, i32* %11
%14 = load i32, i32* %10
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %45
16: ; preds = %12
%17 = load float*, float** %6
%18 = load i32, i32* %11
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds float, float* %17, i64 %19
%21 = load float, float* %20
%22 = load float*, float** %7
%23 = load i32, i32* %11
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds float, float* %22, i64 %24
%26 = load float, float* %25
%27 = fadd float %21, %26
%28 = load float*, float** %8
%29 = load i32, i32* %11
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds float, float* %28, i64 %30
%32 = load float, float* %31
%33 = call i64 @db_inv(float %32)
%34 = sitofp i64 %33 to float
%35 = fadd float %27, %34
%36 = fptosi float %35 to i64
%37 = call float @db_pos(i64 %36)
%38 = load float*, float** %9
%39 = load i32, i32* %11
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds float, float* %38, i64 %40
store float %37, float* %41
br label %42
42: ; preds = %16
%43 = load i32, i32* %11
%44 = add nsw i32 %43, 1
store i32 %44, i32* %11
br label %12
45: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
define i32 @global_threshold(float* nocapture %0, float* nocapture %1, float* nocapture %2, float* nocapture writeonly %3, i32 %4) {
%6 = icmp sgt i32 %4, 0
br i1 %6, label %7, label %26
7: ; preds = %5
%8 = zext i32 %4 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %24, %9 ]
%11 = getelementptr inbounds float, float* %0, i64 %10
%12 = load float, float* %11
%13 = getelementptr inbounds float, float* %1, i64 %10
%14 = load float, float* %13
%15 = fadd float %12, %14
%16 = getelementptr inbounds float, float* %2, i64 %10
%17 = load float, float* %16
%18 = tail call i64 @db_inv(float %17)
%19 = sitofp i64 %18 to float
%20 = fadd float %15, %19
%21 = fptosi float %20 to i64
%22 = tail call float @db_pos(i64 %21)
%23 = getelementptr inbounds float, float* %3, i64 %10
store float %22, float* %23
%24 = add nuw nsw i64 %10, 1
%25 = icmp eq i64 %24, %8
br i1 %25, label %26, label %9
26: ; preds = %9, %5
ret i32 0
}