#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 GetCenterFrequency(unsigned int);
double GetMagnitudeFactor(unsigned int);
double GetFilterParameter(unsigned int samplingRate, unsigned int binSize,
                          unsigned int frequencyBand, unsigned int filterBand) {
  double filterParameter = 0.0f;
  double boundary = (frequencyBand * samplingRate) / binSize;
  double prevCenterFrequency = GetCenterFrequency(filterBand - 1);
  double thisCenterFrequency = GetCenterFrequency(filterBand);
  double nextCenterFrequency = GetCenterFrequency(filterBand + 1);
  if (boundary >= 0 && boundary < prevCenterFrequency) {
    filterParameter = 0.0f;
  } else if (boundary >= prevCenterFrequency &&
             boundary < thisCenterFrequency) {
    filterParameter = (boundary - prevCenterFrequency) /
                      (thisCenterFrequency - prevCenterFrequency);
    filterParameter *= GetMagnitudeFactor(filterBand);
  } else if (boundary >= thisCenterFrequency &&
             boundary < nextCenterFrequency) {
    filterParameter = (boundary - nextCenterFrequency) /
                      (thisCenterFrequency - nextCenterFrequency);
    filterParameter *= GetMagnitudeFactor(filterBand);
  } else if (boundary >= nextCenterFrequency && boundary < samplingRate) {
    filterParameter = 0.0f;
  }
  return filterParameter;
}


x86 assembly (clang, -O0):
<GetFilterParameter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x4(%rbp),%ecx
imul   %ecx,%eax
mov    -0x8(%rbp),%ecx
xor    %edx,%edx
div    %ecx
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%edi
sub    $0x1,%edi
call   1040 <GetCenterFrequency@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%edi
call   1040 <GetCenterFrequency@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%edi
add    $0x1,%edi
call   1040 <GetCenterFrequency@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11b6 <GetFilterParameter+0x96>
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b6 <GetFilterParameter+0x96>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12a4 <GetFilterParameter+0x184>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     120e <GetFilterParameter+0xee>
movsd  -0x20(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    120e <GetFilterParameter+0xee>
movsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
subsd  -0x28(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <GetMagnitudeFactor@plt>
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    129f <GetFilterParameter+0x17f>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jb     1266 <GetFilterParameter+0x146>
movsd  -0x20(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1266 <GetFilterParameter+0x146>
movsd  -0x20(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
subsd  -0x38(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <GetMagnitudeFactor@plt>
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    129a <GetFilterParameter+0x17a>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jb     1295 <GetFilterParameter+0x175>
movsd  -0x20(%rbp),%xmm1
mov    -0x4(%rbp),%eax
cvtsi2sd %rax,%xmm0
ucomisd %xmm1,%xmm0
jbe    1295 <GetFilterParameter+0x175>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    129a <GetFilterParameter+0x17a>
jmp    129f <GetFilterParameter+0x17f>
jmp    12a4 <GetFilterParameter+0x184>
movsd  -0x18(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetFilterParameter>:
push   %rbx
sub    $0x20,%rsp
mov    %ecx,%ebx
mov    %edi,%eax
imul   %edx,%eax
xor    %edx,%edx
div    %esi
cvtsi2sd %rax,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    -0x1(%rbx),%edi
call   1040 <GetCenterFrequency@plt>
movsd  %xmm0,0x18(%rsp)
mov    %ebx,%edi
call   1040 <GetCenterFrequency@plt>
movsd  %xmm0,0x10(%rsp)
lea    0x1(%rbx),%edi
call   1040 <GetCenterFrequency@plt>
movsd  0x18(%rsp),%xmm4
movsd  0x8(%rsp),%xmm2
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm4
ja     11b9 <GetFilterParameter+0x99>
ucomisd %xmm4,%xmm2
movsd  0x10(%rsp),%xmm3
jb     118a <GetFilterParameter+0x6a>
ucomisd %xmm2,%xmm3
ja     119a <GetFilterParameter+0x7a>
ucomisd %xmm3,%xmm2
jb     11b9 <GetFilterParameter+0x99>
ucomisd %xmm2,%xmm1
movapd %xmm1,%xmm4
jbe    11b9 <GetFilterParameter+0x99>
subsd  %xmm4,%xmm2
subsd  %xmm4,%xmm3
divsd  %xmm3,%xmm2
movsd  %xmm2,0x8(%rsp)
mov    %ebx,%edi
call   1030 <GetMagnitudeFactor@plt>
mulsd  0x8(%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define double @GetFilterParameter(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = mul i32 %2, %0
%6 = udiv i32 %5, %1
%7 = uitofp i32 %6 to double
%8 = add i32 %3, -1
%9 = tail call double @GetCenterFrequency(i32 %8)
%10 = tail call double @GetCenterFrequency(i32 %3)
%11 = add i32 %3, 1
%12 = tail call double @GetCenterFrequency(i32 %11)
%13 = fcmp ogt double %9, %7
br i1 %13, label %29, label %14
14: ; preds = %4
%15 = fcmp ole double %9, %7
%16 = fcmp ogt double %10, %7
%17 = select i1 %15, i1 %16, i1 false
br i1 %17, label %22, label %18
18: ; preds = %14
%19 = fcmp ole double %10, %7
%20 = fcmp ogt double %12, %7
%21 = select i1 %19, i1 %20, i1 false
br i1 %21, label %22, label %29
22: ; preds = %18, %14
%23 = phi double [ %9, %14 ], [ %12, %18 ]
%24 = fsub double %7, %23
%25 = fsub double %10, %23
%26 = fdiv double %24, %25
%27 = tail call double @GetMagnitudeFactor(i32 %3)
%28 = fmul double %26, %27
br label %29
29: ; preds = %22, %18, %4
%30 = phi double [ 0.000000e+00, %4 ], [ 0.000000e+00, %18 ], [ %28, %22 ]
ret double %30
}