#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 i_zero(double);
double sqrt(double);
void kaiser(double *taps, size_t ntaps, double beta) {
  double i_beta = 1.0 / i_zero(beta);
  double inm1 = 1.0 / ((double)(ntaps - 1));
  double temp;
  int i;
  taps[0] = i_beta;
  for (i = 1; i < ntaps - 1; i++) {
    temp = 2 * i * inm1 - 1;
    taps[i] = i_zero(beta * sqrt(1.0 - temp * temp)) * i_beta;
  }
  taps[ntaps - 1] = i_beta;
}


x86 assembly (clang, -O0):
<kaiser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <i_zero@plt>
movaps %xmm0,%xmm1
movsd  0xeb6(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
movq   %rax,%xmm1
movaps 0xea9(%rip),%xmm0
punpckldq %xmm0,%xmm1
movapd 0xead(%rip),%xmm0
subpd  %xmm0,%xmm1
movaps %xmm1,%xmm0
unpckhpd %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe76(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x34(%rbp)
movslq -0x34(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jae    1251 <kaiser+0x131>
mov    -0x34(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe31(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xde9(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <i_zero@plt>
mulsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11a7 <kaiser+0x87>
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
movsd  %xmm0,(%rax,%rcx,8)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kaiser>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movsd  %xmm0,0x10(%rsp)
call   1030 <i_zero@plt>
movsd  0xebc(%rip),%xmm1
divsd  %xmm0,%xmm1
lea    -0x1(%r14),%rax
movsd  %xmm1,(%rsp)
movsd  %xmm1,(%r15)
cmp    $0x2,%rax
jb     11fa <kaiser+0xda>
movq   %rax,%xmm0
punpckldq 0xeb3(%rip),%xmm0
subpd  0xebb(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe77(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    -0x2(%r14),%r12
mov    $0x2,%ebx
jmp    11c5 <kaiser+0xa5>
xchg   %ax,%ax
call   1040 <sqrt@plt>
mulsd  0x10(%rsp),%xmm0
call   1030 <i_zero@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%r15,%rbx,4)
add    $0x2,%rbx
add    $0xffffffffffffffff,%r12
je     11fa <kaiser+0xda>
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
mulsd  0x8(%rsp),%xmm1
addsd  0xe2e(%rip),%xmm1
mulsd  %xmm1,%xmm1
movsd  0xe1a(%rip),%xmm0
subsd  %xmm1,%xmm0
ucomisd 0xe1e(%rip),%xmm0
jb     11a0 <kaiser+0x80>
sqrtsd %xmm0,%xmm0
jmp    11a5 <kaiser+0x85>
movsd  (%rsp),%xmm0
movsd  %xmm0,-0x8(%r15,%r14,8)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @kaiser(double* %0, i64 %1, double %2) {
%4 = alloca double*
%5 = alloca i64
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
store double* %0, double** %4
store i64 %1, i64* %5
store double %2, double* %6
%11 = load double, double* %6
%12 = call double @i_zero(double %11)
%13 = fdiv double 1.000000e+00, %12
store double %13, double* %7
%14 = load i64, i64* %5
%15 = sub i64 %14, 1
%16 = uitofp i64 %15 to double
%17 = fdiv double 1.000000e+00, %16
store double %17, double* %8
%18 = load double, double* %7
%19 = load double*, double** %4
%20 = getelementptr inbounds double, double* %19, i64 0
store double %18, double* %20
store i32 1, i32* %10
br label %21
21: ; preds = %47, %3
%22 = load i32, i32* %10
%23 = sext i32 %22 to i64
%24 = load i64, i64* %5
%25 = sub i64 %24, 1
%26 = icmp ult i64 %23, %25
br i1 %26, label %27, label %50
27: ; preds = %21
%28 = load i32, i32* %10
%29 = mul nsw i32 2, %28
%30 = sitofp i32 %29 to double
%31 = load double, double* %8
%32 = call double @llvm.fmuladd.f64(double %30, double %31, double -1.000000e+00)
store double %32, double* %9
%33 = load double, double* %6
%34 = load double, double* %9
%35 = load double, double* %9
%36 = fneg double %34
%37 = call double @llvm.fmuladd.f64(double %36, double %35, double 1.000000e+00)
%38 = call double @sqrt(double %37)
%39 = fmul double %33, %38
%40 = call double @i_zero(double %39)
%41 = load double, double* %7
%42 = fmul double %40, %41
%43 = load double*, double** %4
%44 = load i32, i32* %10
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
store double %42, double* %46
br label %47
47: ; preds = %27
%48 = load i32, i32* %10
%49 = add nsw i32 %48, 1
store i32 %49, i32* %10
br label %21
50: ; preds = %21
%51 = load double, double* %7
%52 = load double*, double** %4
%53 = load i64, i64* %5
%54 = sub i64 %53, 1
%55 = getelementptr inbounds double, double* %52, i64 %54
store double %51, double* %55
ret void
}

LLVM IR (-O2):
define void @kaiser(double* nocapture writeonly %0, i64 %1, double %2) {
%4 = tail call double @i_zero(double %2)
%5 = fdiv double 1.000000e+00, %4
%6 = add i64 %1, -1
%7 = uitofp i64 %6 to double
%8 = fdiv double 1.000000e+00, %7
store double %5, double* %0
%9 = icmp ugt i64 %6, 1
br i1 %9, label %10, label %25
10: ; preds = %3, %10
%11 = phi i64 [ %23, %10 ], [ 1, %3 ]
%12 = trunc i64 %11 to i32
%13 = shl i32 %12, 1
%14 = sitofp i32 %13 to double
%15 = tail call double @llvm.fmuladd.f64(double %14, double %8, double -1.000000e+00)
%16 = fneg double %15
%17 = tail call double @llvm.fmuladd.f64(double %16, double %15, double 1.000000e+00)
%18 = tail call double @sqrt(double %17)
%19 = fmul double %18, %2
%20 = tail call double @i_zero(double %19)
%21 = fmul double %5, %20
%22 = getelementptr inbounds double, double* %0, i64 %11
store double %21, double* %22
%23 = add nuw i64 %11, 1
%24 = icmp eq i64 %23, %6
br i1 %24, label %25, label %10
25: ; preds = %10, %3
%26 = getelementptr inbounds double, double* %0, i64 %6
store double %5, double* %26
ret void
}