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


x86 assembly (clang, -O0):
<fa_kaiser_beta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movss  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f4 <fa_kaiser_beta+0xd4>
movss  -0x10(%rbp),%xmm0
call   1030 <bessel@plt>
movss  %xmm0,-0x1c(%rbp)
cvtsi2sdl -0x14(%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
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x20(%rbp),%xmm0
mulss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe56(%rip),%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movss  -0x24(%rbp),%xmm0
cvtsi2ss %rax,%xmm1
mulss  %xmm1,%xmm0
call   1030 <bessel@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
divss  -0x1c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113b <fa_kaiser_beta+0x1b>
mov    -0xc(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fa_kaiser_beta>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r14d
test   %esi,%esi
jle    11d3 <fa_kaiser_beta+0xb3>
mov    %rdi,%r15
lea    -0x1(%r14),%eax
cvtsi2sd %eax,%xmm1
movsd  %xmm1,0x10(%rsp)
mov    %r14d,%r12d
xor    %ebx,%ebx
movss  %xmm0,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movss  0x8(%rsp),%xmm0
call   1030 <bessel@plt>
movss  %xmm0,0xc(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
addsd  %xmm0,%xmm0
divsd  0x10(%rsp),%xmm0
addsd  0xe76(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
mulss  %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe6a(%rip),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mulss  0x8(%rsp),%xmm0
call   1030 <bessel@plt>
divss  0xc(%rsp),%xmm0
movss  %xmm0,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1160 <fa_kaiser_beta+0x40>
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @fa_kaiser_beta(float* %0, i32 %1, float %2) {
%4 = alloca float*
%5 = alloca i32
%6 = alloca float
%7 = alloca i32
%8 = alloca float
%9 = alloca float
%10 = alloca float
store float* %0, float** %4
store i32 %1, i32* %5
store float %2, float* %6
store i32 0, i32* %7
br label %11
11: ; preds = %45, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %48
15: ; preds = %11
%16 = load float, float* %6
%17 = call float @bessel(float %16)
store float %17, float* %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
%26 = fptrunc double %25 to float
store float %26, float* %10
%27 = load float, float* %6
%28 = load float, float* %10
%29 = load float, float* %10
%30 = fmul float %28, %29
%31 = fpext float %30 to double
%32 = fsub double 1.000000e+00, %31
%33 = fptosi double %32 to i32
%34 = call i64 @sqrt(i32 %33)
%35 = sitofp i64 %34 to float
%36 = fmul float %27, %35
%37 = call float @bessel(float %36)
store float %37, float* %8
%38 = load float, float* %8
%39 = load float, float* %9
%40 = fdiv float %38, %39
%41 = load float*, float** %4
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds float, float* %41, i64 %43
store float %40, float* %44
br label %45
45: ; preds = %15
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %11
48: ; preds = %11
%49 = load i32, i32* %5
ret i32 %49
}

LLVM IR (-O2):
define i32 @fa_kaiser_beta(float* nocapture writeonly %0, i32 returned %1, float %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %30
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 ], [ %28, %9 ]
%11 = tail call float @bessel(float %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 = fptrunc double %16 to float
%18 = fmul float %17, %17
%19 = fpext float %18 to double
%20 = fsub double 1.000000e+00, %19
%21 = fptosi double %20 to i32
%22 = tail call i64 @sqrt(i32 %21)
%23 = sitofp i64 %22 to float
%24 = fmul float %23, %2
%25 = tail call float @bessel(float %24)
%26 = fdiv float %25, %11
%27 = getelementptr inbounds float, float* %0, i64 %10
store float %26, float* %27
%28 = add nuw nsw i64 %10, 1
%29 = icmp eq i64 %28, %8
br i1 %29, label %30, label %9
30: ; preds = %9, %3
ret i32 %1
}