#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, double *power, double *scale) {
  int i;
  double Xmax[32 + 1];
  for (i = 0; i < 32; i++) {
    Xmax[i] = -200.0;
  }
  for (i = 1; i < 513; i++) {
    int index = (i - 1) >> 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    $0x150,%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
movsd  0xec4(%rip),%xmm0
movsd  %xmm0,-0x130(%rbp,%rax,8)
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    11d5 <psycho_3_spl+0xc5>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
sar    $0x4,%eax
mov    %eax,-0x134(%rbp)
movslq -0x134(%rbp),%rax
movsd  -0x130(%rbp,%rax,8),%xmm1
ff ff
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    11c2 <psycho_3_spl+0xb2>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x134(%rbp),%rax
movsd  %xmm0,-0x130(%rbp,%rax,8)
ff ff
jmp    11c7 <psycho_3_spl+0xb7>
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    127a <psycho_3_spl+0x16a>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  0xe0a(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
call   1030 <log10@plt>
imul   $0x14,%eax,%eax
sub    $0xa,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x140(%rbp)
ff
movslq -0x1c(%rbp),%rax
movsd  -0x130(%rbp,%rax,8),%xmm0
ff ff
ucomisd -0x140(%rbp),%xmm0
ff
jbe    1247 <psycho_3_spl+0x137>
movslq -0x1c(%rbp),%rax
movsd  -0x130(%rbp,%rax,8),%xmm0
ff ff
movsd  %xmm0,-0x148(%rbp)
ff
jmp    1257 <psycho_3_spl+0x147>
movsd  -0x140(%rbp),%xmm0
ff
movsd  %xmm0,-0x148(%rbp)
ff
movsd  -0x148(%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    11dc <psycho_3_spl+0xcc>
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<psycho_3_spl>:
push   %r15
push   %r14
push   %rbx
sub    $0x110,%rsp
mov    %rdx,%r14
mov    %rdi,%r15
movapd 0xed6(%rip),%xmm0
movapd %xmm0,(%rsp)
movapd %xmm0,0x10(%rsp)
movapd %xmm0,0x20(%rsp)
movapd %xmm0,0x30(%rsp)
movapd %xmm0,0x40(%rsp)
movapd %xmm0,0x50(%rsp)
movapd %xmm0,0x60(%rsp)
movapd %xmm0,0x70(%rsp)
movapd %xmm0,0x80(%rsp)
movapd %xmm0,0x90(%rsp)
movapd %xmm0,0xa0(%rsp)
movapd %xmm0,0xb0(%rsp)
movapd %xmm0,0xc0(%rsp)
movapd %xmm0,0xd0(%rsp)
movapd %xmm0,0xe0(%rsp)
movapd %xmm0,0xf0(%rsp)
xor    %eax,%eax
jmp    11bc <psycho_3_spl+0xac>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x2,%rax
cmp    $0x200,%rax
je     11f3 <psycho_3_spl+0xe3>
mov    %eax,%ecx
sar    $0x4,%ecx
movslq %ecx,%rcx
movsd  0x8(%rsi,%rax,8),%xmm0
ucomisd (%rsp,%rcx,8),%xmm0
jbe    11d6 <psycho_3_spl+0xc6>
movsd  %xmm0,(%rsp,%rcx,8)
lea    0x1(%rax),%ecx
sar    $0x4,%ecx
movslq %ecx,%rcx
movsd  0x10(%rsi,%rax,8),%xmm0
ucomisd (%rsp,%rcx,8),%xmm0
jbe    11b0 <psycho_3_spl+0xa0>
movsd  %xmm0,(%rsp,%rcx,8)
jmp    11b0 <psycho_3_spl+0xa0>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%r14,%rbx,8),%xmm0
mulsd  0xe02(%rip),%xmm0
call   1030 <log10@plt>
lea    (%rax,%rax,4),%eax
lea    -0xa(,%rax,4),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  (%rsp,%rbx,8),%xmm1
maxsd  %xmm0,%xmm1
movsd  %xmm1,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    $0x20,%rbx
jne    1200 <psycho_3_spl+0xf0>
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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