#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 */
double incbif(float, float, float);
int /*<<< orphan*/ mtherrf(char *, int);
double powf(float, double);
float bdtrif(int k, int n, float yy) {
  float y, dk, dn, p;
  y = yy;
  if ((y < 0.0) || (y > 1.0))
    goto domerr;
  if ((k < 0) || (n <= k)) {
  domerr:
    mtherrf("bdtrif", 1);
    return (0.0);
  }
  dn = n - k;
  if (k == 0) {
    p = 1.0 - powf(y, 1.0 / dn);
  } else {
    dk = k + 1;
    p = 1.0 - incbif(dn, dk, y);
  }
  return (p);
}


x86 assembly (clang, -O0):
<bdtrif>:
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,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
ja     117e <bdtrif+0x4e>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe8c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1183 <bdtrif+0x53>
jmp    119e <bdtrif+0x6e>
cmpl   $0x0,-0x8(%rbp)
jl     1199 <bdtrif+0x69>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11bc <bdtrif+0x8c>
jmp    119e <bdtrif+0x6e>
lea    0xe63(%rip),%rdi
mov    $0x1,%esi
call   1050 <mtherrf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1256 <bdtrif+0x126>
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x1c(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1211 <bdtrif+0xe1>
movss  -0x14(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xe15(%rip),%xmm1
divsd  %xmm2,%xmm1
call   1030 <powf@plt>
movaps %xmm0,%xmm1
movsd  0xe01(%rip),%xmm0
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    124c <bdtrif+0x11c>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
movss  -0x14(%rbp),%xmm2
call   1040 <incbif@plt>
movaps %xmm0,%xmm1
movsd  0xdc1(%rip),%xmm0
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bdtrif>:
push   %rax
movaps %xmm0,%xmm2
xorps  %xmm0,%xmm0
ucomiss %xmm2,%xmm0
jbe    1152 <bdtrif+0x22>
lea    0xecd(%rip),%rdi
mov    $0x1,%esi
call   1050 <mtherrf@plt>
xorps  %xmm0,%xmm0
pop    %rax
ret
sub    %edi,%esi
jle    113c <bdtrif+0xc>
test   %edi,%edi
js     113c <bdtrif+0xc>
ucomiss 0xe9f(%rip),%xmm2
ja     113c <bdtrif+0xc>
xorps  %xmm0,%xmm0
cvtsi2ss %esi,%xmm0
test   %edi,%edi
je     117c <bdtrif+0x4c>
add    $0x1,%edi
cvtsi2ss %edi,%xmm1
call   1040 <incbif@plt>
jmp    1194 <bdtrif+0x64>
cvtss2sd %xmm0,%xmm0
movsd  0xe80(%rip),%xmm1
divsd  %xmm0,%xmm1
movaps %xmm2,%xmm0
call   1030 <powf@plt>
movsd  0xe6c(%rip),%xmm1
subsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
@.str = [7 x i8] c"bdtrif\00"
define float @bdtrif(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
%11 = alloca float
store i32 %0, i32* %5
store i32 %1, i32* %6
store float %2, float* %7
%12 = load float, float* %7
store float %12, float* %8
%13 = load float, float* %8
%14 = fpext float %13 to double
%15 = fcmp olt double %14, 0.000000e+00
br i1 %15, label %20, label %16
16: ; preds = %3
%17 = load float, float* %8
%18 = fpext float %17 to double
%19 = fcmp ogt double %18, 1.000000e+00
br i1 %19, label %20, label %21
20: ; preds = %16, %3
br label %29
21: ; preds = %16
%22 = load i32, i32* %5
%23 = icmp slt i32 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %21
%25 = load i32, i32* %6
%26 = load i32, i32* %5
%27 = icmp sle i32 %25, %26
br i1 %27, label %28, label %31
28: ; preds = %24, %21
br label %29
29: ; preds = %28, %20
%30 = 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 %58
31: ; preds = %24
%32 = load i32, i32* %6
%33 = load i32, i32* %5
%34 = sub nsw i32 %32, %33
%35 = sitofp i32 %34 to float
store float %35, float* %10
%36 = load i32, i32* %5
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %46
38: ; preds = %31
%39 = load float, float* %8
%40 = load float, float* %10
%41 = fpext float %40 to double
%42 = fdiv double 1.000000e+00, %41
%43 = call double @powf(float %39, double %42)
%44 = fsub double 1.000000e+00, %43
%45 = fptrunc double %44 to float
store float %45, float* %11
br label %56
46: ; preds = %31
%47 = load i32, i32* %5
%48 = add nsw i32 %47, 1
%49 = sitofp i32 %48 to float
store float %49, float* %9
%50 = load float, float* %10
%51 = load float, float* %9
%52 = load float, float* %8
%53 = call double @incbif(float %50, float %51, float %52)
%54 = fsub double 1.000000e+00, %53
%55 = fptrunc double %54 to float
store float %55, float* %11
br label %56
56: ; preds = %46, %38
%57 = load float, float* %11
store float %57, float* %4
br label %58
58: ; preds = %56, %29
%59 = load float, float* %4
ret float %59
}

LLVM IR (-O2):
@.str = [7 x i8] c"bdtrif\00"
define float @bdtrif(i32 %0, i32 %1, float %2) {
%4 = fcmp olt float %2, 0.000000e+00
br i1 %4, label %11, label %5
5: ; preds = %3
%6 = fcmp ule float %2, 1.000000e+00
%7 = icmp sgt i32 %0, -1
%8 = and i1 %7, %6
%9 = icmp sgt i32 %1, %0
%10 = and i1 %9, %8
br i1 %10, label %13, label %11
11: ; preds = %3, %5
%12 = tail call i32 @mtherrf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 1)
br label %29
13: ; preds = %5
%14 = sub nsw i32 %1, %0
%15 = sitofp i32 %14 to float
%16 = icmp eq i32 %0, 0
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = fpext float %15 to double
%19 = fdiv double 1.000000e+00, %18
%20 = tail call double @powf(float %2, double %19)
br label %25
21: ; preds = %13
%22 = add nuw nsw i32 %0, 1
%23 = sitofp i32 %22 to float
%24 = tail call double @incbif(float %15, float %23, float %2)
br label %25
25: ; preds = %21, %17
%26 = phi double [ %20, %17 ], [ %24, %21 ]
%27 = fsub double 1.000000e+00, %26
%28 = fptrunc double %27 to float
br label %29
29: ; preds = %25, %11
%30 = phi float [ 0.000000e+00, %11 ], [ %28, %25 ]
ret float %30
}