long double nbdtrl(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) {
  domerr:
    mtherr("nbdtrl", 1);
    return (0.0L);
  }
  dn = n;
  if (k == 0)
    return (powl(p, dn));
  dk = k + 1;
  return (incbetl(dn, dk, p));
}


x86 assembly (clang, -O0):
<nbdtrl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%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     1171 <nbdtrl+0x41>
jmp    115b <nbdtrl+0x2b>
fldt   -0x30(%rbp)
fld1
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    1176 <nbdtrl+0x46>
jmp    1171 <nbdtrl+0x41>
jmp    1185 <nbdtrl+0x55>
cmpl   $0x0,-0x14(%rbp)
jge    11a2 <nbdtrl+0x72>
jmp    1185 <nbdtrl+0x55>
lea    0xe74(%rip),%rdi
xor    %eax,%eax
mov    $0x1,%esi
call   1050 <mtherr@plt>
fldz
fstpt  -0x10(%rbp)
jmp    1206 <nbdtrl+0xd6>
mov    -0x18(%rbp),%eax
mov    %eax,-0x54(%rbp)
fildl  -0x54(%rbp)
fstpt  -0x50(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11d3 <nbdtrl+0xa3>
fldt   -0x30(%rbp)
fldt   -0x50(%rbp)
mov    %rsp,%rax
fstpt  0x10(%rax)
fstpt  (%rax)
call   1030 <powl@plt>
fstpt  -0x10(%rbp)
jmp    1206 <nbdtrl+0xd6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
fildl  -0x5c(%rbp)
fstpt  -0x40(%rbp)
fldt   -0x50(%rbp)
fldt   -0x40(%rbp)
fldt   -0x30(%rbp)
mov    %rsp,%rax
fstpt  0x20(%rax)
fstpt  0x10(%rax)
fstpt  (%rax)
xor    %eax,%eax
call   1040 <incbetl@plt>
mov    %eax,-0x58(%rbp)
fildl  -0x58(%rbp)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nbdtrl>:
sub    $0x48,%rsp
fldt   0x50(%rsp)
test   %edi,%edi
js     1184 <nbdtrl+0x54>
fldz
fucomip %st(1),%st
ja     1184 <nbdtrl+0x54>
fld1
fxch   %st(1)
fucomi %st(1),%st
fstp   %st(1)
ja     1184 <nbdtrl+0x54>
mov    %esi,0x44(%rsp)
fildl  0x44(%rsp)
test   %edi,%edi
je     11a0 <nbdtrl+0x70>
add    $0x1,%edi
mov    %edi,0x3c(%rsp)
fildl  0x3c(%rsp)
fxch   %st(2)
fstpt  0x20(%rsp)
fstpt  (%rsp)
fstpt  0x10(%rsp)
xor    %eax,%eax
call   1040 <incbetl@plt>
mov    %eax,0x40(%rsp)
fildl  0x40(%rsp)
add    $0x48,%rsp
ret
fstp   %st(0)
lea    0xe73(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <mtherr@plt>
fldz
add    $0x48,%rsp
ret
fstpt  0x10(%rsp)
fstpt  (%rsp)
call   1030 <powl@plt>
add    $0x48,%rsp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"nbdtrl\00"
define x86_fp80 @nbdtrl(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 %20
16: ; preds = %12
%17 = load i32, i32* %5
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
br label %20
20: ; preds = %19, %15
%21 = 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 %40
22: ; preds = %16
%23 = load i32, i32* %6
%24 = sitofp i32 %23 to x86_fp80
store x86_fp80 %24, x86_fp80* %9
%25 = load i32, i32* %5
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = load x86_fp80, x86_fp80* %7
%29 = load x86_fp80, x86_fp80* %9
%30 = call x86_fp80 @powl(x86_fp80 %28, x86_fp80 %29)
store x86_fp80 %30, x86_fp80* %4
br label %40
31: ; preds = %22
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
%34 = sitofp i32 %33 to x86_fp80
store x86_fp80 %34, x86_fp80* %8
%35 = load x86_fp80, x86_fp80* %9
%36 = load x86_fp80, x86_fp80* %8
%37 = load x86_fp80, x86_fp80* %7
%38 = call i32 (x86_fp80, x86_fp80, x86_fp80, ...) bitcast (i32 (...)* @incbetl to i32 (x86_fp80, x86_fp80, x86_fp80, ...)*)(x86_fp80 %35, x86_fp80 %36, x86_fp80 %37)
%39 = sitofp i32 %38 to x86_fp80
store x86_fp80 %39, x86_fp80* %4
br label %40
40: ; preds = %31, %27, %20
%41 = load x86_fp80, x86_fp80* %4
ret x86_fp80 %41
}

LLVM IR (-O2):
@.str = [7 x i8] c"nbdtrl\00"
define x86_fp80 @nbdtrl(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
%7 = icmp slt i32 %0, 0
%8 = or i1 %7, %6
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = 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 %21
11: ; preds = %3
%12 = sitofp i32 %1 to x86_fp80
%13 = icmp eq i32 %0, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call x86_fp80 @powl(x86_fp80 %2, x86_fp80 %12)
br label %21
16: ; preds = %11
%17 = add nuw nsw i32 %0, 1
%18 = sitofp i32 %17 to x86_fp80
%19 = tail call i32 (x86_fp80, x86_fp80, x86_fp80, ...) bitcast (i32 (...)* @incbetl to i32 (x86_fp80, x86_fp80, x86_fp80, ...)*)(x86_fp80 %12, x86_fp80 %18, x86_fp80 %2)
%20 = sitofp i32 %19 to x86_fp80
br label %21
21: ; preds = %16, %14, %9
%22 = phi x86_fp80 [ 0xK00000000000000000000, %9 ], [ %15, %14 ], [ %20, %16 ]
ret x86_fp80 %22
}