double fdtri(ia, ib, y)
int ia, ib;
double y;
{
  double a, b, w, x;
  if ((ia < 1) || (ib < 1) || (y <= 0.0) || (y > 1.0)) {
    mtherr("fdtri", 1);
    return (0.0);
  }
  a = ia;
  b = ib;
  w = incbet(0.5 * b, 0.5 * a, 0.5);
  if (w > y || y < 0.001) {
    w = incbi(0.5 * b, 0.5 * a, y);
    x = (b - b * w) / (a * w);
  } else {
    w = incbi(0.5 * a, 0.5 * b, 1.0 - y);
    x = b * w / (a * (1.0 - w));
  }
  return (x);
}


x86 assembly (clang, -O0):
<fdtri>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x1,-0xc(%rbp)
jl     117c <fdtri+0x4c>
cmpl   $0x1,-0x10(%rbp)
jl     117c <fdtri+0x4c>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jae    117c <fdtri+0x4c>
movsd  -0x18(%rbp),%xmm0
movsd  0xe8e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    119c <fdtri+0x6c>
lea    0xe95(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1050 <mtherr@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12e4 <fdtri+0x1b4>
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe50(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  0xe43(%rip),%xmm1
mulsd  -0x20(%rbp),%xmm1
movsd  0xe36(%rip),%xmm2
mov    $0x3,%al
call   1040 <incbet@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
ja     1205 <fdtri+0xd5>
movsd  0xe16(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    127a <fdtri+0x14a>
movsd  0xdfb(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  0xdee(%rip),%xmm1
mulsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
mov    $0x3,%al
call   1030 <incbi@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    12da <fdtri+0x1aa>
movsd  0xd86(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  0xd79(%rip),%xmm1
mulsd  -0x28(%rbp),%xmm1
movsd  0xd64(%rip),%xmm2
subsd  -0x18(%rbp),%xmm2
mov    $0x3,%al
call   1030 <incbi@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xd38(%rip),%xmm2
subsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fdtri>:
sub    $0x28,%rsp
ucomisd 0xec4(%rip),%xmm0
ja     120e <fdtri+0xde>
test   %edi,%edi
jle    120e <fdtri+0xde>
test   %esi,%esi
jle    120e <fdtri+0xde>
movapd %xmm0,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm3,%xmm0
jae    120e <fdtri+0xde>
cvtsi2sd %edi,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %esi,%xmm0
movsd  0xe91(%rip),%xmm2
movsd  %xmm0,0x18(%rsp)
mulsd  %xmm2,%xmm0
movsd  %xmm1,0x10(%rsp)
mulsd  %xmm2,%xmm1
movsd  %xmm0,0x8(%rsp)
movsd  %xmm1,(%rsp)
mov    $0x3,%al
movsd  %xmm3,0x20(%rsp)
call   1040 <incbet@plt>
movsd  0x20(%rsp),%xmm3
movsd  0xe5f(%rip),%xmm0
ucomisd %xmm3,%xmm0
ja     122a <fdtri+0xfa>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
ucomisd %xmm3,%xmm0
ja     122a <fdtri+0xfa>
movsd  0xe34(%rip),%xmm2
subsd  %xmm3,%xmm2
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mov    $0x3,%al
call   1030 <incbi@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0x18(%rsp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe05(%rip),%xmm2
subsd  %xmm1,%xmm2
mulsd  0x10(%rsp),%xmm2
divsd  %xmm2,%xmm0
add    $0x28,%rsp
ret
lea    0xe03(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <mtherr@plt>
xorpd  %xmm0,%xmm0
add    $0x28,%rsp
ret
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
movapd %xmm3,%xmm2
mov    $0x3,%al
call   1030 <incbi@plt>
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
movsd  0x18(%rsp),%xmm0
movapd %xmm0,%xmm1
mulsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"fdtri\00"
define double @fdtri(i32 %0, i32 %1, double %2) {
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store i32 %0, i32* %5
store i32 %1, i32* %6
store double %2, double* %7
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 1
br i1 %13, label %23, label %14
14: ; preds = %3
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 1
br i1 %16, label %23, label %17
17: ; preds = %14
%18 = load double, double* %7
%19 = fcmp ole double %18, 0.000000e+00
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load double, double* %7
%22 = fcmp ogt double %21, 1.000000e+00
br i1 %22, label %23, label %25
23: ; preds = %20, %17, %14, %3
%24 = 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 %78
25: ; preds = %20
%26 = load i32, i32* %5
%27 = sitofp i32 %26 to double
store double %27, double* %8
%28 = load i32, i32* %6
%29 = sitofp i32 %28 to double
store double %29, double* %9
%30 = load double, double* %9
%31 = fmul double 5.000000e-01, %30
%32 = load double, double* %8
%33 = fmul double 5.000000e-01, %32
%34 = call i32 (double, double, double, ...) bitcast (i32 (...)* @incbet to i32 (double, double, double, ...)*)(double %31, double %33, double 5.000000e-01)
%35 = sitofp i32 %34 to double
store double %35, double* %10
%36 = load double, double* %10
%37 = load double, double* %7
%38 = fcmp ogt double %36, %37
br i1 %38, label %42, label %39
39: ; preds = %25
%40 = load double, double* %7
%41 = fcmp olt double %40, 1.000000e-03
br i1 %41, label %42, label %59
42: ; preds = %39, %25
%43 = load double, double* %9
%44 = fmul double 5.000000e-01, %43
%45 = load double, double* %8
%46 = fmul double 5.000000e-01, %45
%47 = load double, double* %7
%48 = call i32 (double, double, double, ...) bitcast (i32 (...)* @incbi to i32 (double, double, double, ...)*)(double %44, double %46, double %47)
%49 = sitofp i32 %48 to double
store double %49, double* %10
%50 = load double, double* %9
%51 = load double, double* %9
%52 = load double, double* %10
%53 = fneg double %51
%54 = call double @llvm.fmuladd.f64(double %53, double %52, double %50)
%55 = load double, double* %8
%56 = load double, double* %10
%57 = fmul double %55, %56
%58 = fdiv double %54, %57
store double %58, double* %11
br label %76
59: ; preds = %39
%60 = load double, double* %8
%61 = fmul double 5.000000e-01, %60
%62 = load double, double* %9
%63 = fmul double 5.000000e-01, %62
%64 = load double, double* %7
%65 = fsub double 1.000000e+00, %64
%66 = call i32 (double, double, double, ...) bitcast (i32 (...)* @incbi to i32 (double, double, double, ...)*)(double %61, double %63, double %65)
%67 = sitofp i32 %66 to double
store double %67, double* %10
%68 = load double, double* %9
%69 = load double, double* %10
%70 = fmul double %68, %69
%71 = load double, double* %8
%72 = load double, double* %10
%73 = fsub double 1.000000e+00, %72
%74 = fmul double %71, %73
%75 = fdiv double %70, %74
store double %75, double* %11
br label %76
76: ; preds = %59, %42
%77 = load double, double* %11
store double %77, double* %4
br label %78
78: ; preds = %76, %23
%79 = load double, double* %4
ret double %79
}

LLVM IR (-O2):
@.str = [6 x i8] c"fdtri\00"
define double @fdtri(i32 %0, i32 %1, double %2) {
%4 = icmp slt i32 %0, 1
%5 = icmp slt i32 %1, 1
%6 = or i1 %4, %5
%7 = fcmp ole double %2, 0.000000e+00
%8 = or i1 %6, %7
%9 = fcmp ogt double %2, 1.000000e+00
%10 = or i1 %9, %8
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = 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 %38
13: ; preds = %3
%14 = sitofp i32 %0 to double
%15 = sitofp i32 %1 to double
%16 = fmul double %15, 5.000000e-01
%17 = fmul double %14, 5.000000e-01
%18 = tail call i32 (double, double, double, ...) bitcast (i32 (...)* @incbet to i32 (double, double, double, ...)*)(double %16, double %17, double 5.000000e-01)
%19 = sitofp i32 %18 to double
%20 = fcmp ogt double %19, %2
%21 = fcmp olt double %2, 1.000000e-03
%22 = or i1 %21, %20
br i1 %22, label %23, label %30
23: ; preds = %13
%24 = tail call i32 (double, double, double, ...) bitcast (i32 (...)* @incbi to i32 (double, double, double, ...)*)(double %16, double %17, double %2)
%25 = sitofp i32 %24 to double
%26 = fneg double %15
%27 = tail call double @llvm.fmuladd.f64(double %26, double %25, double %15)
%28 = fmul double %14, %25
%29 = fdiv double %27, %28
br label %38
30: ; preds = %13
%31 = fsub double 1.000000e+00, %2
%32 = tail call i32 (double, double, double, ...) bitcast (i32 (...)* @incbi to i32 (double, double, double, ...)*)(double %17, double %16, double %31)
%33 = sitofp i32 %32 to double
%34 = fmul double %15, %33
%35 = fsub double 1.000000e+00, %33
%36 = fmul double %35, %14
%37 = fdiv double %34, %36
br label %38
38: ; preds = %23, %30, %11
%39 = phi double [ 0.000000e+00, %11 ], [ %29, %23 ], [ %37, %30 ]
ret double %39
}