#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 */
float db_inv(float);
int global_threshold_mag(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] = (tone_thres[k] + noise_thres[k] + db_inv(psd_ath[k]));
  return 0;
}


x86 assembly (clang, -O0):
<global_threshold_mag>:
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    1197 <global_threshold_mag+0x87>
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   1030 <db_inv@plt>
movaps %xmm0,%xmm1
movss  -0x2c(%rbp),%xmm0
addss  %xmm1,%xmm0
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    1133 <global_threshold_mag+0x23>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<global_threshold_mag>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %r8d,%r8d
jle    1173 <global_threshold_mag+0x63>
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   1030 <db_inv@plt>
addss  0x4(%rsp),%xmm0
movss  %xmm0,(%r14,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1140 <global_threshold_mag+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_mag(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 = %39, %5
%13 = load i32, i32* %11
%14 = load i32, i32* %10
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %42
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 float @db_inv(float %32)
%34 = fadd float %27, %33
%35 = load float*, float** %9
%36 = load i32, i32* %11
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds float, float* %35, i64 %37
store float %34, float* %38
br label %39
39: ; preds = %16
%40 = load i32, i32* %11
%41 = add nsw i32 %40, 1
store i32 %41, i32* %11
br label %12
42: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
define i32 @global_threshold_mag(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 %23
7: ; preds = %5
%8 = zext i32 %4 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %21, %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 float @db_inv(float %17)
%19 = fadd float %15, %18
%20 = getelementptr inbounds float, float* %3, i64 %10
store float %19, float* %20
%21 = add nuw nsw i64 %10, 1
%22 = icmp eq i64 %21, %8
br i1 %22, label %23, label %9
23: ; preds = %9, %5
ret i32 0
}