#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 besselI0(double const);
scalar_t__ pow(double, int);
double const sqrt(scalar_t__);
void kaiser(double *window, const int N, const double alpha) {
  int n;
  const double M = N - 1;
  double num;
  for (n = 0; n < N; n++) {
    num = besselI0(alpha * sqrt(1.0 - pow((2.0 * n / M - 1), 2)));
    window[n] = num / besselI0(alpha);
  }
}


x86 assembly (clang, -O0):
<kaiser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1208 <kaiser+0xd8>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm1
movsd  0xe8b(%rip),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  0xe72(%rip),%xmm1
subsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
cvtsi2sd %rax,%xmm1
movsd  0xe57(%rip),%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <besselI0@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <besselI0@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115a <kaiser+0x2a>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kaiser>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movsd  %xmm0,0x8(%rsp)
test   %esi,%esi
jle    11d6 <kaiser+0xa6>
mov    %rdi,%r14
lea    -0x1(%rsi),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %esi,%r15d
xor    %ebx,%ebx
nop
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
addsd  %xmm0,%xmm0
divsd  0x10(%rsp),%xmm0
addsd  0xe87(%rip),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0xe75(%rip),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
call   1050 <sqrt@plt>
mulsd  0x8(%rsp),%xmm0
call   1030 <besselI0@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <besselI0@plt>
movsd  0x18(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1160 <kaiser+0x30>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @kaiser(double* %0, i32 %1, double %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca double
store double* %0, double** %4
store i32 %1, i32* %5
store double %2, double* %6
%10 = load i32, i32* %5
%11 = sub nsw i32 %10, 1
%12 = sitofp i32 %11 to double
store double %12, double* %8
store i32 0, i32* %7
br label %13
13: ; preds = %40, %3
%14 = load i32, i32* %7
%15 = load i32, i32* %5
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %43
17: ; preds = %13
%18 = load double, double* %6
%19 = load i32, i32* %7
%20 = sitofp i32 %19 to double
%21 = fmul double 2.000000e+00, %20
%22 = load double, double* %8
%23 = fdiv double %21, %22
%24 = fsub double %23, 1.000000e+00
%25 = call i64 @pow(double %24, i32 2)
%26 = sitofp i64 %25 to double
%27 = fsub double 1.000000e+00, %26
%28 = fptosi double %27 to i64
%29 = call double @sqrt(i64 %28)
%30 = fmul double %18, %29
%31 = call double @besselI0(double %30)
store double %31, double* %9
%32 = load double, double* %9
%33 = load double, double* %6
%34 = call double @besselI0(double %33)
%35 = fdiv double %32, %34
%36 = load double*, double** %4
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %36, i64 %38
store double %35, double* %39
br label %40
40: ; preds = %17
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %13
43: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @kaiser(double* nocapture writeonly %0, i32 %1, double %2) {
%4 = add nsw i32 %1, -1
%5 = sitofp i32 %4 to double
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %28
7: ; preds = %3
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %26, %9 ]
%11 = trunc i64 %10 to i32
%12 = sitofp i32 %11 to double
%13 = fmul double %12, 2.000000e+00
%14 = fdiv double %13, %5
%15 = fadd double %14, -1.000000e+00
%16 = tail call i64 @pow(double %15, i32 2)
%17 = sitofp i64 %16 to double
%18 = fsub double 1.000000e+00, %17
%19 = fptosi double %18 to i64
%20 = tail call double @sqrt(i64 %19)
%21 = fmul double %20, %2
%22 = tail call double @besselI0(double %21)
%23 = tail call double @besselI0(double %2)
%24 = fdiv double %22, %23
%25 = getelementptr inbounds double, double* %0, i64 %10
store double %24, double* %25
%26 = add nuw nsw i64 %10, 1
%27 = icmp eq i64 %26, %8
br i1 %27, label %28, label %9
28: ; preds = %9, %3
ret void
}