double nbdtrc(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(dk, dn, 1.0 - p));
}


x86 assembly (clang, -O0):
<nbdtrc>:
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 <nbdtrc+0x38>
movsd  -0x18(%rbp),%xmm0
movsd  0xeb2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    115d <nbdtrc+0x3d>
jmp    116c <nbdtrc+0x4c>
cmpl   $0x0,-0xc(%rbp)
jge    118c <nbdtrc+0x6c>
jmp    116c <nbdtrc+0x4c>
lea    0xe95(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1040 <mtherr@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11cc <nbdtrc+0xac>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xe49(%rip),%xmm2
subsd  -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):
<nbdtrc>:
push   %rax
test   %edi,%edi
js     1167 <nbdtrc+0x47>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     1167 <nbdtrc+0x47>
ucomisd 0xec9(%rip),%xmm0
ja     1167 <nbdtrc+0x47>
add    $0x1,%edi
cvtsi2sd %edi,%xmm3
xorps  %xmm1,%xmm1
cvtsi2sd %esi,%xmm1
movsd  0xeb1(%rip),%xmm2
subsd  %xmm0,%xmm2
movapd %xmm3,%xmm0
mov    $0x3,%al
call   1030 <incbet@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
pop    %rax
ret
lea    0xe9a(%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 @nbdtrc(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 %34
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* %8
%29 = load double, double* %9
%30 = load double, double* %7
%31 = fsub double 1.000000e+00, %30
%32 = call i32 (double, double, double, ...) bitcast (i32 (...)* @incbet to i32 (double, double, double, ...)*)(double %28, double %29, double %31)
%33 = sitofp i32 %32 to double
store double %33, double* %4
br label %34
34: ; preds = %22, %20
%35 = load double, double* %4
ret double %35
}

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