#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 BesselI_0(double const);
double MaxDouble(double, double);
double const sqrt(double);
double Kaiser(const double b, const double k) {
  double k2;
  if ((k < -1.0) || (k > 1.0))
    return 0.0;
  k2 = MaxDouble(1.0 - (k * k), 0.0);
  return BesselI_0(b * sqrt(k2)) / BesselI_0(b);
}


x86 assembly (clang, -O0):
<Kaiser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  0xeb6(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
ja     116c <Kaiser+0x3c>
movsd  -0x18(%rbp),%xmm0
movsd  0xea6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1179 <Kaiser+0x49>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11fc <Kaiser+0xcc>
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe62(%rip),%xmm1
addsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
call   1030 <MaxDouble@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <BesselI_0@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <BesselI_0@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Kaiser>:
sub    $0x18,%rsp
movsd  %xmm0,0x8(%rsp)
movsd  0xebe(%rip),%xmm0
ucomisd %xmm1,%xmm0
xorpd  %xmm0,%xmm0
ja     11ae <Kaiser+0x7e>
ucomisd 0xeb4(%rip),%xmm1
ja     11ae <Kaiser+0x7e>
mulsd  %xmm1,%xmm1
movsd  0xea6(%rip),%xmm0
subsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
call   1030 <MaxDouble@plt>
ucomisd 0xe99(%rip),%xmm0
jb     117f <Kaiser+0x4f>
sqrtsd %xmm0,%xmm0
jmp    1184 <Kaiser+0x54>
call   1050 <sqrt@plt>
mulsd  0x8(%rsp),%xmm0
call   1040 <BesselI_0@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <BesselI_0@plt>
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @Kaiser(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %4
store double %1, double* %5
%7 = load double, double* %5
%8 = fcmp olt double %7, -1.000000e+00
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load double, double* %5
%11 = fcmp ogt double %10, 1.000000e+00
br i1 %11, label %12, label %13
12: ; preds = %9, %2
store double 0.000000e+00, double* %3
br label %27
13: ; preds = %9
%14 = load double, double* %5
%15 = load double, double* %5
%16 = fneg double %14
%17 = call double @llvm.fmuladd.f64(double %16, double %15, double 1.000000e+00)
%18 = call double @MaxDouble(double %17, double 0.000000e+00)
store double %18, double* %6
%19 = load double, double* %4
%20 = load double, double* %6
%21 = call double @sqrt(double %20)
%22 = fmul double %19, %21
%23 = call double @BesselI_0(double %22)
%24 = load double, double* %4
%25 = call double @BesselI_0(double %24)
%26 = fdiv double %23, %25
store double %26, double* %3
br label %27
27: ; preds = %13, %12
%28 = load double, double* %3
ret double %28
}

LLVM IR (-O2):
define double @Kaiser(double %0, double %1) {
%3 = fcmp olt double %1, -1.000000e+00
%4 = fcmp ogt double %1, 1.000000e+00
%5 = or i1 %3, %4
br i1 %5, label %15, label %6
6: ; preds = %2
%7 = fneg double %1
%8 = tail call double @llvm.fmuladd.f64(double %7, double %1, double 1.000000e+00)
%9 = tail call double @MaxDouble(double %8, double 0.000000e+00)
%10 = tail call double @sqrt(double %9)
%11 = fmul double %10, %0
%12 = tail call double @BesselI_0(double %11)
%13 = tail call double @BesselI_0(double %0)
%14 = fdiv double %12, %13
br label %15
15: ; preds = %2, %6
%16 = phi double [ %14, %6 ], [ 0.000000e+00, %2 ]
ret double %16
}