#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 exp(scalar_t__);
int fabs(double);
scalar_t__ kf_lgamma(double);
double log(int);
double kf_betai_aux(double a, double b, double x) {
  double C, D, f;
  int j;
  if (x == 0.)
    return 0.;
  if (x == 1.)
    return 1.;
  f = 1.;
  C = f;
  D = 0.;
  for (j = 1; j < 200; ++j) {
    double aa, d;
    int m = j >> 1;
    aa = (j & 1) ? -(a + m) * (a + b + m) * x / ((a + 2 * m) * (a + 2 * m + 1))
                 : m * (b - m) * x / ((a + 2 * m - 1) * (a + 2 * m));
    D = 1. + aa * D;
    if (D < 1e-290)
      D = 1e-290;
    C = 1. + aa / C;
    if (C < 1e-290)
      C = 1e-290;
    D = 1. / D;
    d = C * D;
    f *= d;
    if (fabs(d - 1.) < 1e-14)
      break;
  }
  return exp(kf_lgamma(a + b) - kf_lgamma(a) - kf_lgamma(b) + a * log(x) +
             b * log(1. - x)) /
         a / f;
}


x86 assembly (clang, -O0):
<kf_betai_aux>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    117f <kf_betai_aux+0x3f>
jp     117f <kf_betai_aux+0x3f>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    14a2 <kf_betai_aux+0x362>
movsd  -0x20(%rbp),%xmm0
movsd  0xe74(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11ae <kf_betai_aux+0x6e>
jp     11ae <kf_betai_aux+0x6e>
movsd  0xe5c(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    14a2 <kf_betai_aux+0x362>
movsd  0xe4a(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x1,-0x3c(%rbp)
cmpl   $0xc8,-0x3c(%rbp)
jge    13d1 <kf_betai_aux+0x291>
mov    -0x3c(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0x3c(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     127e <kf_betai_aux+0x13e>
movsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x54(%rbp),%xmm1
addsd  %xmm1,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x10(%rbp),%xmm1
addsd  -0x18(%rbp),%xmm1
cvtsi2sdl -0x54(%rbp),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    -0x54(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm2
addsd  %xmm2,%xmm1
movsd  -0x10(%rbp),%xmm2
mov    -0x54(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm3
addsd  %xmm3,%xmm2
movsd  0xd98(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    12d9 <kf_betai_aux+0x199>
cvtsi2sdl -0x54(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
cvtsi2sdl -0x54(%rbp),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    -0x54(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm2
addsd  %xmm2,%xmm1
movsd  0xd4b(%rip),%xmm2
subsd  %xmm2,%xmm1
movsd  -0x10(%rbp),%xmm2
mov    -0x54(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd07(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xcfe(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1322 <kf_betai_aux+0x1e2>
movsd  0xceb(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x48(%rbp),%xmm1
divsd  -0x28(%rbp),%xmm1
movsd  0xccc(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xcc3(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    135d <kf_betai_aux+0x21d>
movsd  0xcb0(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xc9b(%rip),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  0xc66(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xc61(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    13be <kf_betai_aux+0x27e>
jmp    13d1 <kf_betai_aux+0x291>
jmp    13c3 <kf_betai_aux+0x283>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11d4 <kf_betai_aux+0x94>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
call   1040 <kf_lgamma@plt>
mov    %rax,-0x90(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <kf_lgamma@plt>
mov    %rax,%rcx
mov    -0x90(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x88(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <kf_lgamma@plt>
mov    %rax,%rcx
mov    -0x88(%rbp),%rax
sub    %rcx,%rax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
cvttsd2si -0x20(%rbp),%edi
call   1060 <log@plt>
movsd  -0x80(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xb9a(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <log@plt>
movsd  -0x70(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1050 <exp@plt>
divsd  -0x10(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kf_betai_aux>:
push   %r14
push   %rbx
sub    $0x38,%rsp
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,(%rsp)
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jne    1162 <kf_betai_aux+0x22>
jnp    1367 <kf_betai_aux+0x227>
movsd  0xe96(%rip),%xmm0
ucomisd %xmm0,%xmm2
jne    1176 <kf_betai_aux+0x36>
jnp    1367 <kf_betai_aux+0x227>
movsd  %xmm2,0x18(%rsp)
movsd  (%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x28(%rsp)
mov    $0x1,%ebx
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xe5c(%rip),%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  %xmm0,0x20(%rsp)
mov    %ebx,%eax
shr    %eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
test   $0x1,%bl
jne    1210 <kf_betai_aux+0xd0>
movsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
mulsd  0x18(%rsp),%xmm1
mov    %ebx,%eax
and    $0x7ffffffe,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  (%rsp),%xmm0
movapd %xmm0,%xmm2
movsd  0xe15(%rip),%xmm4
addsd  %xmm4,%xmm2
mulsd  %xmm0,%xmm2
divsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
movsd  0xdf5(%rip),%xmm3
jmp    1267 <kf_betai_aux+0x127>
nopl   (%rax)
movsd  0x28(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  (%rsp),%xmm2
addsd  %xmm2,%xmm0
xorpd  0xdf5(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  0x18(%rsp),%xmm0
mov    %ebx,%eax
and    $0x7ffffffe,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
addsd  %xmm2,%xmm1
movapd %xmm1,%xmm2
movsd  0xdad(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm1,%xmm2
divsd  %xmm2,%xmm0
movsd  0xda1(%rip),%xmm4
movsd  0x8(%rsp),%xmm5
mulsd  %xmm0,%xmm5
addsd  %xmm3,%xmm5
movsd  0xd93(%rip),%xmm2
movapd %xmm2,%xmm1
maxsd  %xmm5,%xmm1
divsd  0x30(%rsp),%xmm0
addsd  %xmm3,%xmm0
maxsd  %xmm0,%xmm2
divsd  %xmm1,%xmm3
movsd  %xmm2,0x30(%rsp)
movapd %xmm2,%xmm0
movsd  %xmm3,0x8(%rsp)
mulsd  %xmm3,%xmm0
movsd  0x20(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
addsd  %xmm4,%xmm0
call   1030 <fabs@plt>
test   %eax,%eax
jle    12d9 <kf_betai_aux+0x199>
lea    0x1(%rbx),%eax
cmp    $0xc7,%ebx
mov    %eax,%ebx
jne    11b0 <kf_betai_aux+0x70>
movsd  0x28(%rsp),%xmm0
call   1040 <kf_lgamma@plt>
mov    %rax,%rbx
movsd  (%rsp),%xmm0
call   1040 <kf_lgamma@plt>
mov    %rax,%r14
movsd  0x10(%rsp),%xmm0
call   1040 <kf_lgamma@plt>
add    %r14,%rax
sub    %rax,%rbx
xorps  %xmm0,%xmm0
cvtsi2sd %rbx,%xmm0
movsd  %xmm0,0x8(%rsp)
cvttsd2si 0x18(%rsp),%edi
call   1060 <log@plt>
mulsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xcc9(%rip),%xmm0
subsd  0x18(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <log@plt>
mulsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%rdi
call   1050 <exp@plt>
divsd  (%rsp),%xmm0
divsd  0x20(%rsp),%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @kf_betai_aux(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca i32
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%15 = load double, double* %7
%16 = fcmp oeq double %15, 0.000000e+00
br i1 %16, label %17, label %18
17: ; preds = %3
store double 0.000000e+00, double* %4
br label %148
18: ; preds = %3
%19 = load double, double* %7
%20 = fcmp oeq double %19, 1.000000e+00
br i1 %20, label %21, label %22
21: ; preds = %18
store double 1.000000e+00, double* %4
br label %148
22: ; preds = %18
store double 1.000000e+00, double* %10
%23 = load double, double* %10
store double %23, double* %8
store double 0.000000e+00, double* %9
store i32 1, i32* %11
br label %24
24: ; preds = %116, %22
%25 = load i32, i32* %11
%26 = icmp slt i32 %25, 200
br i1 %26, label %27, label %119
27: ; preds = %24
%28 = load i32, i32* %11
%29 = ashr i32 %28, 1
store i32 %29, i32* %14
%30 = load i32, i32* %11
%31 = and i32 %30, 1
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %61
33: ; preds = %27
%34 = load double, double* %5
%35 = load i32, i32* %14
%36 = sitofp i32 %35 to double
%37 = fadd double %34, %36
%38 = fneg double %37
%39 = load double, double* %5
%40 = load double, double* %6
%41 = fadd double %39, %40
%42 = load i32, i32* %14
%43 = sitofp i32 %42 to double
%44 = fadd double %41, %43
%45 = fmul double %38, %44
%46 = load double, double* %7
%47 = fmul double %45, %46
%48 = load double, double* %5
%49 = load i32, i32* %14
%50 = mul nsw i32 2, %49
%51 = sitofp i32 %50 to double
%52 = fadd double %48, %51
%53 = load double, double* %5
%54 = load i32, i32* %14
%55 = mul nsw i32 2, %54
%56 = sitofp i32 %55 to double
%57 = fadd double %53, %56
%58 = fadd double %57, 1.000000e+00
%59 = fmul double %52, %58
%60 = fdiv double %47, %59
br label %84
61: ; preds = %27
%62 = load i32, i32* %14
%63 = sitofp i32 %62 to double
%64 = load double, double* %6
%65 = load i32, i32* %14
%66 = sitofp i32 %65 to double
%67 = fsub double %64, %66
%68 = fmul double %63, %67
%69 = load double, double* %7
%70 = fmul double %68, %69
%71 = load double, double* %5
%72 = load i32, i32* %14
%73 = mul nsw i32 2, %72
%74 = sitofp i32 %73 to double
%75 = fadd double %71, %74
%76 = fsub double %75, 1.000000e+00
%77 = load double, double* %5
%78 = load i32, i32* %14
%79 = mul nsw i32 2, %78
%80 = sitofp i32 %79 to double
%81 = fadd double %77, %80
%82 = fmul double %76, %81
%83 = fdiv double %70, %82
br label %84
84: ; preds = %61, %33
%85 = phi double [ %60, %33 ], [ %83, %61 ]
store double %85, double* %12
%86 = load double, double* %12
%87 = load double, double* %9
%88 = call double @llvm.fmuladd.f64(double %86, double %87, double 1.000000e+00)
store double %88, double* %9
%89 = load double, double* %9
%90 = fcmp olt double %89, 1.000000e-290
br i1 %90, label %91, label %92
91: ; preds = %84
store double 1.000000e-290, double* %9
br label %92
92: ; preds = %91, %84
%93 = load double, double* %12
%94 = load double, double* %8
%95 = fdiv double %93, %94
%96 = fadd double 1.000000e+00, %95
store double %96, double* %8
%97 = load double, double* %8
%98 = fcmp olt double %97, 1.000000e-290
br i1 %98, label %99, label %100
99: ; preds = %92
store double 1.000000e-290, double* %8
br label %100
100: ; preds = %99, %92
%101 = load double, double* %9
%102 = fdiv double 1.000000e+00, %101
store double %102, double* %9
%103 = load double, double* %8
%104 = load double, double* %9
%105 = fmul double %103, %104
store double %105, double* %13
%106 = load double, double* %13
%107 = load double, double* %10
%108 = fmul double %107, %106
store double %108, double* %10
%109 = load double, double* %13
%110 = fsub double %109, 1.000000e+00
%111 = call i32 @fabs(double %110)
%112 = sitofp i32 %111 to double
%113 = fcmp olt double %112, 0x3D06849B86A12B9B
br i1 %113, label %114, label %115
114: ; preds = %100
br label %119
115: ; preds = %100
br label %116
116: ; preds = %115
%117 = load i32, i32* %11
%118 = add nsw i32 %117, 1
store i32 %118, i32* %11
br label %24
119: ; preds = %114, %24
%120 = load double, double* %5
%121 = load double, double* %6
%122 = fadd double %120, %121
%123 = call i64 @kf_lgamma(double %122)
%124 = load double, double* %5
%125 = call i64 @kf_lgamma(double %124)
%126 = sub nsw i64 %123, %125
%127 = load double, double* %6
%128 = call i64 @kf_lgamma(double %127)
%129 = sub nsw i64 %126, %128
%130 = sitofp i64 %129 to double
%131 = load double, double* %5
%132 = load double, double* %7
%133 = fptosi double %132 to i32
%134 = call double @log(i32 %133)
%135 = call double @llvm.fmuladd.f64(double %131, double %134, double %130)
%136 = load double, double* %6
%137 = load double, double* %7
%138 = fsub double 1.000000e+00, %137
%139 = fptosi double %138 to i32
%140 = call double @log(i32 %139)
%141 = call double @llvm.fmuladd.f64(double %136, double %140, double %135)
%142 = fptosi double %141 to i64
%143 = call double @exp(i64 %142)
%144 = load double, double* %5
%145 = fdiv double %143, %144
%146 = load double, double* %10
%147 = fdiv double %145, %146
store double %147, double* %4
br label %148
148: ; preds = %119, %21, %17
%149 = load double, double* %4
ret double %149
}

LLVM IR (-O2):
define double @kf_betai_aux(double %0, double %1, double %2) {
%4 = fcmp oeq double %2, 0.000000e+00
br i1 %4, label %76, label %5
5: ; preds = %3
%6 = fcmp oeq double %2, 1.000000e+00
br i1 %6, label %76, label %7
7: ; preds = %5
%8 = fadd double %0, %1
br label %9
9: ; preds = %40, %7
%10 = phi double [ 1.000000e+00, %7 ], [ %48, %40 ]
%11 = phi double [ 0.000000e+00, %7 ], [ %49, %40 ]
%12 = phi i32 [ 1, %7 ], [ %55, %40 ]
%13 = phi double [ 1.000000e+00, %7 ], [ %51, %40 ]
%14 = lshr i32 %12, 1
%15 = and i32 %12, 1
%16 = icmp eq i32 %15, 0
%17 = sitofp i32 %14 to double
br i1 %16, label %30, label %18
18: ; preds = %9
%19 = fadd double %17, %0
%20 = fneg double %19
%21 = fadd double %8, %17
%22 = fmul double %21, %20
%23 = fmul double %22, %2
%24 = and i32 %12, 2147483646
%25 = sitofp i32 %24 to double
%26 = fadd double %25, %0
%27 = fadd double %26, 1.000000e+00
%28 = fmul double %26, %27
%29 = fdiv double %23, %28
br label %40
30: ; preds = %9
%31 = fsub double %1, %17
%32 = fmul double %31, %17
%33 = fmul double %32, %2
%34 = and i32 %12, 2147483646
%35 = sitofp i32 %34 to double
%36 = fadd double %35, %0
%37 = fadd double %36, -1.000000e+00
%38 = fmul double %36, %37
%39 = fdiv double %33, %38
br label %40
40: ; preds = %30, %18
%41 = phi double [ %29, %18 ], [ %39, %30 ]
%42 = tail call double @llvm.fmuladd.f64(double %41, double %11, double 1.000000e+00)
%43 = fcmp olt double %42, 1.000000e-290
%44 = select i1 %43, double 1.000000e-290, double %42
%45 = fdiv double %41, %10
%46 = fadd double %45, 1.000000e+00
%47 = fcmp olt double %46, 1.000000e-290
%48 = select i1 %47, double 1.000000e-290, double %46
%49 = fdiv double 1.000000e+00, %44
%50 = fmul double %48, %49
%51 = fmul double %13, %50
%52 = fadd double %50, -1.000000e+00
%53 = tail call i32 @fabs(double %52)
%54 = icmp slt i32 %53, 1
%55 = add nuw nsw i32 %12, 1
%56 = icmp eq i32 %55, 200
%57 = select i1 %54, i1 true, i1 %56
br i1 %57, label %58, label %9
58: ; preds = %40
%59 = tail call i64 @kf_lgamma(double %8)
%60 = tail call i64 @kf_lgamma(double %0)
%61 = tail call i64 @kf_lgamma(double %1)
%62 = add i64 %60, %61
%63 = sub i64 %59, %62
%64 = sitofp i64 %63 to double
%65 = fptosi double %2 to i32
%66 = tail call double @log(i32 %65)
%67 = tail call double @llvm.fmuladd.f64(double %0, double %66, double %64)
%68 = fsub double 1.000000e+00, %2
%69 = fptosi double %68 to i32
%70 = tail call double @log(i32 %69)
%71 = tail call double @llvm.fmuladd.f64(double %1, double %70, double %67)
%72 = fptosi double %71 to i64
%73 = tail call double @exp(i64 %72)
%74 = fdiv double %73, %0
%75 = fdiv double %74, %51
br label %76
76: ; preds = %5, %3, %58
%77 = phi double [ %75, %58 ], [ 0.000000e+00, %3 ], [ 1.000000e+00, %5 ]
ret double %77
}