#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 DBL_EPSILON;
double bessi0(double x) {
  double xh, sum, pow, ds;
  int k;
  xh = 0.5 * x;
  sum = 1.0;
  pow = 1.0;
  k = 0;
  ds = 1.0;
  while (ds > sum * DBL_EPSILON) {
    ++k;
    pow = pow * (xh / k);
    ds = pow * pow;
    sum = sum + ds;
  }
  return sum;
}


x86 assembly (clang, -O0):
<bessi0>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  0xef7(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xedd(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xed0(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
movsd  0xebc(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mov    0x2e8e(%rip),%rax
mulsd  (%rax),%xmm1
ucomisd %xmm1,%xmm0
jbe    11b0 <bessi0+0xb0>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
cvtsi2sdl -0x2c(%rbp),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1149 <bessi0+0x49>
movsd  -0x18(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<bessi0>:
mov    0x2ee1(%rip),%rax
movsd  (%rax),%xmm2
movsd  0xef5(%rip),%xmm1
ucomisd %xmm2,%xmm1
jbe    1170 <bessi0+0x70>
mulsd  0xedf(%rip),%xmm0
movsd  0xedf(%rip),%xmm3
mov    $0x1,%eax
movapd %xmm3,%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xorps  %xmm4,%xmm4
cvtsi2sd %eax,%xmm4
movapd %xmm0,%xmm5
divsd  %xmm4,%xmm5
mulsd  %xmm5,%xmm3
movapd %xmm3,%xmm4
mulsd  %xmm3,%xmm4
addsd  %xmm4,%xmm1
movapd %xmm1,%xmm5
mulsd  %xmm2,%xmm5
add    $0x1,%eax
ucomisd %xmm5,%xmm4
ja     1140 <bessi0+0x40>
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
@DBL_EPSILON = global double 0.000000e+00
define double @bessi0(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
store double %0, double* %2
%8 = load double, double* %2
%9 = fmul double 5.000000e-01, %8
store double %9, double* %3
store double 1.000000e+00, double* %4
store double 1.000000e+00, double* %5
store i32 0, i32* %7
store double 1.000000e+00, double* %6
br label %10
10: ; preds = %16, %1
%11 = load double, double* %6
%12 = load double, double* %4
%13 = load double, double* @DBL_EPSILON
%14 = fmul double %12, %13
%15 = fcmp ogt double %11, %14
br i1 %15, label %16, label %31
16: ; preds = %10
%17 = load i32, i32* %7
%18 = add nsw i32 %17, 1
store i32 %18, i32* %7
%19 = load double, double* %5
%20 = load double, double* %3
%21 = load i32, i32* %7
%22 = sitofp i32 %21 to double
%23 = fdiv double %20, %22
%24 = fmul double %19, %23
store double %24, double* %5
%25 = load double, double* %5
%26 = load double, double* %5
%27 = fmul double %25, %26
store double %27, double* %6
%28 = load double, double* %4
%29 = load double, double* %6
%30 = fadd double %28, %29
store double %30, double* %4
br label %10
31: ; preds = %10
%32 = load double, double* %4
ret double %32
}

LLVM IR (-O2):
@DBL_EPSILON = global double 0.000000e+00
define double @bessi0(double %0) {
%2 = fmul double %0, 5.000000e-01
%3 = load double, double* @DBL_EPSILON
%4 = fcmp olt double %3, 1.000000e+00
br i1 %4, label %5, label %17
5: ; preds = %1, %5
%6 = phi i32 [ %9, %5 ], [ 0, %1 ]
%7 = phi double [ %12, %5 ], [ 1.000000e+00, %1 ]
%8 = phi double [ %14, %5 ], [ 1.000000e+00, %1 ]
%9 = add nuw nsw i32 %6, 1
%10 = sitofp i32 %9 to double
%11 = fdiv double %2, %10
%12 = fmul double %7, %11
%13 = fmul double %12, %12
%14 = fadd double %8, %13
%15 = fmul double %14, %3
%16 = fcmp ogt double %13, %15
br i1 %16, label %5, label %17
17: ; preds = %5, %1
%18 = phi double [ 1.000000e+00, %1 ], [ %14, %5 ]
ret double %18
}