#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 */
typedef int complex;

/* Variables and functions */
int M_PI;
int _Complex_I;
double cabs(int);
double *double_alloc(int);
int /*<<< orphan*/ free(double *);
double sqrt(double);
double rmsestimates(double gain_factor, double fc, double h, int nf, double *f,
                    double *y) {
  int i;
  double s2, *yc, w, wc;
  complex num, den;
  wc = 2. * M_PI * fc;
  yc = double_alloc(nf);
  s2 = 0.;
  for (i = 0; i < nf; i++) {
    w = 2. * M_PI * f[i];
    num = -w * w;
    den = num + 2. * h * wc * w * _Complex_I + wc * wc;
    yc[i] = gain_factor * cabs(num / den);
    s2 = s2 + (y[i] / yc[i] - 1.) * (y[i] / yc[i] - 1.);
  }
  s2 = sqrt(s2 / (double)(nf - 1));
  free(yc);
  return s2;
}


x86 assembly (clang, -O0):
<rmsestimates>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
mov    0x2e7f(%rip),%rax
cvtsi2sdl (%rax),%xmm1
movsd  0xe8b(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <double_alloc@plt>
mov    %rax,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12e0 <rmsestimates+0x1a0>
mov    0x2e37(%rip),%rax
cvtsi2sdl (%rax),%xmm1
movsd  0xe43(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x50(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x5c(%rbp)
cvtsi2sdl -0x5c(%rbp),%xmm0
movsd  0xdf8(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
mov    0x2dba(%rip),%rax
cvtsi2sdl (%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x60(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x5c(%rbp),%eax
cltd
idivl  -0x60(%rbp)
mov    %eax,%edi
call   1040 <cabs@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x40(%rbp),%xmm1
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
movsd  0xd6d(%rip),%xmm2
subsd  %xmm2,%xmm0
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm2
movsd  0xd47(%rip),%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    119e <rmsestimates+0x5e>
movsd  -0x40(%rbp),%xmm0
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
movsd  -0x40(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rmsestimates>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %edi,%ebp
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x20(%rsp)
mov    0x2e7a(%rip),%rax
xorps  %xmm0,%xmm0
cvtsi2sdl (%rax),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1050 <double_alloc@plt>
mov    %rax,%r15
xorpd  %xmm2,%xmm2
mov    %ebp,0xc(%rsp)
test   %ebp,%ebp
jle    127d <rmsestimates+0x13d>
movsd  0x10(%rsp),%xmm1
addsd  %xmm1,%xmm1
mulsd  (%rsp),%xmm1
movsd  0x18(%rsp),%xmm0
addsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x18(%rsp)
mov    0xc(%rsp),%ebp
xorpd  %xmm2,%xmm2
xor    %r14d,%r14d
mov    0x2e10(%rip),%r12
mulsd  %xmm1,%xmm1
movsd  %xmm1,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm2,(%rsp)
mov    0x2dfc(%rip),%rax
xorps  %xmm0,%xmm0
cvtsi2sdl (%rax),%xmm0
addsd  %xmm0,%xmm0
mulsd  (%rbx,%r14,8),%xmm0
movapd %xmm0,%xmm1
xorpd  0xdf7(%rip),%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%eax
cvttpd2dq %xmm1,%xmm1
cvtdq2pd %xmm1,%xmm1
xorps  %xmm2,%xmm2
cvtsi2sdl (%r12),%xmm2
mulsd  0x18(%rsp),%xmm0
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
addsd  0x10(%rsp),%xmm2
cvttsd2si %xmm2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <cabs@plt>
movsd  (%rsp),%xmm2
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%r15,%r14,8)
movsd  0x0(%r13,%r14,8),%xmm1
divsd  %xmm0,%xmm1
addsd  0xda8(%rip),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm1,%xmm2
add    $0x1,%r14
cmp    %r14,%rbp
jne    11e0 <rmsestimates+0xa0>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  %xmm0,%xmm2
ucomisd 0xd81(%rip),%xmm2
jb     12a2 <rmsestimates+0x162>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    12ab <rmsestimates+0x16b>
movapd %xmm2,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,(%rsp)
mov    %r15,%rdi
call   1030 <free@plt>
movsd  (%rsp),%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global i32 0
@_Complex_I = global i32 0
define double @rmsestimates(double %0, double %1, double %2, i32 %3, double* %4, double* %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca double*
%12 = alloca double*
%13 = alloca i32
%14 = alloca double
%15 = alloca double*
%16 = alloca double
%17 = alloca double
%18 = alloca i32
%19 = alloca i32
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store i32 %3, i32* %10
store double* %4, double** %11
store double* %5, double** %12
%20 = load i32, i32* @M_PI
%21 = sitofp i32 %20 to double
%22 = fmul double 2.000000e+00, %21
%23 = load double, double* %8
%24 = fmul double %22, %23
store double %24, double* %17
%25 = load i32, i32* %10
%26 = call double* @double_alloc(i32 %25)
store double* %26, double** %15
store double 0.000000e+00, double* %14
store i32 0, i32* %13
br label %27
27: ; preds = %97, %6
%28 = load i32, i32* %13
%29 = load i32, i32* %10
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %100
31: ; preds = %27
%32 = load i32, i32* @M_PI
%33 = sitofp i32 %32 to double
%34 = fmul double 2.000000e+00, %33
%35 = load double*, double** %11
%36 = load i32, i32* %13
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
%39 = load double, double* %38
%40 = fmul double %34, %39
store double %40, double* %16
%41 = load double, double* %16
%42 = fneg double %41
%43 = load double, double* %16
%44 = fmul double %42, %43
%45 = fptosi double %44 to i32
store i32 %45, i32* %18
%46 = load i32, i32* %18
%47 = sitofp i32 %46 to double
%48 = load double, double* %9
%49 = fmul double 2.000000e+00, %48
%50 = load double, double* %17
%51 = fmul double %49, %50
%52 = load double, double* %16
%53 = fmul double %51, %52
%54 = load i32, i32* @_Complex_I
%55 = sitofp i32 %54 to double
%56 = call double @llvm.fmuladd.f64(double %53, double %55, double %47)
%57 = load double, double* %17
%58 = load double, double* %17
%59 = call double @llvm.fmuladd.f64(double %57, double %58, double %56)
%60 = fptosi double %59 to i32
store i32 %60, i32* %19
%61 = load double, double* %7
%62 = load i32, i32* %18
%63 = load i32, i32* %19
%64 = sdiv i32 %62, %63
%65 = call double @cabs(i32 %64)
%66 = fmul double %61, %65
%67 = load double*, double** %15
%68 = load i32, i32* %13
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds double, double* %67, i64 %69
store double %66, double* %70
%71 = load double, double* %14
%72 = load double*, double** %12
%73 = load i32, i32* %13
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds double, double* %72, i64 %74
%76 = load double, double* %75
%77 = load double*, double** %15
%78 = load i32, i32* %13
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds double, double* %77, i64 %79
%81 = load double, double* %80
%82 = fdiv double %76, %81
%83 = fsub double %82, 1.000000e+00
%84 = load double*, double** %12
%85 = load i32, i32* %13
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds double, double* %84, i64 %86
%88 = load double, double* %87
%89 = load double*, double** %15
%90 = load i32, i32* %13
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds double, double* %89, i64 %91
%93 = load double, double* %92
%94 = fdiv double %88, %93
%95 = fsub double %94, 1.000000e+00
%96 = call double @llvm.fmuladd.f64(double %83, double %95, double %71)
store double %96, double* %14
br label %97
97: ; preds = %31
%98 = load i32, i32* %13
%99 = add nsw i32 %98, 1
store i32 %99, i32* %13
br label %27
100: ; preds = %27
%101 = load double, double* %14
%102 = load i32, i32* %10
%103 = sub nsw i32 %102, 1
%104 = sitofp i32 %103 to double
%105 = fdiv double %101, %104
%106 = call double @sqrt(double %105)
store double %106, double* %14
%107 = load double*, double** %15
%108 = call i32 @free(double* %107)
%109 = load double, double* %14
ret double %109
}

LLVM IR (-O2):
@M_PI = global i32 0
@_Complex_I = global i32 0
define double @rmsestimates(double %0, double %1, double %2, i32 %3, double* nocapture %4, double* nocapture %5) {
%7 = load i32, i32* @M_PI
%8 = sitofp i32 %7 to double
%9 = fmul double %8, 2.000000e+00
%10 = fmul double %9, %1
%11 = tail call double* @double_alloc(i32 %3)
%12 = icmp sgt i32 %3, 0
br i1 %12, label %13, label %47
13: ; preds = %6
%14 = fmul double %2, 2.000000e+00
%15 = fmul double %14, %10
%16 = zext i32 %3 to i64
br label %17
17: ; preds = %13, %17
%18 = phi i64 [ 0, %13 ], [ %45, %17 ]
%19 = phi double [ 0.000000e+00, %13 ], [ %44, %17 ]
%20 = load i32, i32* @M_PI
%21 = sitofp i32 %20 to double
%22 = fmul double %21, 2.000000e+00
%23 = getelementptr inbounds double, double* %4, i64 %18
%24 = load double, double* %23
%25 = fmul double %24, %22
%26 = fneg double %25
%27 = fmul double %25, %26
%28 = fptosi double %27 to i32
%29 = sitofp i32 %28 to double
%30 = fmul double %15, %25
%31 = load i32, i32* @_Complex_I
%32 = sitofp i32 %31 to double
%33 = tail call double @llvm.fmuladd.f64(double %30, double %32, double %29)
%34 = tail call double @llvm.fmuladd.f64(double %10, double %10, double %33)
%35 = fptosi double %34 to i32
%36 = sdiv i32 %28, %35
%37 = tail call double @cabs(i32 %36)
%38 = fmul double %37, %0
%39 = getelementptr inbounds double, double* %11, i64 %18
store double %38, double* %39
%40 = getelementptr inbounds double, double* %5, i64 %18
%41 = load double, double* %40
%42 = fdiv double %41, %38
%43 = fadd double %42, -1.000000e+00
%44 = tail call double @llvm.fmuladd.f64(double %43, double %43, double %19)
%45 = add nuw nsw i64 %18, 1
%46 = icmp eq i64 %45, %16
br i1 %46, label %47, label %17
47: ; preds = %17, %6
%48 = phi double [ 0.000000e+00, %6 ], [ %44, %17 ]
%49 = add nsw i32 %3, -1
%50 = sitofp i32 %49 to double
%51 = fdiv double %48, %50
%52 = tail call double @sqrt(double %51)
%53 = tail call i32 @free(double* %11)
ret double %52
}