#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
float incbetf(float, float, float);
int /*<<< orphan*/ mtherrf(char *, int);
float nbdtrf(int k, int n, float pp) {
  float dk, dn, p;
  p = pp;
  if ((p < 0.0) || (p > 1.0))
    goto domerr;
  if (k < 0) {
  domerr:
    mtherrf("nbdtrf", 1);
    return (0.0);
  }
  dk = k + 1;
  dn = n;
  return (incbetf(dn, dk, p));
}


x86 assembly (clang, -O0):
<nbdtrf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
ja     116e <nbdtrf+0x4e>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe9c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1173 <nbdtrf+0x53>
jmp    1182 <nbdtrf+0x62>
cmpl   $0x0,-0x8(%rbp)
jge    11a0 <nbdtrf+0x80>
jmp    1182 <nbdtrf+0x62>
lea    0xe7f(%rip),%rdi
mov    $0x1,%esi
call   1040 <mtherrf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11d2 <nbdtrf+0xb2>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm2
call   1030 <incbetf@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nbdtrf>:
push   %rax
movaps %xmm0,%xmm2
xorps  %xmm0,%xmm0
ucomiss %xmm2,%xmm0
ja     114d <nbdtrf+0x2d>
test   %edi,%edi
js     114d <nbdtrf+0x2d>
ucomiss 0xec9(%rip),%xmm2
ja     114d <nbdtrf+0x2d>
add    $0x1,%edi
cvtsi2ss %edi,%xmm1
xorps  %xmm0,%xmm0
cvtsi2ss %esi,%xmm0
pop    %rax
jmp    1030 <incbetf@plt>
lea    0xeb0(%rip),%rdi
mov    $0x1,%esi
call   1040 <mtherrf@plt>
xorps  %xmm0,%xmm0
pop    %rax
ret

LLVM IR (-O0):
@.str = [7 x i8] c"nbdtrf\00"
define float @nbdtrf(i32 %0, i32 %1, float %2) {
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
store i32 %0, i32* %5
store i32 %1, i32* %6
store float %2, float* %7
%11 = load float, float* %7
store float %11, float* %10
%12 = load float, float* %10
%13 = fpext float %12 to double
%14 = fcmp olt double %13, 0.000000e+00
br i1 %14, label %19, label %15
15: ; preds = %3
%16 = load float, float* %10
%17 = fpext float %16 to double
%18 = fcmp ogt double %17, 1.000000e+00
br i1 %18, label %19, label %20
19: ; preds = %15, %3
br label %24
20: ; preds = %15
%21 = load i32, i32* %5
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
br label %24
24: ; preds = %23, %19
%25 = call i32 @mtherrf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 1)
store float 0.000000e+00, float* %4
br label %36
26: ; preds = %20
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
%29 = sitofp i32 %28 to float
store float %29, float* %8
%30 = load i32, i32* %6
%31 = sitofp i32 %30 to float
store float %31, float* %9
%32 = load float, float* %9
%33 = load float, float* %8
%34 = load float, float* %10
%35 = call float @incbetf(float %32, float %33, float %34)
store float %35, float* %4
br label %36
36: ; preds = %26, %24
%37 = load float, float* %4
ret float %37
}

LLVM IR (-O2):
@.str = [7 x i8] c"nbdtrf\00"
define float @nbdtrf(i32 %0, i32 %1, float %2) {
%4 = fcmp olt float %2, 0.000000e+00
br i1 %4, label %9, label %5
5: ; preds = %3
%6 = fcmp ogt float %2, 1.000000e+00
%7 = icmp slt i32 %0, 0
%8 = or i1 %7, %6
br i1 %8, label %9, label %11
9: ; preds = %3, %5
%10 = tail call i32 @mtherrf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 1)
br label %16
11: ; preds = %5
%12 = add nuw nsw i32 %0, 1
%13 = sitofp i32 %12 to float
%14 = sitofp i32 %1 to float
%15 = tail call float @incbetf(float %14, float %13, float %2)
br label %16
16: ; preds = %11, %9
%17 = phi float [ 0.000000e+00, %9 ], [ %15, %11 ]
ret float %17
}