#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 */
double GetFilterParameter(unsigned int, unsigned int, unsigned int,
                          unsigned int);
double NormalizationFactor(unsigned int, unsigned int);
double cos(unsigned int);
scalar_t__ fabs(double);
double log(double);
double GetCoefficient(double *spectralData, unsigned int samplingRate,
                      unsigned int NumFilters, unsigned int binSize,
                      unsigned int m) {
  double result = 0.0f;
  double outerSum = 0.0f;
  double innerSum = 0.0f;
  unsigned int k, l;
  if (m >= NumFilters) {
    return 0.0f;
  }
  result = NormalizationFactor(NumFilters, m);
  for (l = 1; l <= NumFilters; l++) {
    innerSum = 0.0f;
    for (k = 0; k < binSize - 1; k++) {
      innerSum += fabs(spectralData[k] *
                       GetFilterParameter(samplingRate, binSize, k, l));
    }
    if (innerSum > 0.0f) {
      innerSum = log(innerSum);
    }
    innerSum =
        innerSum *
        cos(((m * 3.14159265358979323846264338327) / NumFilters) * (l - 0.5f));
    outerSum += innerSum;
  }
  result *= outerSum;
  return result;
}


x86 assembly (clang, -O0):
<GetCoefficient>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jb     119a <GetCoefficient+0x4a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12e7 <GetCoefficient+0x197>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1040 <NormalizationFactor@plt>
movsd  %xmm0,-0x28(%rbp)
movl   $0x1,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x18(%rbp),%eax
ja     12ce <GetCoefficient+0x17e>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jae    122d <GetCoefficient+0xdd>
mov    -0x10(%rbp),%rax
mov    -0x3c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x3c(%rbp),%edx
mov    -0x40(%rbp),%ecx
call   1050 <GetFilterParameter@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <fabs@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11cc <GetCoefficient+0x7c>
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    124e <GetCoefficient+0xfe>
movsd  -0x38(%rbp),%xmm0
call   1070 <log@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x20(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  0xd98(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%eax
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
mov    -0x40(%rbp),%eax
cvtsi2ss %rax,%xmm1
movss  0xd80(%rip),%xmm2
addss  %xmm2,%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,%edi
call   1060 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11b1 <GetCoefficient+0x61>
movsd  -0x30(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetCoefficient>:
xorpd  %xmm0,%xmm0
cmp    %edx,%r8d
jae    12b4 <GetCoefficient+0x164>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8d,%ebx
mov    %ecx,%r15d
mov    %esi,%r12d
mov    %rdi,%r13
mov    %edx,%edi
mov    %r8d,%esi
mov    %edx,%ebp
call   1040 <NormalizationFactor@plt>
movsd  %xmm0,0x18(%rsp)
lea    -0x1(%r15),%r14d
mov    %ebx,%eax
cvtsi2sd %rax,%xmm1
mulsd  0xe64(%rip),%xmm1
mov    %ebp,%eax
mov    %ebp,%ebx
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
mov    $0x1,%ebp
xorpd  %xmm1,%xmm1
mov    %ebx,0x14(%rsp)
jmp    121b <GetCoefficient+0xcb>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x14(%rsp),%ebx
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  0xe24(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0x20(%rsp),%xmm0
cvttsd2si %xmm0,%rdi
call   1060 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
addsd  %xmm0,%xmm1
add    $0x1,%ebp
cmp    %ebx,%ebp
ja     129c <GetCoefficient+0x14c>
movsd  %xmm1,0x28(%rsp)
xorpd  %xmm0,%xmm0
test   %r14,%r14
je     11d4 <GetCoefficient+0x84>
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
movsd  %xmm0,0x8(%rsp)
movsd  0x0(%r13,%rbx,8),%xmm0
movsd  %xmm0,0x30(%rsp)
mov    %r12d,%edi
mov    %r15d,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
call   1050 <GetFilterParameter@plt>
mulsd  0x30(%rsp),%xmm0
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1230 <GetCoefficient+0xe0>
ucomisd 0xd7c(%rip),%xmm0
jbe    11d0 <GetCoefficient+0x80>
call   1070 <log@plt>
jmp    11d0 <GetCoefficient+0x80>
movsd  0x18(%rsp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @GetCoefficient(double* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca double
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca i32
%16 = alloca i32
store double* %0, double** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store double 0.000000e+00, double* %12
store double 0.000000e+00, double* %13
store double 0.000000e+00, double* %14
%17 = load i32, i32* %11
%18 = load i32, i32* %9
%19 = icmp uge i32 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %5
store double 0.000000e+00, double* %6
br label %87
21: ; preds = %5
%22 = load i32, i32* %9
%23 = load i32, i32* %11
%24 = call double @NormalizationFactor(i32 %22, i32 %23)
store double %24, double* %12
store i32 1, i32* %16
br label %25
25: ; preds = %79, %21
%26 = load i32, i32* %16
%27 = load i32, i32* %9
%28 = icmp ule i32 %26, %27
br i1 %28, label %29, label %82
29: ; preds = %25
store double 0.000000e+00, double* %14
store i32 0, i32* %15
br label %30
30: ; preds = %51, %29
%31 = load i32, i32* %15
%32 = load i32, i32* %10
%33 = sub i32 %32, 1
%34 = icmp ult i32 %31, %33
br i1 %34, label %35, label %54
35: ; preds = %30
%36 = load double*, double** %7
%37 = load i32, i32* %15
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds double, double* %36, i64 %38
%40 = load double, double* %39
%41 = load i32, i32* %8
%42 = load i32, i32* %10
%43 = load i32, i32* %15
%44 = load i32, i32* %16
%45 = call double @GetFilterParameter(i32 %41, i32 %42, i32 %43, i32 %44)
%46 = fmul double %40, %45
%47 = call i64 @fabs(double %46)
%48 = sitofp i64 %47 to double
%49 = load double, double* %14
%50 = fadd double %49, %48
store double %50, double* %14
br label %51
51: ; preds = %35
%52 = load i32, i32* %15
%53 = add i32 %52, 1
store i32 %53, i32* %15
br label %30
54: ; preds = %30
%55 = load double, double* %14
%56 = fcmp ogt double %55, 0.000000e+00
br i1 %56, label %57, label %60
57: ; preds = %54
%58 = load double, double* %14
%59 = call double @log(double %58)
store double %59, double* %14
br label %60
60: ; preds = %57, %54
%61 = load double, double* %14
%62 = load i32, i32* %11
%63 = uitofp i32 %62 to double
%64 = fmul double %63, 0x400921FB54442D18
%65 = load i32, i32* %9
%66 = uitofp i32 %65 to double
%67 = fdiv double %64, %66
%68 = load i32, i32* %16
%69 = uitofp i32 %68 to float
%70 = fsub float %69, 5.000000e-01
%71 = fpext float %70 to double
%72 = fmul double %67, %71
%73 = fptoui double %72 to i32
%74 = call double @cos(i32 %73)
%75 = fmul double %61, %74
store double %75, double* %14
%76 = load double, double* %14
%77 = load double, double* %13
%78 = fadd double %77, %76
store double %78, double* %13
br label %79
79: ; preds = %60
%80 = load i32, i32* %16
%81 = add i32 %80, 1
store i32 %81, i32* %16
br label %25
82: ; preds = %25
%83 = load double, double* %13
%84 = load double, double* %12
%85 = fmul double %84, %83
store double %85, double* %12
%86 = load double, double* %12
store double %86, double* %6
br label %87
87: ; preds = %82, %20
%88 = load double, double* %6
ret double %88
}

LLVM IR (-O2):
define double @GetCoefficient(double* nocapture %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp ult i32 %4, %2
br i1 %6, label %7, label %50
7: ; preds = %5
%8 = tail call double @NormalizationFactor(i32 %2, i32 %4)
%9 = add i32 %3, -1
%10 = icmp eq i32 %9, 0
%11 = uitofp i32 %4 to double
%12 = fmul double %11, 0x400921FB54442D18
%13 = uitofp i32 %2 to double
%14 = fdiv double %12, %13
%15 = zext i32 %9 to i64
br label %16
16: ; preds = %7, %36
%17 = phi i32 [ 1, %7 ], [ %46, %36 ]
%18 = phi double [ 0.000000e+00, %7 ], [ %45, %36 ]
br i1 %10, label %36, label %19
19: ; preds = %16, %19
%20 = phi i64 [ %30, %19 ], [ 0, %16 ]
%21 = phi double [ %29, %19 ], [ 0.000000e+00, %16 ]
%22 = getelementptr inbounds double, double* %0, i64 %20
%23 = load double, double* %22
%24 = trunc i64 %20 to i32
%25 = tail call double @GetFilterParameter(i32 %1, i32 %3, i32 %24, i32 %17)
%26 = fmul double %23, %25
%27 = tail call i64 @fabs(double %26)
%28 = sitofp i64 %27 to double
%29 = fadd double %21, %28
%30 = add nuw nsw i64 %20, 1
%31 = icmp eq i64 %30, %15
br i1 %31, label %32, label %19
32: ; preds = %19
%33 = fcmp ogt double %29, 0.000000e+00
br i1 %33, label %34, label %36
34: ; preds = %32
%35 = tail call double @log(double %29)
br label %36
36: ; preds = %16, %34, %32
%37 = phi double [ %35, %34 ], [ %29, %32 ], [ 0.000000e+00, %16 ]
%38 = uitofp i32 %17 to float
%39 = fadd float %38, -5.000000e-01
%40 = fpext float %39 to double
%41 = fmul double %14, %40
%42 = fptoui double %41 to i32
%43 = tail call double @cos(i32 %42)
%44 = fmul double %37, %43
%45 = fadd double %18, %44
%46 = add i32 %17, 1
%47 = icmp ugt i32 %46, %2
br i1 %47, label %48, label %16
48: ; preds = %36
%49 = fmul double %8, %45
br label %50
50: ; preds = %5, %48
%51 = phi double [ %49, %48 ], [ 0.000000e+00, %5 ]
ret double %51
}