double nbdtr(k, n, p)
int k, n;
double p;
{
  double dk, dn;
  if ((p < 0.0) || (p > 1.0))
    goto domerr;
  if (k < 0) {
  domerr:
    mtherr("nbdtr", 1);
    return (0.0);
  }
  dk = k + 1;
  dn = n;
  return (incbet(dn, dk, p));
}


x86 assembly (clang, -O0):
<nbdtr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
ja     1158 <nbdtr+0x38>
movsd  -0x18(%rbp),%xmm0
movsd  0xeb2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    115d <nbdtr+0x3d>
jmp    116c <nbdtr+0x4c>
cmpl   $0x0,-0xc(%rbp)
jge    118c <nbdtr+0x6c>
jmp    116c <nbdtr+0x4c>
lea    0xe95(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1040 <mtherr@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c4 <nbdtr+0xa4>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
mov    $0x3,%al
call   1030 <incbet@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nbdtr>:
push   %rax
test   %edi,%edi
js     115b <nbdtr+0x3b>
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
ja     115b <nbdtr+0x3b>
ucomisd 0xec5(%rip),%xmm2
ja     115b <nbdtr+0x3b>
add    $0x1,%edi
cvtsi2sd %edi,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %esi,%xmm0
mov    $0x3,%al
call   1030 <incbet@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
pop    %rax
ret
lea    0xea6(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <mtherr@plt>
xorpd  %xmm0,%xmm0
pop    %rax
ret

LLVM IR (-O0):
@.str = [6 x i8] c"nbdtr\00"
define double @nbdtr(i32 %0, i32 %1, double %2) {
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
store i32 %0, i32* %5
store i32 %1, i32* %6
store double %2, double* %7
%10 = load double, double* %7
%11 = fcmp olt double %10, 0.000000e+00
br i1 %11, label %15, label %12
12: ; preds = %3
%13 = load double, double* %7
%14 = fcmp ogt double %13, 1.000000e+00
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 ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 1)
store double 0.000000e+00, double* %4
br label %33
22: ; preds = %16
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
%25 = sitofp i32 %24 to double
store double %25, double* %8
%26 = load i32, i32* %6
%27 = sitofp i32 %26 to double
store double %27, double* %9
%28 = load double, double* %9
%29 = load double, double* %8
%30 = load double, double* %7
%31 = call i32 (double, double, double, ...) bitcast (i32 (...)* @incbet to i32 (double, double, double, ...)*)(double %28, double %29, double %30)
%32 = sitofp i32 %31 to double
store double %32, double* %4
br label %33
33: ; preds = %22, %20
%34 = load double, double* %4
ret double %34
}

LLVM IR (-O2):
@.str = [6 x i8] c"nbdtr\00"
define double @nbdtr(i32 %0, i32 %1, double %2) {
%4 = fcmp olt double %2, 0.000000e+00
%5 = fcmp ogt double %2, 1.000000e+00
%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 ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 1)
br label %17
11: ; preds = %3
%12 = add nuw nsw i32 %0, 1
%13 = sitofp i32 %12 to double
%14 = sitofp i32 %1 to double
%15 = tail call i32 (double, double, double, ...) bitcast (i32 (...)* @incbet to i32 (double, double, double, ...)*)(double %14, double %13, double %2)
%16 = sitofp i32 %15 to double
br label %17
17: ; preds = %11, %9
%18 = phi double [ 0.000000e+00, %9 ], [ %16, %11 ]
ret double %18
}