#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 betacf(double, double, double);
double exp(double);
double gammln(double);
double lbetacf(double, double, double);
double log(double);
double log1minusbetai(double a, double b, double x) {
  double bt;
  if (x < 0.0 || x > 1.0)
    return 0.;
  if (x == 0.0 || x == 1.0)
    bt = 0.0;
  else
    bt = gammln(a + b) - gammln(a) - gammln(b) + a * log(x) + b * log(1.0 - x);
  if (x < (a + 1.0) / (a + b + 2.0))
    return log(1. - exp(bt) * betacf(a, b, x) / a);
  else
    return bt + lbetacf(b, a, 1.0 - x) - log(b);
}


x86 assembly (clang, -O0):
<log1minusbetai>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
ja     118c <log1minusbetai+0x3c>
movsd  -0x20(%rbp),%xmm0
movsd  0xe7e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1199 <log1minusbetai+0x49>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1362 <log1minusbetai+0x212>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11b6 <log1minusbetai+0x66>
jp     11b6 <log1minusbetai+0x66>
jmp    11d3 <log1minusbetai+0x83>
movsd  -0x20(%rbp),%xmm0
movsd  0xe3d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11e0 <log1minusbetai+0x90>
jp     11e0 <log1minusbetai+0x90>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    128e <log1minusbetai+0x13e>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
call   1060 <gammln@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1060 <gammln@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1060 <gammln@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1050 <log@plt>
movsd  -0x48(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xd96(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
call   1050 <log@plt>
movsd  -0x38(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  0xd65(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
addsd  -0x18(%rbp),%xmm2
movsd  0xd56(%rip),%xmm3
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    1310 <log1minusbetai+0x1c0>
movsd  -0x28(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
call   1070 <betacf@plt>
movsd  -0x60(%rbp),%xmm1
mulsd  %xmm0,%xmm1
divsd  -0x10(%rbp),%xmm1
movsd  0xd03(%rip),%xmm0
subsd  %xmm1,%xmm0
call   1050 <log@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    1362 <log1minusbetai+0x212>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xcd4(%rip),%xmm2
subsd  -0x20(%rbp),%xmm2
call   1040 <lbetacf@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log1minusbetai>:
sub    $0x28,%rsp
movapd %xmm2,%xmm4
xorpd  %xmm2,%xmm2
ucomisd %xmm4,%xmm2
ja     12ea <log1minusbetai+0x19a>
ucomisd 0xe92(%rip),%xmm4
ja     12ea <log1minusbetai+0x19a>
movapd %xmm0,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm4
movapd %xmm3,%xmm5
addsd  %xmm1,%xmm5
movsd  %xmm1,0x18(%rsp)
movsd  %xmm3,0x8(%rsp)
movsd  %xmm4,0x10(%rsp)
jne    11a2 <log1minusbetai+0x52>
jnp    1247 <log1minusbetai+0xf7>
ucomisd 0xe56(%rip),%xmm4
jne    11b2 <log1minusbetai+0x62>
jnp    1247 <log1minusbetai+0xf7>
movapd %xmm5,%xmm0
movsd  %xmm5,0x20(%rsp)
call   1060 <gammln@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <gammln@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x18(%rsp),%xmm0
call   1060 <gammln@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <log@plt>
mulsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xde5(%rip),%xmm0
subsd  0x10(%rsp),%xmm0
call   1050 <log@plt>
movsd  0x20(%rsp),%xmm5
movsd  0x10(%rsp),%xmm4
movsd  0x8(%rsp),%xmm3
movsd  0x18(%rsp),%xmm1
mulsd  %xmm1,%xmm0
addsd  (%rsp),%xmm0
movsd  0xdb1(%rip),%xmm2
addsd  0xdb1(%rip),%xmm5
addsd  %xmm3,%xmm2
divsd  %xmm5,%xmm2
ucomisd %xmm4,%xmm2
jbe    12aa <log1minusbetai+0x15a>
call   1030 <exp@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
call   1070 <betacf@plt>
mulsd  (%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
movsd  0xd67(%rip),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
jmp    1050 <log@plt>
movsd  %xmm0,(%rsp)
movsd  0xd49(%rip),%xmm2
subsd  %xmm4,%xmm2
movapd %xmm1,%xmm0
movapd %xmm3,%xmm1
call   1040 <lbetacf@plt>
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x18(%rsp),%xmm0
call   1050 <log@plt>
movsd  (%rsp),%xmm2
subsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @log1minusbetai(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%9 = load double, double* %7
%10 = fcmp olt double %9, 0.000000e+00
br i1 %10, label %14, label %11
11: ; preds = %3
%12 = load double, double* %7
%13 = fcmp ogt double %12, 1.000000e+00
br i1 %13, label %14, label %15
14: ; preds = %11, %3
store double 0.000000e+00, double* %4
br label %75
15: ; preds = %11
%16 = load double, double* %7
%17 = fcmp oeq double %16, 0.000000e+00
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load double, double* %7
%20 = fcmp oeq double %19, 1.000000e+00
br i1 %20, label %21, label %22
21: ; preds = %18, %15
store double 0.000000e+00, double* %8
br label %42
22: ; preds = %18
%23 = load double, double* %5
%24 = load double, double* %6
%25 = fadd double %23, %24
%26 = call double @gammln(double %25)
%27 = load double, double* %5
%28 = call double @gammln(double %27)
%29 = fsub double %26, %28
%30 = load double, double* %6
%31 = call double @gammln(double %30)
%32 = fsub double %29, %31
%33 = load double, double* %5
%34 = load double, double* %7
%35 = call double @log(double %34)
%36 = call double @llvm.fmuladd.f64(double %33, double %35, double %32)
%37 = load double, double* %6
%38 = load double, double* %7
%39 = fsub double 1.000000e+00, %38
%40 = call double @log(double %39)
%41 = call double @llvm.fmuladd.f64(double %37, double %40, double %36)
store double %41, double* %8
br label %42
42: ; preds = %22, %21
%43 = load double, double* %7
%44 = load double, double* %5
%45 = fadd double %44, 1.000000e+00
%46 = load double, double* %5
%47 = load double, double* %6
%48 = fadd double %46, %47
%49 = fadd double %48, 2.000000e+00
%50 = fdiv double %45, %49
%51 = fcmp olt double %43, %50
br i1 %51, label %52, label %64
52: ; preds = %42
%53 = load double, double* %8
%54 = call double @exp(double %53)
%55 = load double, double* %5
%56 = load double, double* %6
%57 = load double, double* %7
%58 = call double @betacf(double %55, double %56, double %57)
%59 = fmul double %54, %58
%60 = load double, double* %5
%61 = fdiv double %59, %60
%62 = fsub double 1.000000e+00, %61
%63 = call double @log(double %62)
store double %63, double* %4
br label %75
64: ; preds = %42
%65 = load double, double* %8
%66 = load double, double* %6
%67 = load double, double* %5
%68 = load double, double* %7
%69 = fsub double 1.000000e+00, %68
%70 = call double @lbetacf(double %66, double %67, double %69)
%71 = fadd double %65, %70
%72 = load double, double* %6
%73 = call double @log(double %72)
%74 = fsub double %71, %73
store double %74, double* %4
br label %75
75: ; preds = %64, %52, %14
%76 = load double, double* %4
ret double %76
}

LLVM IR (-O2):
define double @log1minusbetai(double %0, double %1, double %2) {
%4 = fcmp olt double %2, 0.000000e+00
%5 = fcmp ogt double %2, 1.000000e+00
%6 = or i1 %4, %5
br i1 %6, label %42, label %7
7: ; preds = %3
%8 = fcmp oeq double %2, 0.000000e+00
%9 = fcmp oeq double %2, 1.000000e+00
%10 = or i1 %8, %9
%11 = fadd double %0, %1
br i1 %10, label %23, label %12
12: ; preds = %7
%13 = tail call double @gammln(double %11)
%14 = tail call double @gammln(double %0)
%15 = fsub double %13, %14
%16 = tail call double @gammln(double %1)
%17 = fsub double %15, %16
%18 = tail call double @log(double %2)
%19 = tail call double @llvm.fmuladd.f64(double %0, double %18, double %17)
%20 = fsub double 1.000000e+00, %2
%21 = tail call double @log(double %20)
%22 = tail call double @llvm.fmuladd.f64(double %1, double %21, double %19)
br label %23
23: ; preds = %7, %12
%24 = phi double [ %22, %12 ], [ 0.000000e+00, %7 ]
%25 = fadd double %0, 1.000000e+00
%26 = fadd double %11, 2.000000e+00
%27 = fdiv double %25, %26
%28 = fcmp ogt double %27, %2
br i1 %28, label %29, label %36
29: ; preds = %23
%30 = tail call double @exp(double %24)
%31 = tail call double @betacf(double %0, double %1, double %2)
%32 = fmul double %30, %31
%33 = fdiv double %32, %0
%34 = fsub double 1.000000e+00, %33
%35 = tail call double @log(double %34)
br label %42
36: ; preds = %23
%37 = fsub double 1.000000e+00, %2
%38 = tail call double @lbetacf(double %1, double %0, double %37)
%39 = fadd double %24, %38
%40 = tail call double @log(double %1)
%41 = fsub double %39, %40
br label %42
42: ; preds = %3, %36, %29
%43 = phi double [ %35, %29 ], [ %41, %36 ], [ 0.000000e+00, %3 ]
ret double %43
}