#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 bessel(double const);
scalar_t__ sqrt(int);
int kaiser_beta(double *w, const int N, const double beta) {
  int i;
  double Ia, Ib;
  for (i = 0; i < N; i++) {
    double x;
    Ib = bessel(beta);
    x = (double)((2. * i / (N - 1)) - 1);
    Ia = bessel(beta * (double)sqrt(1. - x * x));
    w[i] = (double)(Ia / Ib);
  }
  return N;
}


x86 assembly (clang, -O0):
<kaiser_beta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1207 <kaiser_beta+0xe7>
movsd  -0x18(%rbp),%xmm0
call   1030 <bessel@plt>
movsd  %xmm0,-0x30(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm1
movsd  0xea5(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  0xe83(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%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  0xe43(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movsd  -0x40(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
mulsd  %xmm1,%xmm0
call   1030 <bessel@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
divsd  -0x30(%rbp),%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    113b <kaiser_beta+0x1b>
mov    -0xc(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kaiser_beta>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r14d
test   %esi,%esi
jle    11c9 <kaiser_beta+0xa9>
mov    %rdi,%r15
lea    -0x1(%r14),%eax
cvtsi2sd %eax,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %r14d,%r12d
xor    %ebx,%ebx
movsd  %xmm0,(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%rsp),%xmm0
call   1030 <bessel@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movsd  %xmm0,0x10(%rsp)
addsd  %xmm1,%xmm1
divsd  0x8(%rsp),%xmm1
addsd  0xe77(%rip),%xmm1
mulsd  %xmm1,%xmm1
movsd  0xe73(%rip),%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mulsd  (%rsp),%xmm0
call   1030 <bessel@plt>
divsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1160 <kaiser_beta+0x40>
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @kaiser_beta(double* nocapture writeonly %0, i32 returned %1, double %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %28
5: ; preds = %3
%6 = add nsw i32 %1, -1
%7 = sitofp i32 %6 to double
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %5, %9
%10 = phi i64 [ 0, %5 ], [ %26, %9 ]
%11 = tail call double @bessel(double %2)
%12 = trunc i64 %10 to i32
%13 = sitofp i32 %12 to double
%14 = fmul double %13, 2.000000e+00
%15 = fdiv double %14, %7
%16 = fadd double %15, -1.000000e+00
%17 = fneg double %16
%18 = tail call double @llvm.fmuladd.f64(double %17, double %16, double 1.000000e+00)
%19 = fptosi double %18 to i32
%20 = tail call i64 @sqrt(i32 %19)
%21 = sitofp i64 %20 to double
%22 = fmul double %21, %2
%23 = tail call double @bessel(double %22)
%24 = fdiv double %23, %11
%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 i32 %1
}