#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(float);
void peak_to_spl(float *peak, float *pdb, size_t len) {
  int i;
  for (i = 0; i < len; i++) {
    pdb[i] = (100) + 20 * log10(peak[i] + 2.2204460492503131e-16);
  }
}


x86 assembly (clang, -O0):
<peak_to_spl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1184 <peak_to_spl+0x74>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xeae(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <log10@plt>
imul   $0x14,%eax,%eax
add    $0x64,%eax
cvtsi2ss %eax,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112b <peak_to_spl+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<peak_to_spl>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdx,%rdx
je     1163 <peak_to_spl+0x53>
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movss  (%r15,%rbx,4),%xmm0
addss  0xec2(%rip),%xmm0
call   1030 <log10@plt>
lea    (%rax,%rax,4),%eax
lea    0x64(,%rax,4),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <peak_to_spl+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @peak_to_spl(float* %0, float* %1, i64 %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca i64
%7 = alloca i32
store float* %0, float** %4
store float* %1, float** %5
store i64 %2, i64* %6
store i32 0, i32* %7
br label %8
8: ; preds = %30, %3
%9 = load i32, i32* %7
%10 = sext i32 %9 to i64
%11 = load i64, i64* %6
%12 = icmp ult i64 %10, %11
br i1 %12, label %13, label %33
13: ; preds = %8
%14 = load float*, float** %4
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds float, float* %14, i64 %16
%18 = load float, float* %17
%19 = fpext float %18 to double
%20 = fadd double %19, 0x3CB0000000000000
%21 = fptrunc double %20 to float
%22 = call i32 @log10(float %21)
%23 = mul nsw i32 20, %22
%24 = add nsw i32 100, %23
%25 = sitofp i32 %24 to float
%26 = load float*, float** %5
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds float, float* %26, i64 %28
store float %25, float* %29
br label %30
30: ; preds = %13
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %8
33: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @peak_to_spl(float* nocapture %0, float* nocapture writeonly %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %17, label %5
5: ; preds = %3, %5
%6 = phi i64 [ %15, %5 ], [ 0, %3 ]
%7 = getelementptr inbounds float, float* %0, i64 %6
%8 = load float, float* %7
%9 = fadd float %8, 0x3CB0000000000000
%10 = tail call i32 @log10(float %9)
%11 = mul nsw i32 %10, 20
%12 = add nsw i32 %11, 100
%13 = sitofp i32 %12 to float
%14 = getelementptr inbounds float, float* %1, i64 %6
store float %13, float* %14
%15 = add nuw i64 %6, 1
%16 = icmp eq i64 %15, %2
br i1 %16, label %17, label %5
17: ; preds = %5, %3
ret void
}