void II_smr(ltmin, spike, scale, sblimit) double spike[32], scale[32],
    ltmin[32];
int sblimit;
{
  int i;
  double max;
  for (i = 0; i < sblimit; i++) {
    max = 20 * log10(scale[i] * 32768) - 10;
    if (spike[i] > max)
      max = spike[i];
    max -= ltmin[i];
    ltmin[i] = max;
  }
}


x86 assembly (clang, -O0):
<II_smr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11d6 <II_smr+0xc6>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  0xec6(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
call   1030 <log10@plt>
movsd  0xea4(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xea0(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    119b <II_smr+0x8b>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x28(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112e <II_smr+0x1e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<II_smr>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %ecx,%ecx
jle    1174 <II_smr+0x64>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
mov    %ecx,%r12d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsd  (%r14,%rbx,8),%xmm0
mulsd  0xec2(%rip),%xmm0
call   1030 <log10@plt>
mulsd  0xebd(%rip),%xmm0
addsd  0xebd(%rip),%xmm0
movsd  (%r15,%rbx,8),%xmm1
maxsd  %xmm0,%xmm1
subsd  0x0(%r13,%rbx,8),%xmm1
movsd  %xmm1,0x0(%r13,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <II_smr+0x20>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @II_smr(double* %0, double* %1, double* %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %11
11: ; preds = %50, %4
%12 = load i32, i32* %9
%13 = load i32, i32* %8
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %53
15: ; preds = %11
%16 = load double*, double** %7
%17 = load i32, i32* %9
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %16, i64 %18
%20 = load double, double* %19
%21 = fmul double %20, 3.276800e+04
%22 = call double @log10(double %21)
%23 = call double @llvm.fmuladd.f64(double 2.000000e+01, double %22, double -1.000000e+01)
store double %23, double* %10
%24 = load double*, double** %6
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
%28 = load double, double* %27
%29 = load double, double* %10
%30 = fcmp ogt double %28, %29
br i1 %30, label %31, label %37
31: ; preds = %15
%32 = load double*, double** %6
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
%36 = load double, double* %35
store double %36, double* %10
br label %37
37: ; preds = %31, %15
%38 = load double*, double** %5
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
%42 = load double, double* %41
%43 = load double, double* %10
%44 = fsub double %43, %42
store double %44, double* %10
%45 = load double, double* %10
%46 = load double*, double** %5
%47 = load i32, i32* %9
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %46, i64 %48
store double %45, double* %49
br label %50
50: ; preds = %37
%51 = load i32, i32* %9
%52 = add nsw i32 %51, 1
store i32 %52, i32* %9
br label %11
53: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @II_smr(double* nocapture %0, double* nocapture %1, double* nocapture %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %24
6: ; preds = %4
%7 = zext i32 %3 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %22, %8 ]
%10 = getelementptr inbounds double, double* %2, i64 %9
%11 = load double, double* %10
%12 = fmul double %11, 3.276800e+04
%13 = tail call double @log10(double %12)
%14 = tail call double @llvm.fmuladd.f64(double %13, double 2.000000e+01, double -1.000000e+01)
%15 = getelementptr inbounds double, double* %1, i64 %9
%16 = load double, double* %15
%17 = fcmp ogt double %16, %14
%18 = select i1 %17, double %16, double %14
%19 = getelementptr inbounds double, double* %0, i64 %9
%20 = load double, double* %19
%21 = fsub double %18, %20
store double %21, double* %19
%22 = add nuw nsw i64 %9, 1
%23 = icmp eq i64 %22, %7
br i1 %23, label %24, label %8
24: ; preds = %8, %4
ret void
}