#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 Izero(float);
double sin(float);
float sqrt(double);
void KaiserLowpass(int length, float cutoff, float beta, float gain,
                   double *filter) {
  double ibeta, ilength, x, w;
  int i;
  ibeta = 1.0 / Izero(beta);
  ilength = 1.0 / (length - 0.5);
  for (i = 0; i < length; i++) {
    x = i + 0.5;
    w = x * ilength;
    w = 1.0 - w * w;
    w = (((0.0) > (w)) ? (0.0) : (w));
    w = Izero(beta * sqrt(w)) * ibeta;
    filter[i] = w * gain * sin(cutoff * 3.14159265358979323846 * x) /
                (3.14159265358979323846 * x);
  }
}


x86 assembly (clang, -O0):
<KaiserLowpass>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <Izero@plt>
movaps %xmm0,%xmm1
movsd  0xe9d(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xe8f(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xe7b(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12cc <KaiserLowpass+0x19c>
cvtsi2sdl -0x3c(%rbp),%xmm0
movsd  0xe5a(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe0d(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    1217 <KaiserLowpass+0xe7>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1221 <KaiserLowpass+0xf1>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x54(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x54(%rbp),%xmm0
mulss  %xmm1,%xmm0
call   1030 <Izero@plt>
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd8e(%rip),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x30(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd68(%rip),%xmm1
mulsd  -0x30(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1195 <KaiserLowpass+0x65>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<KaiserLowpass>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%r14
movss  %xmm2,0x8(%rsp)
movss  %xmm0,0x10(%rsp)
mov    %edi,%ebp
movss  %xmm1,0x1c(%rsp)
movapd %xmm1,%xmm0
call   1030 <Izero@plt>
test   %ebp,%ebp
jle    1259 <KaiserLowpass+0x129>
movsd  0xe98(%rip),%xmm2
movapd %xmm2,%xmm3
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
divsd  %xmm0,%xmm3
movsd  %xmm3,0x38(%rsp)
addsd  0xe83(%rip),%xmm1
divsd  %xmm1,%xmm2
movsd  %xmm2,0x30(%rsp)
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x28(%rsp)
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe5f(%rip),%xmm0
movsd  %xmm0,0x20(%rsp)
mov    %ebp,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
addsd  0xe49(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x30(%rsp),%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm0,%xmm0
movsd  0xe15(%rip),%xmm1
subsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
maxsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
mulss  0x1c(%rsp),%xmm0
call   1030 <Izero@plt>
mulsd  0x38(%rsp),%xmm0
mulsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x20(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1040 <sin@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0xdce(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11c0 <KaiserLowpass+0x90>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @KaiserLowpass(i32 %0, float %1, float %2, float %3, double* %4) {
%6 = alloca i32
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca double*
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca i32
store i32 %0, i32* %6
store float %1, float* %7
store float %2, float* %8
store float %3, float* %9
store double* %4, double** %10
%16 = load float, float* %8
%17 = call double @Izero(float %16)
%18 = fdiv double 1.000000e+00, %17
store double %18, double* %11
%19 = load i32, i32* %6
%20 = sitofp i32 %19 to double
%21 = fsub double %20, 5.000000e-01
%22 = fdiv double 1.000000e+00, %21
store double %22, double* %12
store i32 0, i32* %15
br label %23
23: ; preds = %71, %5
%24 = load i32, i32* %15
%25 = load i32, i32* %6
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %74
27: ; preds = %23
%28 = load i32, i32* %15
%29 = sitofp i32 %28 to double
%30 = fadd double %29, 5.000000e-01
store double %30, double* %13
%31 = load double, double* %13
%32 = load double, double* %12
%33 = fmul double %31, %32
store double %33, double* %14
%34 = load double, double* %14
%35 = load double, double* %14
%36 = fneg double %34
%37 = call double @llvm.fmuladd.f64(double %36, double %35, double 1.000000e+00)
store double %37, double* %14
%38 = load double, double* %14
%39 = fcmp ogt double 0.000000e+00, %38
br i1 %39, label %40, label %41
40: ; preds = %27
br label %43
41: ; preds = %27
%42 = load double, double* %14
br label %43
43: ; preds = %41, %40
%44 = phi double [ 0.000000e+00, %40 ], [ %42, %41 ]
store double %44, double* %14
%45 = load float, float* %8
%46 = load double, double* %14
%47 = call float @sqrt(double %46)
%48 = fmul float %45, %47
%49 = call double @Izero(float %48)
%50 = load double, double* %11
%51 = fmul double %49, %50
store double %51, double* %14
%52 = load double, double* %14
%53 = load float, float* %9
%54 = fpext float %53 to double
%55 = fmul double %52, %54
%56 = load float, float* %7
%57 = fpext float %56 to double
%58 = fmul double %57, 0x400921FB54442D18
%59 = load double, double* %13
%60 = fmul double %58, %59
%61 = fptrunc double %60 to float
%62 = call double @sin(float %61)
%63 = fmul double %55, %62
%64 = load double, double* %13
%65 = fmul double 0x400921FB54442D18, %64
%66 = fdiv double %63, %65
%67 = load double*, double** %10
%68 = load i32, i32* %15
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds double, double* %67, i64 %69
store double %66, double* %70
br label %71
71: ; preds = %43
%72 = load i32, i32* %15
%73 = add nsw i32 %72, 1
store i32 %73, i32* %15
br label %23
74: ; preds = %23
ret void
}

LLVM IR (-O2):
define void @KaiserLowpass(i32 %0, float %1, float %2, float %3, double* nocapture writeonly %4) {
%6 = tail call double @Izero(float %2)
%7 = fdiv double 1.000000e+00, %6
%8 = sitofp i32 %0 to double
%9 = fadd double %8, -5.000000e-01
%10 = fdiv double 1.000000e+00, %9
%11 = icmp sgt i32 %0, 0
br i1 %11, label %12, label %41
12: ; preds = %5
%13 = fpext float %3 to double
%14 = fpext float %1 to double
%15 = fmul double %14, 0x400921FB54442D18
%16 = zext i32 %0 to i64
br label %17
17: ; preds = %12, %17
%18 = phi i64 [ 0, %12 ], [ %39, %17 ]
%19 = trunc i64 %18 to i32
%20 = sitofp i32 %19 to double
%21 = fadd double %20, 5.000000e-01
%22 = fmul double %10, %21
%23 = fneg double %22
%24 = tail call double @llvm.fmuladd.f64(double %23, double %22, double 1.000000e+00)
%25 = fcmp olt double %24, 0.000000e+00
%26 = select i1 %25, double 0.000000e+00, double %24
%27 = tail call float @sqrt(double %26)
%28 = fmul float %27, %2
%29 = tail call double @Izero(float %28)
%30 = fmul double %7, %29
%31 = fmul double %30, %13
%32 = fmul double %15, %21
%33 = fptrunc double %32 to float
%34 = tail call double @sin(float %33)
%35 = fmul double %34, %31
%36 = fmul double %21, 0x400921FB54442D18
%37 = fdiv double %35, %36
%38 = getelementptr inbounds double, double* %4, i64 %18
store double %37, double* %38
%39 = add nuw nsw i64 %18, 1
%40 = icmp eq i64 %39, %16
br i1 %40, label %41, label %17
41: ; preds = %17, %5
ret void
}