#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, double);
int /*<<< orphan*/ mtherr(char *, int);
float nbdtrcf(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:
    mtherr("nbdtrf", 1);
    return (0.0);
  }
  dk = k + 1;
  dn = n;
  return (incbetf(dk, dn, 1.0 - p));
}


x86 assembly (clang, -O0):
<nbdtrcf>:
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 <nbdtrcf+0x4e>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe9c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1173 <nbdtrcf+0x53>
jmp    1182 <nbdtrcf+0x62>
cmpl   $0x0,-0x8(%rbp)
jge    11a0 <nbdtrcf+0x80>
jmp    1182 <nbdtrcf+0x62>
lea    0xe7f(%rip),%rdi
mov    $0x1,%esi
call   1040 <mtherr@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11e2 <nbdtrcf+0xc2>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm2
cvtss2sd %xmm2,%xmm3
movsd  0xe2c(%rip),%xmm2
subsd  %xmm3,%xmm2
call   1030 <incbetf@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nbdtrcf>:
push   %rax
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
ja     115d <nbdtrcf+0x3d>
test   %edi,%edi
js     115d <nbdtrcf+0x3d>
ucomiss 0xecc(%rip),%xmm0
ja     115d <nbdtrcf+0x3d>
add    $0x1,%edi
cvtsi2ss %edi,%xmm3
xorps  %xmm1,%xmm1
cvtsi2ss %esi,%xmm1
cvtss2sd %xmm0,%xmm0
movsd  0xeb8(%rip),%xmm2
subsd  %xmm0,%xmm2
movaps %xmm3,%xmm0
pop    %rax
jmp    1030 <incbetf@plt>
lea    0xeac(%rip),%rdi
mov    $0x1,%esi
call   1040 <mtherr@plt>
xorps  %xmm0,%xmm0
pop    %rax
ret

LLVM IR (-O0):
@.str = [7 x i8] c"nbdtrf\00"
define float @nbdtrcf(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 @mtherr(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 %38
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* %8
%33 = load float, float* %9
%34 = load float, float* %10
%35 = fpext float %34 to double
%36 = fsub double 1.000000e+00, %35
%37 = call float @incbetf(float %32, float %33, double %36)
store float %37, float* %4
br label %38
38: ; preds = %26, %24
%39 = load float, float* %4
ret float %39
}

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