#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);
scalar_t__ sqrt(int);
int llz_kaiser(double *w, const int N) {
  int i;
  double Ia, Ib;
  double beta = 8.96;
  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):
<llz_kaiser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    120f <llz_kaiser+0xef>
movsd  -0x28(%rbp),%xmm0
call   1030 <bessel@plt>
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x10(%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,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%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  0xe43(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movsd  -0x38(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
mulsd  %xmm1,%xmm0
call   1030 <bessel@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1143 <llz_kaiser+0x23>
mov    -0xc(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<llz_kaiser>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r14d
test   %esi,%esi
jle    11bf <llz_kaiser+0x9f>
mov    %rdi,%r15
lea    -0x1(%r14),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r14d,%r12d
xor    %ebx,%ebx
nopl   0x0(%rax)
movsd  0xea8(%rip),%xmm0
call   1030 <bessel@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movsd  %xmm0,0x10(%rsp)
addsd  %xmm1,%xmm1
divsd  0x8(%rsp),%xmm1
addsd  0xe8c(%rip),%xmm1
mulsd  %xmm1,%xmm1
movsd  0xe88(%rip),%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mulsd  0xe5b(%rip),%xmm0
call   1030 <bessel@plt>
divsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1150 <llz_kaiser+0x30>
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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