long double bdtrcl(k, n, p)
int k, n;
long double p;
{
  long double dk, dn;
  if ((p < 0.0L) || (p > 1.0L))
    goto domerr;
  if (k < 0)
    return (1.0L);
  if (n < k) {
  domerr:
    mtherr("bdtrcl", 1);
    return (0.0L);
  }
  if (k == n)
    return (0.0L);
  dn = n - k;
  if (k == 0) {
    if (p < .01L)
      dk = -expm1l(dn * log1pl(-p));
    else
      dk = 1.0L - powl(1.0L - p, dn);
  } else {
    dk = k + 1;
    dk = incbetl(dk, dn, p);
  }
  return (dk);
}


x86 assembly (clang, -O0):
<bdtrcl>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
fldt   0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    %esi,-0x18(%rbp)
fstpt  -0x30(%rbp)
fldt   -0x30(%rbp)
fldz
fucomip %st(1),%st
fstp   %st(0)
ja     1191 <bdtrcl+0x41>
jmp    117b <bdtrcl+0x2b>
fldt   -0x30(%rbp)
fld1
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    1196 <bdtrcl+0x46>
jmp    1191 <bdtrcl+0x41>
jmp    11bb <bdtrcl+0x6b>
cmpl   $0x0,-0x14(%rbp)
jge    11aa <bdtrcl+0x5a>
fld1
fstpt  -0x10(%rbp)
jmp    12b1 <bdtrcl+0x161>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d8 <bdtrcl+0x88>
jmp    11bb <bdtrcl+0x6b>
lea    0xe4e(%rip),%rdi
xor    %eax,%eax
mov    $0x1,%esi
call   1070 <mtherr@plt>
fldz
fstpt  -0x10(%rbp)
jmp    12b1 <bdtrcl+0x161>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    11ee <bdtrcl+0x9e>
fldz
fstpt  -0x10(%rbp)
jmp    12b1 <bdtrcl+0x161>
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x54(%rbp)
fildl  -0x54(%rbp)
fstpt  -0x50(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1278 <bdtrcl+0x128>
fldt   -0x30(%rbp)
fldt   0xdee(%rip)
fucomip %st(1),%st
fstp   %st(0)
jbe    124f <bdtrcl+0xff>
jmp    1221 <bdtrcl+0xd1>
fldt   -0x50(%rbp)
fstpt  -0x68(%rbp)
fldt   -0x30(%rbp)
fchs
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <log1pl@plt>
fldt   -0x68(%rbp)
fmulp  %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
call   1060 <expm1l@plt>
fchs
fstpt  -0x40(%rbp)
jmp    1273 <bdtrcl+0x123>
fldt   -0x30(%rbp)
fld1
fld    %st(0)
fstpt  -0x74(%rbp)
fsubp  %st,%st(1)
fldt   -0x50(%rbp)
mov    %rsp,%rax
fstpt  0x10(%rax)
fstpt  (%rax)
call   1030 <powl@plt>
fldt   -0x74(%rbp)
fsubp  %st,%st(1)
fstpt  -0x40(%rbp)
jmp    12ab <bdtrcl+0x15b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
fildl  -0x5c(%rbp)
fstpt  -0x40(%rbp)
fldt   -0x40(%rbp)
fldt   -0x50(%rbp)
fldt   -0x30(%rbp)
mov    %rsp,%rax
fstpt  0x20(%rax)
fstpt  0x10(%rax)
fstpt  (%rax)
xor    %eax,%eax
call   1050 <incbetl@plt>
mov    %eax,-0x58(%rbp)
fildl  -0x58(%rbp)
fstpt  -0x40(%rbp)
fldt   -0x40(%rbp)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bdtrcl>:
sub    $0x48,%rsp
fldt   0x50(%rsp)
fldz
fucomi %st(1),%st
fldz
ja     1182 <bdtrcl+0x32>
fstp   %st(0)
fld1
fxch   %st(2)
fucomi %st(2),%st
fxch   %st(2)
ja     1182 <bdtrcl+0x32>
test   %edi,%edi
fxch   %st(2)
fxch   %st(1)
js     11a5 <bdtrcl+0x55>
fstp   %st(2)
sub    %edi,%esi
fldz
fxch   %st(1)
fxch   %st(2)
fxch   %st(1)
jge    11ae <bdtrcl+0x5e>
fstp   %st(2)
fstp   %st(1)
lea    0xe83(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
fstpt  0x30(%rsp)
call   1070 <mtherr@plt>
fldt   0x30(%rsp)
fldz
fldz
fstp   %st(1)
fstp   %st(0)
add    $0x48,%rsp
ret
fstp   %st(0)
fldz
fxch   %st(1)
fxch   %st(2)
fxch   %st(1)
je     11a5 <bdtrcl+0x55>
fstp   %st(2)
fstp   %st(1)
mov    %esi,0x44(%rsp)
fildl  0x44(%rsp)
test   %edi,%edi
je     11f3 <bdtrcl+0xa3>
add    $0x1,%edi
mov    %edi,0x3c(%rsp)
fildl  0x3c(%rsp)
fxch   %st(2)
fstpt  0x20(%rsp)
fstpt  0x10(%rsp)
fstpt  (%rsp)
xor    %eax,%eax
call   1050 <incbetl@plt>
mov    %eax,0x40(%rsp)
fildl  0x40(%rsp)
jmp    11a1 <bdtrcl+0x51>
fldt   0xe07(%rip)
fucomip %st(2),%st
jbe    121f <bdtrcl+0xcf>
fxch   %st(1)
fchs
fstpt  (%rsp)
fstpt  0x30(%rsp)
call   1040 <log1pl@plt>
fldt   0x30(%rsp)
fmulp  %st,%st(1)
fstpt  (%rsp)
call   1060 <expm1l@plt>
fchs
jmp    11a1 <bdtrcl+0x51>
fld1
fld    %st(0)
fstpt  0x30(%rsp)
fsubp  %st,%st(2)
fstpt  0x10(%rsp)
fstpt  (%rsp)
call   1030 <powl@plt>
fldt   0x30(%rsp)
fsubp  %st,%st(1)
jmp    11a1 <bdtrcl+0x51>

LLVM IR (-O0):
@.str = [7 x i8] c"bdtrcl\00"
define x86_fp80 @bdtrcl(i32 %0, i32 %1, x86_fp80 %2) {
%4 = alloca x86_fp80
%5 = alloca i32
%6 = alloca i32
%7 = alloca x86_fp80
%8 = alloca x86_fp80
%9 = alloca x86_fp80
store i32 %0, i32* %5
store i32 %1, i32* %6
store x86_fp80 %2, x86_fp80* %7
%10 = load x86_fp80, x86_fp80* %7
%11 = fcmp olt x86_fp80 %10, 0xK00000000000000000000
br i1 %11, label %15, label %12
12: ; preds = %3
%13 = load x86_fp80, x86_fp80* %7
%14 = fcmp ogt x86_fp80 %13, 0xK3FFF8000000000000000
br i1 %14, label %15, label %16
15: ; preds = %12, %3
br label %25
16: ; preds = %12
%17 = load i32, i32* %5
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %16
store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %4
br label %68
20: ; preds = %16
%21 = load i32, i32* %6
%22 = load i32, i32* %5
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %27
24: ; preds = %20
br label %25
25: ; preds = %24, %15
%26 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @mtherr to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 1)
store x86_fp80 0xK00000000000000000000, x86_fp80* %4
br label %68
27: ; preds = %20
%28 = load i32, i32* %5
%29 = load i32, i32* %6
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %32
31: ; preds = %27
store x86_fp80 0xK00000000000000000000, x86_fp80* %4
br label %68
32: ; preds = %27
%33 = load i32, i32* %6
%34 = load i32, i32* %5
%35 = sub nsw i32 %33, %34
%36 = sitofp i32 %35 to x86_fp80
store x86_fp80 %36, x86_fp80* %9
%37 = load i32, i32* %5
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %57
39: ; preds = %32
%40 = load x86_fp80, x86_fp80* %7
%41 = fcmp olt x86_fp80 %40, 0xK3FF8A3D70A3D70A3D70A
br i1 %41, label %42, label %50
42: ; preds = %39
%43 = load x86_fp80, x86_fp80* %9
%44 = load x86_fp80, x86_fp80* %7
%45 = fneg x86_fp80 %44
%46 = call x86_fp80 @log1pl(x86_fp80 %45)
%47 = fmul x86_fp80 %43, %46
%48 = call x86_fp80 @expm1l(x86_fp80 %47)
%49 = fneg x86_fp80 %48
store x86_fp80 %49, x86_fp80* %8
br label %56
50: ; preds = %39
%51 = load x86_fp80, x86_fp80* %7
%52 = fsub x86_fp80 0xK3FFF8000000000000000, %51
%53 = load x86_fp80, x86_fp80* %9
%54 = call x86_fp80 @powl(x86_fp80 %52, x86_fp80 %53)
%55 = fsub x86_fp80 0xK3FFF8000000000000000, %54
store x86_fp80 %55, x86_fp80* %8
br label %56
56: ; preds = %50, %42
br label %66
57: ; preds = %32
%58 = load i32, i32* %5
%59 = add nsw i32 %58, 1
%60 = sitofp i32 %59 to x86_fp80
store x86_fp80 %60, x86_fp80* %8
%61 = load x86_fp80, x86_fp80* %8
%62 = load x86_fp80, x86_fp80* %9
%63 = load x86_fp80, x86_fp80* %7
%64 = call i32 (x86_fp80, x86_fp80, x86_fp80, ...) bitcast (i32 (...)* @incbetl to i32 (x86_fp80, x86_fp80, x86_fp80, ...)*)(x86_fp80 %61, x86_fp80 %62, x86_fp80 %63)
%65 = sitofp i32 %64 to x86_fp80
store x86_fp80 %65, x86_fp80* %8
br label %66
66: ; preds = %57, %56
%67 = load x86_fp80, x86_fp80* %8
store x86_fp80 %67, x86_fp80* %4
br label %68
68: ; preds = %66, %31, %25, %19
%69 = load x86_fp80, x86_fp80* %4
ret x86_fp80 %69
}

LLVM IR (-O2):
@.str = [7 x i8] c"bdtrcl\00"
define x86_fp80 @bdtrcl(i32 %0, i32 %1, x86_fp80 %2) {
%4 = fcmp olt x86_fp80 %2, 0xK00000000000000000000
%5 = fcmp ogt x86_fp80 %2, 0xK3FFF8000000000000000
%6 = or i1 %4, %5
br i1 %6, label %11, label %7
7: ; preds = %3
%8 = icmp slt i32 %0, 0
br i1 %8, label %36, label %9
9: ; preds = %7
%10 = icmp slt i32 %1, %0
br i1 %10, label %11, label %13
11: ; preds = %9, %3
%12 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @mtherr to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 1)
br label %36
13: ; preds = %9
%14 = icmp eq i32 %1, %0
br i1 %14, label %36, label %15
15: ; preds = %13
%16 = sub nsw i32 %1, %0
%17 = sitofp i32 %16 to x86_fp80
%18 = icmp eq i32 %0, 0
br i1 %18, label %19, label %31
19: ; preds = %15
%20 = fcmp olt x86_fp80 %2, 0xK3FF8A3D70A3D70A3D70A
br i1 %20, label %21, label %27
21: ; preds = %19
%22 = fneg x86_fp80 %2
%23 = tail call x86_fp80 @log1pl(x86_fp80 %22)
%24 = fmul x86_fp80 %23, %17
%25 = tail call x86_fp80 @expm1l(x86_fp80 %24)
%26 = fneg x86_fp80 %25
br label %36
27: ; preds = %19
%28 = fsub x86_fp80 0xK3FFF8000000000000000, %2
%29 = tail call x86_fp80 @powl(x86_fp80 %28, x86_fp80 %17)
%30 = fsub x86_fp80 0xK3FFF8000000000000000, %29
br label %36
31: ; preds = %15
%32 = add nuw nsw i32 %0, 1
%33 = sitofp i32 %32 to x86_fp80
%34 = tail call i32 (x86_fp80, x86_fp80, x86_fp80, ...) bitcast (i32 (...)* @incbetl to i32 (x86_fp80, x86_fp80, x86_fp80, ...)*)(x86_fp80 %33, x86_fp80 %17, x86_fp80 %2)
%35 = sitofp i32 %34 to x86_fp80
br label %36
36: ; preds = %31, %27, %21, %13, %7, %11
%37 = phi x86_fp80 [ 0xK00000000000000000000, %11 ], [ 0xK3FFF8000000000000000, %7 ], [ 0xK00000000000000000000, %13 ], [ %26, %21 ], [ %30, %27 ], [ %35, %31 ]
ret x86_fp80 %37
}