#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 bessel0(double);
double sqrt(double);
double kaiser(int i, int n, double beta) {
  double a, w, a2, b1, b2, beta1;
  b1 = bessel0(beta);
  a = 2.0 * i / (double)(n - 1) - 1.0;
  a2 = a * a;
  beta1 = beta * sqrt(1.0 - a2);
  b2 = bessel0(beta1);
  w = b2 / b1;
  return (w);
}


x86 assembly (clang, -O0):
<kaiser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <bessel0@plt>
movsd  %xmm0,-0x30(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xeb9(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  0xe97(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe6d(%rip),%xmm0
subsd  -0x28(%rbp),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <bessel0@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kaiser>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
movsd  %xmm0,0x10(%rsp)
call   1030 <bessel0@plt>
movsd  %xmm0,0x8(%rsp)
cvtsi2sd %ebp,%xmm1
addsd  %xmm1,%xmm1
add    $0xffffffff,%ebx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
divsd  %xmm0,%xmm1
addsd  0xea7(%rip),%xmm1
mulsd  %xmm1,%xmm1
movsd  0xea3(%rip),%xmm0
subsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1179 <kaiser+0x59>
sqrtsd %xmm0,%xmm0
jmp    117e <kaiser+0x5e>
call   1040 <sqrt@plt>
mulsd  0x10(%rsp),%xmm0
call   1030 <bessel0@plt>
divsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @kaiser(i32 %0, i32 %1, double %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store i32 %0, i32* %4
store i32 %1, i32* %5
store double %2, double* %6
%13 = load double, double* %6
%14 = call double @bessel0(double %13)
store double %14, double* %10
%15 = load i32, i32* %4
%16 = sitofp i32 %15 to double
%17 = fmul double 2.000000e+00, %16
%18 = load i32, i32* %5
%19 = sub nsw i32 %18, 1
%20 = sitofp i32 %19 to double
%21 = fdiv double %17, %20
%22 = fsub double %21, 1.000000e+00
store double %22, double* %7
%23 = load double, double* %7
%24 = load double, double* %7
%25 = fmul double %23, %24
store double %25, double* %9
%26 = load double, double* %6
%27 = load double, double* %9
%28 = fsub double 1.000000e+00, %27
%29 = call double @sqrt(double %28)
%30 = fmul double %26, %29
store double %30, double* %12
%31 = load double, double* %12
%32 = call double @bessel0(double %31)
store double %32, double* %11
%33 = load double, double* %11
%34 = load double, double* %10
%35 = fdiv double %33, %34
store double %35, double* %8
%36 = load double, double* %8
ret double %36
}

LLVM IR (-O2):
define double @kaiser(i32 %0, i32 %1, double %2) {
%4 = tail call double @bessel0(double %2)
%5 = sitofp i32 %0 to double
%6 = fmul double %5, 2.000000e+00
%7 = add nsw i32 %1, -1
%8 = sitofp i32 %7 to double
%9 = fdiv double %6, %8
%10 = fadd double %9, -1.000000e+00
%11 = fmul double %10, %10
%12 = fsub double 1.000000e+00, %11
%13 = tail call double @sqrt(double %12)
%14 = fmul double %13, %2
%15 = tail call double @bessel0(double %14)
%16 = fdiv double %15, %4
ret double %16
}