#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 exp10(double);
int log_rms(float *);
int predict_log_gain(float);
float predict_gain(float input[], float *lgp) {
  float new_gain, log_gain, tmp;
  *lgp = log_gain = log_rms(input) - 32;
  tmp = 32 + predict_log_gain(log_gain);
  if (tmp < 0.0)
    tmp = 0.0;
  if (tmp > 60.0)
    tmp = 60.0;
  new_gain = exp10(0.05 * tmp);
  ;
  return (new_gain);
}


x86 assembly (clang, -O0):
<predict_gain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <log_rms@plt>
sub    $0x20,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x18(%rbp),%xmm0
call   1030 <predict_log_gain@plt>
add    $0x20,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1191 <predict_gain+0x61>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe5e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11b9 <predict_gain+0x89>
movss  0xe5c(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe3e(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1050 <exp10@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<predict_gain>:
push   %rbx
mov    %rsi,%rbx
call   1040 <log_rms@plt>
add    $0xffffffe0,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,(%rbx)
call   1030 <predict_log_gain@plt>
xorps  %xmm0,%xmm0
cmp    $0xffffffe0,%eax
jl     115b <predict_gain+0x2b>
add    $0x20,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0xe9d(%rip),%xmm1
minss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mulsd  0xe92(%rip),%xmm0
pop    %rbx
jmp    1050 <exp10@plt>

LLVM IR (-O0):
define float @predict_gain(float* %0, float* %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca float
%6 = alloca float
%7 = alloca float
store float* %0, float** %3
store float* %1, float** %4
%8 = load float*, float** %3
%9 = call i32 @log_rms(float* %8)
%10 = sub nsw i32 %9, 32
%11 = sitofp i32 %10 to float
store float %11, float* %6
%12 = load float*, float** %4
store float %11, float* %12
%13 = load float, float* %6
%14 = call i32 @predict_log_gain(float %13)
%15 = add nsw i32 32, %14
%16 = sitofp i32 %15 to float
store float %16, float* %7
%17 = load float, float* %7
%18 = fpext float %17 to double
%19 = fcmp olt double %18, 0.000000e+00
br i1 %19, label %20, label %21
20: ; preds = %2
store float 0.000000e+00, float* %7
br label %21
21: ; preds = %20, %2
%22 = load float, float* %7
%23 = fpext float %22 to double
%24 = fcmp ogt double %23, 6.000000e+01
br i1 %24, label %25, label %26
25: ; preds = %21
store float 6.000000e+01, float* %7
br label %26
26: ; preds = %25, %21
%27 = load float, float* %7
%28 = fpext float %27 to double
%29 = fmul double 5.000000e-02, %28
%30 = call float @exp10(double %29)
store float %30, float* %5
%31 = load float, float* %5
ret float %31
}

LLVM IR (-O2):
define float @predict_gain(float* %0, float* nocapture writeonly %1) {
%3 = tail call i32 @log_rms(float* %0)
%4 = add nsw i32 %3, -32
%5 = sitofp i32 %4 to float
store float %5, float* %1
%6 = tail call i32 @predict_log_gain(float %5)
%7 = add nsw i32 %6, 32
%8 = sitofp i32 %7 to float
%9 = icmp slt i32 %6, -32
%10 = select i1 %9, float 0.000000e+00, float %8
%11 = fcmp ogt float %10, 6.000000e+01
%12 = select i1 %11, float 6.000000e+01, float %10
%13 = fpext float %12 to double
%14 = fmul double %13, 5.000000e-02
%15 = tail call float @exp10(double %14)
ret float %15
}