#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 atan(double);
double bessel_i0(double);
double sinc(double);
double sqrt(double);
void lfr_filter_calculate_f32(float *data, int nsamp, int nfilt, double offset,
                              double cutoff, double beta) {
  double x, x0, t, y, xscale, yscale;
  int i, j;
  yscale = 2.0 * cutoff / bessel_i0(beta);
  xscale = (8.0 * atan(1.0)) * cutoff;
  for (i = 0; i < nfilt; ++i) {
    x0 = (nsamp - 1) / 2 + offset * i;
    for (j = 0; j < nsamp; ++j) {
      x = j - x0;
      t = x * (2.0 / (nsamp - 2));
      if (t <= -1.0 || t >= 1.0) {
        y = 0.0;
      } else {
        y = yscale * bessel_i0(beta * sqrt(1.0 - t * t)) * sinc(xscale * x);
      }
      data[i * nsamp + j] = (float)y;
    }
  }
}


x86 assembly (clang, -O0):
<lfr_filter_calculate_f32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  0xea4(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <bessel_i0@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe6f(%rip),%xmm0
call   1030 <atan@plt>
movaps %xmm0,%xmm1
movsd  0xe57(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    133c <lfr_filter_calculate_f32+0x1fc>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm1
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x5c(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1329 <lfr_filter_calculate_f32+0x1e9>
cvtsi2sdl -0x60(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
cvtsi2sd %eax,%xmm2
movsd  0xde4(%rip),%xmm1
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xdd7(%rip),%xmm0
ucomisd -0x40(%rbp),%xmm0
jae    1263 <lfr_filter_calculate_f32+0x123>
movsd  -0x40(%rbp),%xmm0
movsd  0xdaf(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1270 <lfr_filter_calculate_f32+0x130>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    12fc <lfr_filter_calculate_f32+0x1bc>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd57(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1050 <bessel_i0@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1040 <sinc@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
mov    -0x5c(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x60(%rbp),%ecx
movslq %ecx,%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    11fa <lfr_filter_calculate_f32+0xba>
jmp    132e <lfr_filter_calculate_f32+0x1ee>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11be <lfr_filter_calculate_f32+0x7e>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lfr_filter_calculate_f32>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x28(%rsp)
mov    %edx,%r15d
mov    %rsi,0x18(%rsp)
mov    %rdi,%rbx
movsd  %xmm2,0x40(%rsp)
movaps %xmm2,%xmm0
call   1050 <bessel_i0@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0xe7f(%rip),%xmm0
call   1030 <atan@plt>
movsd  0xe72(%rip),%xmm2
test   %r15d,%r15d
jle    1313 <lfr_filter_calculate_f32+0x1d3>
movsd  0x8(%rsp),%xmm0
movapd %xmm0,%xmm1
addsd  %xmm0,%xmm1
divsd  0x10(%rsp),%xmm1
movsd  %xmm1,0x38(%rsp)
mulsd  0xe4f(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x18(%rsp),%rcx
lea    -0x1(%rcx),%eax
shr    $0x1f,%eax
add    %ecx,%eax
add    $0xffffffff,%eax
sar    %eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x20(%rsp)
lea    -0x2(%rcx),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xe20(%rip),%xmm3
divsd  %xmm0,%xmm3
movslq %ecx,%r12
mov    %r15d,%r15d
mov    %r12d,%ebp
shl    $0x2,%r12
xor    %r13d,%r13d
movsd  0xe0c(%rip),%xmm4
movsd  %xmm3,0x30(%rsp)
jmp    1230 <lfr_filter_calculate_f32+0xf0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r13
add    %r12,%rbx
cmp    %r15,%r13
je     1313 <lfr_filter_calculate_f32+0x1d3>
cmpl   $0x0,0x18(%rsp)
jle    1220 <lfr_filter_calculate_f32+0xe0>
xorps  %xmm5,%xmm5
cvtsi2sd %r13d,%xmm5
mulsd  0x28(%rsp),%xmm5
addsd  0x20(%rsp),%xmm5
xor    %r14d,%r14d
movsd  %xmm5,0x48(%rsp)
jmp    12c6 <lfr_filter_calculate_f32+0x186>
cs nopw 0x0(%rax,%rax,1)
call   1060 <sqrt@plt>
mulsd  0x40(%rsp),%xmm0
call   1050 <bessel_i0@plt>
mulsd  0x38(%rsp),%xmm0
movsd  %xmm0,0x50(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
call   1040 <sinc@plt>
mulsd  0x50(%rsp),%xmm0
movsd  0xd65(%rip),%xmm2
movsd  0x30(%rsp),%xmm3
movsd  0xd6f(%rip),%xmm4
movsd  0x48(%rsp),%xmm5
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rbx,%r14,4)
add    $0x1,%r14
cmp    %r14,%rbp
je     1220 <lfr_filter_calculate_f32+0xe0>
xorps  %xmm6,%xmm6
cvtsi2sd %r14d,%xmm6
subsd  %xmm5,%xmm6
movapd %xmm3,%xmm1
mulsd  %xmm6,%xmm1
ucomisd %xmm1,%xmm4
xorpd  %xmm0,%xmm0
jae    12af <lfr_filter_calculate_f32+0x16f>
ucomisd %xmm2,%xmm1
jae    12af <lfr_filter_calculate_f32+0x16f>
mulsd  %xmm1,%xmm1
movapd %xmm2,%xmm0
subsd  %xmm1,%xmm0
ucomisd 0xd22(%rip),%xmm0
movsd  %xmm6,0x10(%rsp)
jb     1260 <lfr_filter_calculate_f32+0x120>
sqrtsd %xmm0,%xmm0
jmp    1265 <lfr_filter_calculate_f32+0x125>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @lfr_filter_calculate_f32(float* nocapture writeonly %0, i32 %1, i32 %2, double %3, double %4, double %5) {
%7 = fmul double %4, 2.000000e+00
%8 = tail call double @bessel_i0(double %5)
%9 = fdiv double %7, %8
%10 = tail call double @atan(double 1.000000e+00)
%11 = fmul double %4, 0x401921FB54442D18
%12 = icmp sgt i32 %2, 0
br i1 %12, label %13, label %60
13: ; preds = %6
%14 = add nsw i32 %1, -1
%15 = sdiv i32 %14, 2
%16 = sitofp i32 %15 to double
%17 = icmp sgt i32 %1, 0
%18 = add nsw i32 %1, -2
%19 = sitofp i32 %18 to double
%20 = fdiv double 2.000000e+00, %19
%21 = sext i32 %1 to i64
%22 = zext i32 %2 to i64
%23 = zext i32 %1 to i64
br label %24
24: ; preds = %13, %57
%25 = phi i64 [ 0, %13 ], [ %58, %57 ]
%26 = trunc i64 %25 to i32
%27 = sitofp i32 %26 to double
%28 = tail call double @llvm.fmuladd.f64(double %3, double %27, double %16)
br i1 %17, label %29, label %57
29: ; preds = %24
%30 = mul nsw i64 %25, %21
br label %31
31: ; preds = %29, %50
%32 = phi i64 [ 0, %29 ], [ %55, %50 ]
%33 = trunc i64 %32 to i32
%34 = sitofp i32 %33 to double
%35 = fsub double %34, %28
%36 = fmul double %20, %35
%37 = fcmp ole double %36, -1.000000e+00
%38 = fcmp oge double %36, 1.000000e+00
%39 = or i1 %37, %38
br i1 %39, label %50, label %40
40: ; preds = %31
%41 = fneg double %36
%42 = tail call double @llvm.fmuladd.f64(double %41, double %36, double 1.000000e+00)
%43 = tail call double @sqrt(double %42)
%44 = fmul double %43, %5
%45 = tail call double @bessel_i0(double %44)
%46 = fmul double %9, %45
%47 = fmul double %11, %35
%48 = tail call double @sinc(double %47)
%49 = fmul double %46, %48
br label %50
50: ; preds = %31, %40
%51 = phi double [ %49, %40 ], [ 0.000000e+00, %31 ]
%52 = fptrunc double %51 to float
%53 = add nsw i64 %32, %30
%54 = getelementptr inbounds float, float* %0, i64 %53
store float %52, float* %54
%55 = add nuw nsw i64 %32, 1
%56 = icmp eq i64 %55, %23
br i1 %56, label %57, label %31
57: ; preds = %50, %24
%58 = add nuw nsw i64 %25, 1
%59 = icmp eq i64 %58, %22
br i1 %59, label %60, label %24
60: ; preds = %57, %6
ret void
}