#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 log10(double);
void psycho_3_spl(double *Lsb, float *power, double *scale) {
  int i;
  float Xmax[32];
  for (i = 0; i < 32; i++) {
    Xmax[i] = -200.0;
  }
  for (i = 1; i < 513; i++) {
    int index = i >> 4;
    if (Xmax[index] < power[i])
      Xmax[index] = power[i];
  }
  for (i = 0; i < 32; i++) {
    double val = 20 * log10(scale[i] * 32768) - 10;
    Lsb[i] = ((Xmax[i]) > (val) ? (Xmax[i]) : (val));
  }
}


x86 assembly (clang, -O0):
<psycho_3_spl>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x20,-0x1c(%rbp)
jge    115b <psycho_3_spl+0x4b>
movslq -0x1c(%rbp),%rax
movss  0xec4(%rip),%xmm0
movss  %xmm0,-0xa0(%rbp,%rax,4)
ff ff
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112e <psycho_3_spl+0x1e>
movl   $0x1,-0x1c(%rbp)
cmpl   $0x201,-0x1c(%rbp)
jge    11d1 <psycho_3_spl+0xc1>
mov    -0x1c(%rbp),%eax
sar    $0x4,%eax
mov    %eax,-0xa4(%rbp)
movslq -0xa4(%rbp),%rax
movss  -0xa0(%rbp,%rax,4),%xmm1
ff ff
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
ucomiss %xmm1,%xmm0
jbe    11be <psycho_3_spl+0xae>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movslq -0xa4(%rbp),%rax
movss  %xmm0,-0xa0(%rbp,%rax,4)
ff ff
jmp    11c3 <psycho_3_spl+0xb3>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1162 <psycho_3_spl+0x52>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x20,-0x1c(%rbp)
jge    127e <psycho_3_spl+0x16e>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  0xe0e(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
call   1030 <log10@plt>
imul   $0x14,%eax,%eax
sub    $0xa,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movslq -0x1c(%rbp),%rax
movss  -0xa0(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
ucomisd -0xb0(%rbp),%xmm0
ff
jbe    124b <psycho_3_spl+0x13b>
movslq -0x1c(%rbp),%rax
movss  -0xa0(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
jmp    125b <psycho_3_spl+0x14b>
movsd  -0xb0(%rbp),%xmm0
ff
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0xb8(%rbp),%xmm0
ff
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d8 <psycho_3_spl+0xc8>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<psycho_3_spl>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rdx,%r14
mov    %rdi,%r15
movaps 0xed7(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x70(%rsp)
mov    $0x2,%eax
jmp    116c <psycho_3_spl+0x5c>
nopw   0x0(%rax,%rax,1)
add    $0x2,%rax
cmp    $0x202,%rax
je     119a <psycho_3_spl+0x8a>
lea    -0x1(%rax),%ecx
shr    $0x4,%ecx
movss  -0x4(%rsi,%rax,4),%xmm0
ucomiss (%rsp,%rcx,4),%xmm0
jbe    1183 <psycho_3_spl+0x73>
movss  %xmm0,(%rsp,%rcx,4)
mov    %eax,%ecx
shr    $0x4,%ecx
movss  (%rsi,%rax,4),%xmm0
ucomiss (%rsp,%rcx,4),%xmm0
jbe    1160 <psycho_3_spl+0x50>
movss  %xmm0,(%rsp,%rcx,4)
jmp    1160 <psycho_3_spl+0x50>
xor    %ebx,%ebx
nopl   0x0(%rax)
movsd  (%r14,%rbx,8),%xmm0
mulsd  0xe62(%rip),%xmm0
call   1030 <log10@plt>
lea    (%rax,%rax,4),%eax
lea    -0xa(,%rax,4),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movss  (%rsp,%rbx,4),%xmm1
cvtss2sd %xmm1,%xmm1
maxsd  %xmm0,%xmm1
movsd  %xmm1,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    $0x20,%rbx
jne    11a0 <psycho_3_spl+0x90>
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @psycho_3_spl(double* %0, float* %1, double* %2) {
%4 = alloca double*
%5 = alloca float*
%6 = alloca double*
%7 = alloca i32
%8 = alloca [32 x float]
%9 = alloca i32
%10 = alloca double
store double* %0, double** %4
store float* %1, float** %5
store double* %2, double** %6
store i32 0, i32* %7
br label %11
11: ; preds = %18, %3
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 32
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [32 x float], [32 x float]* %8, i64 0, i64 %16
store float -2.000000e+02, float* %17
br label %18
18: ; preds = %14
%19 = load i32, i32* %7
%20 = add nsw i32 %19, 1
store i32 %20, i32* %7
br label %11
21: ; preds = %11
store i32 1, i32* %7
br label %22
22: ; preds = %48, %21
%23 = load i32, i32* %7
%24 = icmp slt i32 %23, 513
br i1 %24, label %25, label %51
25: ; preds = %22
%26 = load i32, i32* %7
%27 = ashr i32 %26, 4
store i32 %27, i32* %9
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [32 x float], [32 x float]* %8, i64 0, i64 %29
%31 = load float, float* %30
%32 = load float*, float** %5
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds float, float* %32, i64 %34
%36 = load float, float* %35
%37 = fcmp olt float %31, %36
br i1 %37, label %38, label %47
38: ; preds = %25
%39 = load float*, float** %5
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds float, float* %39, i64 %41
%43 = load float, float* %42
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [32 x float], [32 x float]* %8, i64 0, i64 %45
store float %43, float* %46
br label %47
47: ; preds = %38, %25
br label %48
48: ; preds = %47
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %22
51: ; preds = %22
store i32 0, i32* %7
br label %52
52: ; preds = %87, %51
%53 = load i32, i32* %7
%54 = icmp slt i32 %53, 32
br i1 %54, label %55, label %90
55: ; preds = %52
%56 = load double*, double** %6
%57 = load i32, i32* %7
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %56, i64 %58
%60 = load double, double* %59
%61 = fmul double %60, 3.276800e+04
%62 = call i32 @log10(double %61)
%63 = mul nsw i32 20, %62
%64 = sub nsw i32 %63, 10
%65 = sitofp i32 %64 to double
store double %65, double* %10
%66 = load i32, i32* %7
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [32 x float], [32 x float]* %8, i64 0, i64 %67
%69 = load float, float* %68
%70 = fpext float %69 to double
%71 = load double, double* %10
%72 = fcmp ogt double %70, %71
br i1 %72, label %73, label %79
73: ; preds = %55
%74 = load i32, i32* %7
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [32 x float], [32 x float]* %8, i64 0, i64 %75
%77 = load float, float* %76
%78 = fpext float %77 to double
br label %81
79: ; preds = %55
%80 = load double, double* %10
br label %81
81: ; preds = %79, %73
%82 = phi double [ %78, %73 ], [ %80, %79 ]
%83 = load double*, double** %4
%84 = load i32, i32* %7
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds double, double* %83, i64 %85
store double %82, double* %86
br label %87
87: ; preds = %81
%88 = load i32, i32* %7
%89 = add nsw i32 %88, 1
store i32 %89, i32* %7
br label %52
90: ; preds = %52
ret void
}

LLVM IR (-O2):
define void @psycho_3_spl(double* nocapture writeonly %0, float* nocapture %1, double* nocapture %2) {
%4 = alloca [32 x float]
%5 = bitcast [32 x float]* %4 to i8*
%6 = bitcast [32 x float]* %4 to <4 x float>*
store <4 x float> <float -2.000000e+02, float -2.000000e+02, float -2.000000e+02, float -2.000000e+02>, <4 x float>* %6
%7 = getelementptr inbounds [32 x float], [32 x float]* %4, i64 0, i64 4
%8 = bitcast float* %7 to <4 x float>*
store <4 x float> <float -2.000000e+02, float -2.000000e+02, float -2.000000e+02, float -2.000000e+02>, <4 x float>* %8
%9 = getelementptr inbounds [32 x float], [32 x float]* %4, i64 0, i64 8
%10 = bitcast float* %9 to <4 x float>*
store <4 x float> <float -2.000000e+02, float -2.000000e+02, float -2.000000e+02, float -2.000000e+02>, <4 x float>* %10
%11 = getelementptr inbounds [32 x float], [32 x float]* %4, i64 0, i64 12
%12 = bitcast float* %11 to <4 x float>*
store <4 x float> <float -2.000000e+02, float -2.000000e+02, float -2.000000e+02, float -2.000000e+02>, <4 x float>* %12
%13 = getelementptr inbounds [32 x float], [32 x float]* %4, i64 0, i64 16
%14 = bitcast float* %13 to <4 x float>*
store <4 x float> <float -2.000000e+02, float -2.000000e+02, float -2.000000e+02, float -2.000000e+02>, <4 x float>* %14
%15 = getelementptr inbounds [32 x float], [32 x float]* %4, i64 0, i64 20
%16 = bitcast float* %15 to <4 x float>*
store <4 x float> <float -2.000000e+02, float -2.000000e+02, float -2.000000e+02, float -2.000000e+02>, <4 x float>* %16
%17 = getelementptr inbounds [32 x float], [32 x float]* %4, i64 0, i64 24
%18 = bitcast float* %17 to <4 x float>*
store <4 x float> <float -2.000000e+02, float -2.000000e+02, float -2.000000e+02, float -2.000000e+02>, <4 x float>* %18
%19 = getelementptr inbounds [32 x float], [32 x float]* %4, i64 0, i64 28
%20 = bitcast float* %19 to <4 x float>*
store <4 x float> <float -2.000000e+02, float -2.000000e+02, float -2.000000e+02, float -2.000000e+02>, <4 x float>* %20
br label %21
21: ; preds = %41, %3
%22 = phi i64 [ 1, %3 ], [ %42, %41 ]
%23 = lshr i64 %22, 4
%24 = and i64 %23, 268435455
%25 = getelementptr inbounds [32 x float], [32 x float]* %4, i64 0, i64 %24
%26 = load float, float* %25
%27 = getelementptr inbounds float, float* %1, i64 %22
%28 = load float, float* %27
%29 = fcmp olt float %26, %28
br i1 %29, label %30, label %31
30: ; preds = %21
store float %28, float* %25
br label %31
31: ; preds = %30, %21
%32 = add nuw nsw i64 %22, 1
%33 = lshr i64 %32, 4
%34 = and i64 %33, 268435455
%35 = getelementptr inbounds [32 x float], [32 x float]* %4, i64 0, i64 %34
%36 = load float, float* %35
%37 = getelementptr inbounds float, float* %1, i64 %32
%38 = load float, float* %37
%39 = fcmp olt float %36, %38
br i1 %39, label %40, label %41
40: ; preds = %31
store float %38, float* %35
br label %41
41: ; preds = %40, %31
%42 = add nuw nsw i64 %22, 2
%43 = icmp eq i64 %42, 513
br i1 %43, label %44, label %21
44: ; preds = %41, %44
%45 = phi i64 [ %59, %44 ], [ 0, %41 ]
%46 = getelementptr inbounds double, double* %2, i64 %45
%47 = load double, double* %46
%48 = fmul double %47, 3.276800e+04
%49 = tail call i32 @log10(double %48)
%50 = mul nsw i32 %49, 20
%51 = add nsw i32 %50, -10
%52 = sitofp i32 %51 to double
%53 = getelementptr inbounds [32 x float], [32 x float]* %4, i64 0, i64 %45
%54 = load float, float* %53
%55 = fpext float %54 to double
%56 = fcmp ogt double %55, %52
%57 = select i1 %56, double %55, double %52
%58 = getelementptr inbounds double, double* %0, i64 %45
store double %57, double* %58
%59 = add nuw nsw i64 %45, 1
%60 = icmp eq i64 %59, 32
br i1 %60, label %61, label %44
61: ; preds = %44
ret void
}