#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 const cos(double const);
double pow(double, double);
double const sqrt(double const);
float GammaFilterSmootherCoeff(int order, float cutoff_frequency_hz,
                               float sample_rate_hz) {
  const double theta =
      cutoff_frequency_hz * 2.0 * 3.14159265358979324 / sample_rate_hz;
  const double single_stage_power = pow(0.5, 1.0 / order);
  const double q =
      (1.0 - single_stage_power * cos(theta)) / (1.0 - single_stage_power);
  const double p = q - sqrt(q * q - 1.0);
  return (float)(1.0 - p);
}


x86 assembly (clang, -O0):
<GammaFilterSmootherCoeff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xeca(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xeb6(%rip),%xmm1
mulsd  %xmm1,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xe7b(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0xe7f(%rip),%xmm0
call   1040 <pow@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe26(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe1a(%rip),%xmm1
subsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdf4(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xdca(%rip),%xmm0
subsd  -0x30(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GammaFilterSmootherCoeff>:
sub    $0x18,%rsp
cvtss2sd %xmm0,%xmm2
addsd  %xmm2,%xmm2
mulsd  0xebc(%rip),%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
divsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sd %edi,%xmm1
movsd  0xea4(%rip),%xmm0
divsd  %xmm1,%xmm0
call   1030 <exp2@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
movsd  0x10(%rsp),%xmm3
mulsd  %xmm3,%xmm0
movsd  0xe80(%rip),%xmm1
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
subsd  %xmm3,%xmm1
divsd  %xmm1,%xmm2
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
addsd  0xe58(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11c0 <GammaFilterSmootherCoeff+0x90>
sqrtsd %xmm0,%xmm0
jmp    11d1 <GammaFilterSmootherCoeff+0xa1>
movsd  %xmm2,0x8(%rsp)
call   1050 <sqrt@plt>
movsd  0x8(%rsp),%xmm2
subsd  %xmm2,%xmm0
addsd  0xe33(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @GammaFilterSmootherCoeff(i32 %0, float %1, float %2) {
%4 = alloca i32
%5 = alloca float
%6 = alloca float
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store i32 %0, i32* %4
store float %1, float* %5
store float %2, float* %6
%11 = load float, float* %5
%12 = fpext float %11 to double
%13 = fmul double %12, 2.000000e+00
%14 = fmul double %13, 0x400921FB54442D18
%15 = load float, float* %6
%16 = fpext float %15 to double
%17 = fdiv double %14, %16
store double %17, double* %7
%18 = load i32, i32* %4
%19 = sitofp i32 %18 to double
%20 = fdiv double 1.000000e+00, %19
%21 = call double @pow(double 5.000000e-01, double %20)
store double %21, double* %8
%22 = load double, double* %8
%23 = load double, double* %7
%24 = call double @cos(double %23)
%25 = fneg double %22
%26 = call double @llvm.fmuladd.f64(double %25, double %24, double 1.000000e+00)
%27 = load double, double* %8
%28 = fsub double 1.000000e+00, %27
%29 = fdiv double %26, %28
store double %29, double* %9
%30 = load double, double* %9
%31 = load double, double* %9
%32 = load double, double* %9
%33 = call double @llvm.fmuladd.f64(double %31, double %32, double -1.000000e+00)
%34 = call double @sqrt(double %33)
%35 = fsub double %30, %34
store double %35, double* %10
%36 = load double, double* %10
%37 = fsub double 1.000000e+00, %36
%38 = fptrunc double %37 to float
ret float %38
}

LLVM IR (-O2):
define float @GammaFilterSmootherCoeff(i32 %0, float %1, float %2) {
%4 = fpext float %1 to double
%5 = fmul double %4, 2.000000e+00
%6 = fmul double %5, 0x400921FB54442D18
%7 = fpext float %2 to double
%8 = fdiv double %6, %7
%9 = sitofp i32 %0 to double
%10 = fdiv double -1.000000e+00, %9
%11 = tail call double @exp2(double %10)
%12 = tail call double @cos(double %8)
%13 = fneg double %11
%14 = tail call double @llvm.fmuladd.f64(double %13, double %12, double 1.000000e+00)
%15 = fsub double 1.000000e+00, %11
%16 = fdiv double %14, %15
%17 = tail call double @llvm.fmuladd.f64(double %16, double %16, double -1.000000e+00)
%18 = tail call double @sqrt(double %17)
%19 = fsub double %18, %16
%20 = fadd double %19, 1.000000e+00
%21 = fptrunc double %20 to float
ret float %21
}