#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 */
typedef int uintmax_t;
typedef int uint_fast64_t;

/* Variables and functions */
int /*<<< orphan*/ isfinite(long double);
int powl(long double, int);
long double bessi0_exact(long double x, long double tol) {
  long double acum, term;
  register uint_fast64_t i;
  uintmax_t factorial = 1;
  acum = 1;
  term = 1;
  i = 1;
  while (term > tol) {
    factorial *= i;
    term = powl(x / 2.0, 2 * i) / (factorial * factorial);
    if (!isfinite(term))
      break;
    acum += term;
    i++;
  }
  return acum;
}


x86 assembly (clang, -O0):
<bessi0_exact>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
fldt   0x20(%rbp)
fldt   0x10(%rbp)
fstpt  -0x10(%rbp)
fstpt  -0x20(%rbp)
movl   $0x1,-0x48(%rbp)
fld1
fld    %st(0)
fstpt  -0x30(%rbp)
fstpt  -0x40(%rbp)
movl   $0x1,-0x44(%rbp)
fldt   -0x40(%rbp)
fldt   -0x20(%rbp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    11cf <bessi0_exact+0xaf>
jmp    1163 <bessi0_exact+0x43>
mov    -0x44(%rbp),%ecx
mov    -0x48(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x48(%rbp)
fldt   -0x10(%rbp)
flds   0xe88(%rip)
fdivrp %st,%st(1)
mov    -0x44(%rbp),%edi
add    %edi,%edi
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <powl@plt>
mov    -0x48(%rbp),%ecx
imul   %ecx,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4c(%rbp)
fildl  -0x4c(%rbp)
fstpt  -0x40(%rbp)
fldt   -0x40(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <isfinite@plt>
cmp    $0x0,%eax
jne    11b6 <bessi0_exact+0x96>
jmp    11cf <bessi0_exact+0xaf>
fldt   -0x40(%rbp)
fldt   -0x30(%rbp)
faddp  %st,%st(1)
fstpt  -0x30(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    114c <bessi0_exact+0x2c>
fldt   -0x30(%rbp)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bessi0_exact>:
push   %rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
fldt   0x80(%rsp)
fldt   0x70(%rsp)
fld1
fld    %st(2)
fstpt  0x38(%rsp)
fucomi %st(2),%st
fstp   %st(2)
jbe    11d1 <bessi0_exact+0xb1>
fstp   %st(1)
fmuls  0xeb3(%rip)
fstpt  0x2c(%rsp)
fld1
mov    $0x1,%ebp
mov    $0x2,%r14d
mov    $0x1,%ebx
fldz
cs nopw 0x0(%rax,%rax,1)
nop
fstp   %st(0)
fstpt  0x20(%rsp)
imul   %ebx,%ebp
fldt   0x2c(%rsp)
fstpt  (%rsp)
mov    %r14d,%edi
call   1030 <powl@plt>
mov    %ebp,%ecx
imul   %ebp,%ecx
cltd
idiv   %ecx
mov    %eax,0x1c(%rsp)
fildl  0x1c(%rsp)
fld    %st(0)
fstpt  0x44(%rsp)
fstpt  (%rsp)
call   1040 <isfinite@plt>
test   %eax,%eax
je     11cb <bessi0_exact+0xab>
fldt   0x20(%rsp)
fldt   0x44(%rsp)
fadd   %st,%st(1)
add    $0x1,%ebx
add    $0x2,%r14d
fldt   0x38(%rsp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
fldz
ja     1170 <bessi0_exact+0x50>
jmp    11d1 <bessi0_exact+0xb1>
fldt   0x20(%rsp)
fldz
fstp   %st(0)
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define x86_fp80 @bessi0_exact(x86_fp80 %0, x86_fp80 %1) {
%3 = alloca x86_fp80
%4 = alloca x86_fp80
%5 = alloca x86_fp80
%6 = alloca x86_fp80
%7 = alloca i32
%8 = alloca i32
store x86_fp80 %0, x86_fp80* %3
store x86_fp80 %1, x86_fp80* %4
store i32 1, i32* %8
store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %5
store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %6
store i32 1, i32* %7
br label %9
9: ; preds = %31, %2
%10 = load x86_fp80, x86_fp80* %6
%11 = load x86_fp80, x86_fp80* %4
%12 = fcmp ogt x86_fp80 %10, %11
br i1 %12, label %13, label %37
13: ; preds = %9
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = mul nsw i32 %15, %14
store i32 %16, i32* %8
%17 = load x86_fp80, x86_fp80* %3
%18 = fdiv x86_fp80 %17, 0xK40008000000000000000
%19 = load i32, i32* %7
%20 = mul nsw i32 2, %19
%21 = call i32 @powl(x86_fp80 %18, i32 %20)
%22 = load i32, i32* %8
%23 = load i32, i32* %8
%24 = mul nsw i32 %22, %23
%25 = sdiv i32 %21, %24
%26 = sitofp i32 %25 to x86_fp80
store x86_fp80 %26, x86_fp80* %6
%27 = load x86_fp80, x86_fp80* %6
%28 = call i32 @isfinite(x86_fp80 %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %31, label %30
30: ; preds = %13
br label %37
31: ; preds = %13
%32 = load x86_fp80, x86_fp80* %6
%33 = load x86_fp80, x86_fp80* %5
%34 = fadd x86_fp80 %33, %32
store x86_fp80 %34, x86_fp80* %5
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %9
37: ; preds = %30, %9
%38 = load x86_fp80, x86_fp80* %5
ret x86_fp80 %38
}

LLVM IR (-O2):
define x86_fp80 @bessi0_exact(x86_fp80 %0, x86_fp80 %1) {
%3 = fcmp olt x86_fp80 %1, 0xK3FFF8000000000000000
br i1 %3, label %4, label %22
4: ; preds = %2
%5 = fmul x86_fp80 %0, 0xK3FFE8000000000000000
br label %6
6: ; preds = %4, %18
%7 = phi i32 [ 1, %4 ], [ %10, %18 ]
%8 = phi i32 [ 1, %4 ], [ %20, %18 ]
%9 = phi x86_fp80 [ 0xK3FFF8000000000000000, %4 ], [ %19, %18 ]
%10 = mul nsw i32 %7, %8
%11 = shl nuw nsw i32 %8, 1
%12 = tail call i32 @powl(x86_fp80 %5, i32 %11)
%13 = mul nsw i32 %10, %10
%14 = sdiv i32 %12, %13
%15 = sitofp i32 %14 to x86_fp80
%16 = tail call i32 @isfinite(x86_fp80 %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %6
%19 = fadd x86_fp80 %9, %15
%20 = add nuw nsw i32 %8, 1
%21 = fcmp ogt x86_fp80 %15, %1
br i1 %21, label %6, label %22
22: ; preds = %18, %6, %2
%23 = phi x86_fp80 [ 0xK3FFF8000000000000000, %2 ], [ %9, %6 ], [ %19, %18 ]
ret x86_fp80 %23
}