float setCFIR(int *cfircoeffs, float freq_in, float Fpass, float Fstop) {
  int cfir34[] = {-24,   74,   494,   548,   -977, -3416,
                  -3672, 1525, 13074, 26547, 32767};
  float CFIRgain, gaintemp;
  int n;
  CFIRgain = 0;
  for (n = 0; n < 10; n++) {
    cfircoeffs[n] = cfir34[n];
    CFIRgain = CFIRgain + cfircoeffs[n];
  }
  cfircoeffs[10] = 32767;
  CFIRgain = 2 * CFIRgain + cfircoeffs[10];
  CFIRgain = CFIRgain / 65536;
  if (CFIRgain > 1) {
    gaintemp = CFIRgain;
    CFIRgain = 0;
    for (n = 0; n < 10; n++) {
      cfircoeffs[n] = (int)((1 / gaintemp) * (float)cfircoeffs[n] + 0.499999);
      CFIRgain = CFIRgain + cfircoeffs[n];
    }
    cfircoeffs[10] = (int)((1 / gaintemp) * (float)cfircoeffs[n] + 0.499999);
    CFIRgain = 2 * CFIRgain + cfircoeffs[10];
    CFIRgain = CFIRgain / 65536;
  }
  return CFIRgain;
}


x86 assembly (clang, -O0):
<setCFIR>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  %xmm2,-0x14(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xeda(%rip),%rsi
mov    $0x2c,%edx
call   1030 <memcpy@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x44(%rbp)
movl   $0x0,-0x4c(%rbp)
cmpl   $0xa,-0x4c(%rbp)
jge    1195 <setCFIR+0x85>
movslq -0x4c(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%edx
mov    -0x8(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movss  -0x44(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x4c(%rbp),%rcx
cvtsi2ssl (%rax,%rcx,4),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x44(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    114f <setCFIR+0x3f>
mov    -0x8(%rbp),%rax
movl   $0x7fff,0x28(%rax)
movss  -0x44(%rbp),%xmm0
mov    -0x8(%rbp),%rax
cvtsi2ssl 0x28(%rax),%xmm1
addss  %xmm0,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x44(%rbp)
movss  -0x44(%rbp),%xmm0
movss  0xe3c(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x44(%rbp)
movss  -0x44(%rbp),%xmm0
movss  0xe22(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    12da <setCFIR+0x1ca>
movss  -0x44(%rbp),%xmm0
movss  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x44(%rbp)
movl   $0x0,-0x4c(%rbp)
cmpl   $0xa,-0x4c(%rbp)
jge    1270 <setCFIR+0x160>
movss  0xdee(%rip),%xmm0
divss  -0x48(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x4c(%rbp),%rcx
cvtsi2ssl (%rax,%rcx,4),%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdd4(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
mov    -0x8(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movss  -0x44(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x4c(%rbp),%rcx
cvtsi2ssl (%rax,%rcx,4),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x44(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1200 <setCFIR+0xf0>
movss  0xd88(%rip),%xmm0
divss  -0x48(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x4c(%rbp),%rcx
cvtsi2ssl (%rax,%rcx,4),%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd6e(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x28(%rax)
movss  -0x44(%rbp),%xmm0
mov    -0x8(%rbp),%rax
cvtsi2ssl 0x28(%rax),%xmm1
addss  %xmm0,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x44(%rbp)
movss  -0x44(%rbp),%xmm0
movss  0xd33(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x44(%rbp)
movss  -0x44(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setCFIR>:
movaps 0xef9(%rip),%xmm0
movups %xmm0,(%rdi)
movaps 0xeff(%rip),%xmm0
movups %xmm0,0x10(%rdi)
movabs $0x43360000211a,%rax
mov    %rax,0x20(%rdi)
movl   $0x52f6,0x28(%rdi)
movss  0xeee(%rip),%xmm0
ret

LLVM IR (-O0):
@__const.setCFIR.cfir34 = [11 x i32] [i32 -24, i32 74, i32 494, i32 548, i32 -977, i32 -3416, i32 -3672, i32 1525, i32 13074, i32 26547, i32 32767]
define float @setCFIR(i32* %0, float %1, float %2, float %3) {
%5 = alloca i32*
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca [11 x i32]
%10 = alloca float
%11 = alloca float
%12 = alloca i32
store i32* %0, i32** %5
store float %1, float* %6
store float %2, float* %7
store float %3, float* %8
%13 = bitcast [11 x i32]* %9 to i8*
store float 0.000000e+00, float* %10
store i32 0, i32* %12
br label %14
14: ; preds = %34, %4
%15 = load i32, i32* %12
%16 = icmp slt i32 %15, 10
br i1 %16, label %17, label %37
17: ; preds = %14
%18 = load i32, i32* %12
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [11 x i32], [11 x i32]* %9, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = load i32*, i32** %5
%23 = load i32, i32* %12
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
store i32 %21, i32* %25
%26 = load float, float* %10
%27 = load i32*, i32** %5
%28 = load i32, i32* %12
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = load i32, i32* %30
%32 = sitofp i32 %31 to float
%33 = fadd float %26, %32
store float %33, float* %10
br label %34
34: ; preds = %17
%35 = load i32, i32* %12
%36 = add nsw i32 %35, 1
store i32 %36, i32* %12
br label %14
37: ; preds = %14
%38 = load i32*, i32** %5
%39 = getelementptr inbounds i32, i32* %38, i64 10
store i32 32767, i32* %39
%40 = load float, float* %10
%41 = load i32*, i32** %5
%42 = getelementptr inbounds i32, i32* %41, i64 10
%43 = load i32, i32* %42
%44 = sitofp i32 %43 to float
%45 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %40, float %44)
store float %45, float* %10
%46 = load float, float* %10
%47 = fdiv float %46, 6.553600e+04
store float %47, float* %10
%48 = load float, float* %10
%49 = fcmp ogt float %48, 1.000000e+00
br i1 %49, label %50, label %106
50: ; preds = %37
%51 = load float, float* %10
store float %51, float* %11
store float 0.000000e+00, float* %10
store i32 0, i32* %12
br label %52
52: ; preds = %80, %50
%53 = load i32, i32* %12
%54 = icmp slt i32 %53, 10
br i1 %54, label %55, label %83
55: ; preds = %52
%56 = load float, float* %11
%57 = fdiv float 1.000000e+00, %56
%58 = load i32*, i32** %5
%59 = load i32, i32* %12
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i32, i32* %58, i64 %60
%62 = load i32, i32* %61
%63 = sitofp i32 %62 to float
%64 = fmul float %57, %63
%65 = fpext float %64 to double
%66 = fadd double %65, 4.999990e-01
%67 = fptosi double %66 to i32
%68 = load i32*, i32** %5
%69 = load i32, i32* %12
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i32, i32* %68, i64 %70
store i32 %67, i32* %71
%72 = load float, float* %10
%73 = load i32*, i32** %5
%74 = load i32, i32* %12
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i32, i32* %73, i64 %75
%77 = load i32, i32* %76
%78 = sitofp i32 %77 to float
%79 = fadd float %72, %78
store float %79, float* %10
br label %80
80: ; preds = %55
%81 = load i32, i32* %12
%82 = add nsw i32 %81, 1
store i32 %82, i32* %12
br label %52
83: ; preds = %52
%84 = load float, float* %11
%85 = fdiv float 1.000000e+00, %84
%86 = load i32*, i32** %5
%87 = load i32, i32* %12
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i32, i32* %86, i64 %88
%90 = load i32, i32* %89
%91 = sitofp i32 %90 to float
%92 = fmul float %85, %91
%93 = fpext float %92 to double
%94 = fadd double %93, 4.999990e-01
%95 = fptosi double %94 to i32
%96 = load i32*, i32** %5
%97 = getelementptr inbounds i32, i32* %96, i64 10
store i32 %95, i32* %97
%98 = load float, float* %10
%99 = load i32*, i32** %5
%100 = getelementptr inbounds i32, i32* %99, i64 10
%101 = load i32, i32* %100
%102 = sitofp i32 %101 to float
%103 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %98, float %102)
store float %103, float* %10
%104 = load float, float* %10
%105 = fdiv float %104, 6.553600e+04
store float %105, float* %10
br label %106
106: ; preds = %83, %37
%107 = load float, float* %10
ret float %107
}

LLVM IR (-O2):
define float @setCFIR(i32* nocapture %0, float %1, float %2, float %3) {
%5 = getelementptr inbounds i32, i32* %0, i64 10
%6 = bitcast i32* %0 to <4 x i32>*
store <4 x i32> <i32 -15, i32 48, i32 320, i32 355>, <4 x i32>* %6
%7 = getelementptr inbounds i32, i32* %0, i64 4
%8 = bitcast i32* %7 to <4 x i32>*
store <4 x i32> <i32 -632, i32 -2213, i32 -2379, i32 988>, <4 x i32>* %8
%9 = getelementptr inbounds i32, i32* %0, i64 8
store i32 8474, i32* %9
%10 = getelementptr inbounds i32, i32* %0, i64 9
store i32 17206, i32* %10
store i32 21238, i32* %5
ret float 0x3FF0006000000000
}