double bessi(nn, x)
double x;
double nn;
{
  int j, n;
  double bi, bim, bip, tox, ans;
  n = (int)nn;
  if (n == 0)
    return bessi0(x);
  if (n == 1)
    return bessi1(x);
  if (x == 0.0)
    return 0.0;
  else {
    tox = 2.0 / fabs(x);
    bip = ans = 0.0;
    bi = 1.0;
    for (j = 2 * (n + (int)sqrt(40.0 * n)); j > 0; j--) {
      bim = bip + j * tox * bi;
      bip = bi;
      bi = bim;
      if (fabs(bi) > 1.0e10) {
        ans *= 1.0e-10;
        bi *= 1.0e-10;
        bip *= 1.0e-10;
      }
      if (j == n)
        ans = bip;
    }
    ans *= bessi0(x) / bi;
    return x < 0.0 && (n & 1) ? -ans : ans;
  }
}


x86 assembly (clang, -O0):
<bessi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
cvttsd2si -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    116e <bessi+0x3e>
movsd  -0x18(%rbp),%xmm0
mov    $0x1,%al
call   1040 <bessi0@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1356 <bessi+0x226>
cmpl   $0x1,-0x20(%rbp)
jne    1192 <bessi+0x62>
movsd  -0x18(%rbp),%xmm0
mov    $0x1,%al
call   1030 <bessi1@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1356 <bessi+0x226>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11b7 <bessi+0x87>
jp     11b7 <bessi+0x87>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1356 <bessi+0x226>
movsd  -0x18(%rbp),%xmm1
movaps 0xe6d(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xe41(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe18(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x4c(%rbp)
cvtsi2sdl -0x20(%rbp),%xmm1
movsd  0xdf8(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
mov    -0x4c(%rbp),%eax
cvttsd2si %xmm0,%ecx
add    %ecx,%eax
shl    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    12e0 <bessi+0x1b0>
movsd  -0x38(%rbp),%xmm1
cvtsi2sdl -0x1c(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movaps 0xdc5(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xda1(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12b7 <bessi+0x187>
movsd  0xd97(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xd85(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xd73(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    12cd <bessi+0x19d>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    12d2 <bessi+0x1a2>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1220 <bessi+0xf0>
movsd  -0x18(%rbp),%xmm0
mov    $0x1,%al
call   1040 <bessi0@plt>
cvtsi2sd %eax,%xmm0
divsd  -0x28(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1342 <bessi+0x212>
mov    -0x20(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1342 <bessi+0x212>
movsd  -0x48(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    134c <bessi+0x21c>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bessi>:
push   %rbx
sub    $0x30,%rsp
cvttsd2si %xmm0,%ebx
cmp    $0x1,%ebx
je     1159 <bessi+0x29>
test   %ebx,%ebx
jne    1170 <bessi+0x40>
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1040 <bessi0@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
jmp    12df <bessi+0x1af>
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1030 <bessi1@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
jmp    12df <bessi+0x1af>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1180 <bessi+0x50>
jnp    12df <bessi+0x1af>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xe99(%rip),%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
movapd %xmm1,0x10(%rsp)
jb     11a5 <bessi+0x75>
sqrtsd %xmm0,%xmm0
jmp    11b4 <bessi+0x84>
call   1050 <sqrt@plt>
xorpd  %xmm2,%xmm2
movapd 0x10(%rsp),%xmm1
cvttsd2si %xmm0,%ecx
mov    %ecx,%eax
add    %ebx,%eax
jle    127d <bessi+0x14d>
movapd 0xe36(%rip),%xmm0
andpd  %xmm1,%xmm0
movsd  0xe49(%rip),%xmm9
divsd  %xmm0,%xmm9
add    %eax,%eax
lea    (%rbx,%rcx,2),%ecx
movsd  0xe47(%rip),%xmm0
xorpd  %xmm4,%xmm4
movapd 0xe0a(%rip),%xmm8
movsd  0xe39(%rip),%xmm10
movsd  0xe39(%rip),%xmm3
xorpd  %xmm6,%xmm6
jmp    1222 <bessi+0xf2>
nopl   (%rax)
lea    -0x1(%rax),%edx
movapd %xmm2,%xmm4
movapd %xmm7,%xmm0
cmp    $0x1,%eax
mov    %edx,%eax
jle    1285 <bessi+0x155>
xorps  %xmm7,%xmm7
cvtsi2sd %eax,%xmm7
mulsd  %xmm9,%xmm7
mulsd  %xmm0,%xmm7
addsd  %xmm6,%xmm7
movapd %xmm7,%xmm2
andpd  %xmm8,%xmm2
ucomisd %xmm10,%xmm2
jbe    124a <bessi+0x11a>
mulsd  %xmm3,%xmm7
jbe    1250 <bessi+0x120>
mulsd  %xmm3,%xmm4
movapd %xmm0,%xmm5
mulsd  %xmm3,%xmm5
movapd %xmm10,%xmm6
cmpltsd %xmm2,%xmm6
andpd  %xmm6,%xmm5
andnpd %xmm0,%xmm6
orpd   %xmm5,%xmm6
movapd %xmm6,%xmm2
sub    $0x1,%ecx
jb     1210 <bessi+0xe0>
movapd %xmm4,%xmm2
jmp    1210 <bessi+0xe0>
movsd  0xdab(%rip),%xmm7
movapd %xmm7,0x20(%rsp)
movsd  %xmm2,0x8(%rsp)
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1040 <bessi0@plt>
movapd 0x10(%rsp),%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0x20(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
cmpnltsd %xmm1,%xmm2
movapd %xmm2,%xmm1
andpd  %xmm0,%xmm1
test   $0x1,%bl
je     12d3 <bessi+0x1a3>
xorpd  0xd3d(%rip),%xmm0
andnpd %xmm0,%xmm2
orpd   %xmm1,%xmm2
movapd %xmm2,%xmm0
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @bessi(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store double %0, double* %4
store double %1, double* %5
%13 = load double, double* %4
%14 = fptosi double %13 to i32
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %2
%18 = load double, double* %5
%19 = call i32 (double, ...) bitcast (i32 (...)* @bessi0 to i32 (double, ...)*)(double %18)
%20 = sitofp i32 %19 to double
store double %20, double* %3
br label %98
21: ; preds = %2
%22 = load i32, i32* %7
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load double, double* %5
%26 = call i32 (double, ...) bitcast (i32 (...)* @bessi1 to i32 (double, ...)*)(double %25)
%27 = sitofp i32 %26 to double
store double %27, double* %3
br label %98
28: ; preds = %21
%29 = load double, double* %5
%30 = fcmp oeq double %29, 0.000000e+00
br i1 %30, label %31, label %32
31: ; preds = %28
store double 0.000000e+00, double* %3
br label %98
32: ; preds = %28
%33 = load double, double* %5
%34 = call double @llvm.fabs.f64(double %33)
%35 = fdiv double 2.000000e+00, %34
store double %35, double* %11
store double 0.000000e+00, double* %12
store double 0.000000e+00, double* %10
store double 1.000000e+00, double* %8
%36 = load i32, i32* %7
%37 = load i32, i32* %7
%38 = sitofp i32 %37 to double
%39 = fmul double 4.000000e+01, %38
%40 = call double @sqrt(double %39)
%41 = fptosi double %40 to i32
%42 = add nsw i32 %36, %41
%43 = mul nsw i32 2, %42
store i32 %43, i32* %6
br label %44
44: ; preds = %74, %32
%45 = load i32, i32* %6
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %77
47: ; preds = %44
%48 = load double, double* %10
%49 = load i32, i32* %6
%50 = sitofp i32 %49 to double
%51 = load double, double* %11
%52 = fmul double %50, %51
%53 = load double, double* %8
%54 = call double @llvm.fmuladd.f64(double %52, double %53, double %48)
store double %54, double* %9
%55 = load double, double* %8
store double %55, double* %10
%56 = load double, double* %9
store double %56, double* %8
%57 = load double, double* %8
%58 = call double @llvm.fabs.f64(double %57)
%59 = fcmp ogt double %58, 1.000000e+10
br i1 %59, label %60, label %67
60: ; preds = %47
%61 = load double, double* %12
%62 = fmul double %61, 1.000000e-10
store double %62, double* %12
%63 = load double, double* %8
%64 = fmul double %63, 1.000000e-10
store double %64, double* %8
%65 = load double, double* %10
%66 = fmul double %65, 1.000000e-10
store double %66, double* %10
br label %67
67: ; preds = %60, %47
%68 = load i32, i32* %6
%69 = load i32, i32* %7
%70 = icmp eq i32 %68, %69
br i1 %70, label %71, label %73
71: ; preds = %67
%72 = load double, double* %10
store double %72, double* %12
br label %73
73: ; preds = %71, %67
br label %74
74: ; preds = %73
%75 = load i32, i32* %6
%76 = add nsw i32 %75, -1
store i32 %76, i32* %6
br label %44
77: ; preds = %44
%78 = load double, double* %5
%79 = call i32 (double, ...) bitcast (i32 (...)* @bessi0 to i32 (double, ...)*)(double %78)
%80 = sitofp i32 %79 to double
%81 = load double, double* %8
%82 = fdiv double %80, %81
%83 = load double, double* %12
%84 = fmul double %83, %82
store double %84, double* %12
%85 = load double, double* %5
%86 = fcmp olt double %85, 0.000000e+00
br i1 %86, label %87, label %94
87: ; preds = %77
%88 = load i32, i32* %7
%89 = and i32 %88, 1
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %87
%92 = load double, double* %12
%93 = fneg double %92
br label %96
94: ; preds = %87, %77
%95 = load double, double* %12
br label %96
96: ; preds = %94, %91
%97 = phi double [ %93, %91 ], [ %95, %94 ]
store double %97, double* %3
br label %98
98: ; preds = %96, %31, %24, %17
%99 = load double, double* %3
ret double %99
}

LLVM IR (-O2):
define double @bessi(double %0, double %1) {
%3 = fptosi double %0 to i32
switch i32 %3, label %10 [
i32 0, label %4
i32 1, label %7
]
4: ; preds = %2
%5 = tail call i32 (double, ...) bitcast (i32 (...)* @bessi0 to i32 (double, ...)*)(double %1)
%6 = sitofp i32 %5 to double
br label %56
7: ; preds = %2
%8 = tail call i32 (double, ...) bitcast (i32 (...)* @bessi1 to i32 (double, ...)*)(double %1)
%9 = sitofp i32 %8 to double
br label %56
10: ; preds = %2
%11 = fcmp oeq double %1, 0.000000e+00
br i1 %11, label %56, label %12
12: ; preds = %10
%13 = tail call double @llvm.fabs.f64(double %1)
%14 = fdiv double 2.000000e+00, %13
%15 = sitofp i32 %3 to double
%16 = fmul double %15, 4.000000e+01
%17 = tail call double @sqrt(double %16)
%18 = fptosi double %17 to i32
%19 = add nsw i32 %18, %3
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %43
21: ; preds = %12
%22 = shl nuw nsw i32 %19, 1
br label %23
23: ; preds = %21, %23
%24 = phi double [ %40, %23 ], [ 0.000000e+00, %21 ]
%25 = phi double [ %37, %23 ], [ 0.000000e+00, %21 ]
%26 = phi i32 [ %41, %23 ], [ %22, %21 ]
%27 = phi double [ %36, %23 ], [ 1.000000e+00, %21 ]
%28 = sitofp i32 %26 to double
%29 = fmul double %14, %28
%30 = tail call double @llvm.fmuladd.f64(double %29, double %27, double %25)
%31 = tail call double @llvm.fabs.f64(double %30)
%32 = fcmp ogt double %31, 1.000000e+10
%33 = fmul double %24, 1.000000e-10
%34 = fmul double %30, 1.000000e-10
%35 = fmul double %27, 1.000000e-10
%36 = select i1 %32, double %34, double %30
%37 = select i1 %32, double %35, double %27
%38 = select i1 %32, double %33, double %24
%39 = icmp eq i32 %26, %3
%40 = select i1 %39, double %37, double %38
%41 = add nsw i32 %26, -1
%42 = icmp sgt i32 %26, 1
br i1 %42, label %23, label %43
43: ; preds = %23, %12
%44 = phi double [ 1.000000e+00, %12 ], [ %36, %23 ]
%45 = phi double [ 0.000000e+00, %12 ], [ %40, %23 ]
%46 = tail call i32 (double, ...) bitcast (i32 (...)* @bessi0 to i32 (double, ...)*)(double %1)
%47 = sitofp i32 %46 to double
%48 = fdiv double %47, %44
%49 = fmul double %45, %48
%50 = fcmp uge double %1, 0.000000e+00
%51 = and i32 %3, 1
%52 = icmp eq i32 %51, 0
%53 = select i1 %50, i1 true, i1 %52
%54 = fneg double %49
%55 = select i1 %53, double %49, double %54
br label %56
56: ; preds = %10, %43, %7, %4
%57 = phi double [ %6, %4 ], [ %9, %7 ], [ %55, %43 ], [ 0.000000e+00, %10 ]
ret double %57
}