#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 erfc(double);
int /*<<< orphan*/ exit(int);
double pow(double, double);
int /*<<< orphan*/ printf(char *);
double qgamma(double, double);
double sqrt(double);
double ibeta_appx(double x, double a, double b) {
  double oup, abx, c2, w1, w2, num, den;
  if (x < 0. || x > 1.) {
    printf("x only accepts real values between 0.0 and 1.0");
    exit(1);
  }
  if (a < 0. || b < 0.) {
    printf(" The Two Inputs should be nonnegative and real");
    exit(1);
  }
  abx = (a + b - 1) * (1. - x);
  if (abx <= 0.8) {
    c2 = (abx * (3. - x) - (b - 1.) * (1. - x)) / 2.0;
    oup = qgamma(c2, b);
  } else if (abx > 0.8) {
    w1 = pow(b * x, (double)1. / 3.);
    w2 = pow(a * (1. - x), (double)1. / 3.);
    num = -3.0 * (w1 * (1. - 1. / (9. * b)) - w2 * (1. - 1. / (9. * a))) /
          sqrt(2);
    den = sqrt((w1 * w1 / b) + (w2 * w2 / a));
    oup = erfc(num / den) / 2.0;
  }
  return oup;
}


x86 assembly (clang, -O0):
<ibeta_appx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
ja     119c <ibeta_appx+0x3c>
movsd  -0x8(%rbp),%xmm0
movsd  0xe6e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11b2 <ibeta_appx+0x52>
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     11ce <ibeta_appx+0x6e>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11e4 <ibeta_appx+0x84>
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  0xe0a(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xdfe(%rip),%xmm1
subsd  -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xdf0(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     12a0 <ibeta_appx+0x140>
movsd  -0x28(%rbp),%xmm0
movsd  0xe00(%rip),%xmm2
subsd  -0x8(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
movsd  0xdbe(%rip),%xmm3
subsd  %xmm3,%xmm1
movsd  0xdb2(%rip),%xmm3
subsd  -0x8(%rbp),%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd92(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1040 <qgamma@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    13f2 <ibeta_appx+0x292>
movsd  -0x28(%rbp),%xmm0
movsd  0xd5b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    13ed <ibeta_appx+0x28d>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  0xd5f(%rip),%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xd20(%rip),%xmm1
subsd  -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd37(%rip),%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  0xd18(%rip),%xmm2
mulsd  -0x18(%rbp),%xmm2
movsd  0xceb(%rip),%xmm0
divsd  %xmm2,%xmm0
movsd  0xcdf(%rip),%xmm2
subsd  %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
movsd  0xcee(%rip),%xmm3
mulsd  -0x10(%rbp),%xmm3
movsd  0xcc1(%rip),%xmm4
divsd  %xmm3,%xmm4
movsd  0xcb5(%rip),%xmm3
subsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xc9e(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xc85(%rip),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
divsd  -0x10(%rbp),%xmm1
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
divsd  -0x50(%rbp),%xmm0
call   1080 <erfc@plt>
movsd  0xc2c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    13f2 <ibeta_appx+0x292>
movsd  -0x20(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ibeta_appx>:
sub    $0x48,%rsp
movapd %xmm1,%xmm4
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     131f <ibeta_appx+0x1bf>
ucomisd 0xe82(%rip),%xmm0
ja     131f <ibeta_appx+0x1bf>
xorpd  %xmm1,%xmm1
ucomisd %xmm4,%xmm1
ja     1328 <ibeta_appx+0x1c8>
ucomisd %xmm2,%xmm1
ja     1328 <ibeta_appx+0x1c8>
movapd %xmm4,%xmm1
addsd  %xmm2,%xmm1
addsd  0xe5c(%rip),%xmm1
movsd  0xe4c(%rip),%xmm6
subsd  %xmm0,%xmm6
mulsd  %xmm6,%xmm1
movsd  0xe4c(%rip),%xmm3
ucomisd %xmm1,%xmm3
jae    12b1 <ibeta_appx+0x151>
ucomisd 0xe3a(%rip),%xmm1
jbe    1316 <ibeta_appx+0x1b6>
mulsd  %xmm2,%xmm0
movsd  0xe40(%rip),%xmm1
movapd %xmm2,0x20(%rsp)
movapd %xmm4,(%rsp)
movsd  %xmm6,0x18(%rsp)
call   1050 <pow@plt>
movapd %xmm0,0x30(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  (%rsp),%xmm0
movsd  0xe11(%rip),%xmm1
call   1050 <pow@plt>
movsd  0xe0c(%rip),%xmm1
movapd 0x20(%rsp),%xmm5
movapd %xmm5,%xmm2
mulsd  %xmm1,%xmm2
movsd  0xdc6(%rip),%xmm6
movapd %xmm6,%xmm3
divsd  %xmm2,%xmm3
movapd %xmm6,%xmm4
subsd  %xmm3,%xmm4
movapd (%rsp),%xmm3
mulsd  %xmm3,%xmm1
movapd %xmm6,%xmm2
divsd  %xmm1,%xmm2
subsd  %xmm2,%xmm6
mulsd  %xmm0,%xmm6
movapd 0x30(%rsp),%xmm1
mulsd  %xmm1,%xmm4
subsd  %xmm6,%xmm4
mulsd  0xdbf(%rip),%xmm4
divsd  0xdbf(%rip),%xmm4
unpcklpd %xmm0,%xmm1
mulpd  %xmm1,%xmm1
movapd %xmm5,%xmm0
unpcklpd %xmm3,%xmm0
divpd  %xmm0,%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     12ee <ibeta_appx+0x18e>
sqrtsd %xmm0,%xmm0
jmp    12fd <ibeta_appx+0x19d>
movsd  0xd5f(%rip),%xmm3
subsd  %xmm0,%xmm3
movsd  0xd43(%rip),%xmm0
addsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm6
mulsd  %xmm3,%xmm1
subsd  %xmm6,%xmm1
mulsd  0xd43(%rip),%xmm1
movapd %xmm1,%xmm0
movapd %xmm2,%xmm1
add    $0x48,%rsp
jmp    1040 <qgamma@plt>
movsd  %xmm4,(%rsp)
call   1060 <sqrt@plt>
movsd  (%rsp),%xmm4
divsd  %xmm0,%xmm4
movapd %xmm4,%xmm0
call   1080 <erfc@plt>
movapd %xmm0,%xmm1
mulsd  0xd0a(%rip),%xmm1
movapd %xmm1,%xmm0
add    $0x48,%rsp
ret
lea    0xd22(%rip),%rdi
jmp    132f <ibeta_appx+0x1cf>
lea    0xd48(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [47 x i8] c"x only accepts real values between 0.0 and 1.0\00"
@.str.1 = [47 x i8] c" The Two Inputs should be nonnegative and real\00"
define double @ibeta_appx(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 double
%12 = alloca double
%13 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%14 = load double, double* %4
%15 = fcmp olt double %14, 0.000000e+00
br i1 %15, label %19, label %16
16: ; preds = %3
%17 = load double, double* %4
%18 = fcmp ogt double %17, 1.000000e+00
br i1 %18, label %19, label %22
19: ; preds = %16, %3
%20 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %16
%23 = load double, double* %5
%24 = fcmp olt double %23, 0.000000e+00
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load double, double* %6
%27 = fcmp olt double %26, 0.000000e+00
br i1 %27, label %28, label %31
28: ; preds = %25, %22
%29 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %25
%32 = load double, double* %5
%33 = load double, double* %6
%34 = fadd double %32, %33
%35 = fsub double %34, 1.000000e+00
%36 = load double, double* %4
%37 = fsub double 1.000000e+00, %36
%38 = fmul double %35, %37
store double %38, double* %8
%39 = load double, double* %8
%40 = fcmp ole double %39, 8.000000e-01
br i1 %40, label %41, label %56
41: ; preds = %31
%42 = load double, double* %8
%43 = load double, double* %4
%44 = fsub double 3.000000e+00, %43
%45 = load double, double* %6
%46 = fsub double %45, 1.000000e+00
%47 = load double, double* %4
%48 = fsub double 1.000000e+00, %47
%49 = fmul double %46, %48
%50 = fneg double %49
%51 = call double @llvm.fmuladd.f64(double %42, double %44, double %50)
%52 = fdiv double %51, 2.000000e+00
store double %52, double* %9
%53 = load double, double* %9
%54 = load double, double* %6
%55 = call double @qgamma(double %53, double %54)
store double %55, double* %7
br label %103
56: ; preds = %31
%57 = load double, double* %8
%58 = fcmp ogt double %57, 8.000000e-01
br i1 %58, label %59, label %102
59: ; preds = %56
%60 = load double, double* %6
%61 = load double, double* %4
%62 = fmul double %60, %61
%63 = call double @pow(double %62, double 0x3FD5555555555555)
store double %63, double* %10
%64 = load double, double* %5
%65 = load double, double* %4
%66 = fsub double 1.000000e+00, %65
%67 = fmul double %64, %66
%68 = call double @pow(double %67, double 0x3FD5555555555555)
store double %68, double* %11
%69 = load double, double* %10
%70 = load double, double* %6
%71 = fmul double 9.000000e+00, %70
%72 = fdiv double 1.000000e+00, %71
%73 = fsub double 1.000000e+00, %72
%74 = load double, double* %11
%75 = load double, double* %5
%76 = fmul double 9.000000e+00, %75
%77 = fdiv double 1.000000e+00, %76
%78 = fsub double 1.000000e+00, %77
%79 = fmul double %74, %78
%80 = fneg double %79
%81 = call double @llvm.fmuladd.f64(double %69, double %73, double %80)
%82 = fmul double -3.000000e+00, %81
%83 = call double @sqrt(double 2.000000e+00)
%84 = fdiv double %82, %83
store double %84, double* %12
%85 = load double, double* %10
%86 = load double, double* %10
%87 = fmul double %85, %86
%88 = load double, double* %6
%89 = fdiv double %87, %88
%90 = load double, double* %11
%91 = load double, double* %11
%92 = fmul double %90, %91
%93 = load double, double* %5
%94 = fdiv double %92, %93
%95 = fadd double %89, %94
%96 = call double @sqrt(double %95)
store double %96, double* %13
%97 = load double, double* %12
%98 = load double, double* %13
%99 = fdiv double %97, %98
%100 = call double @erfc(double %99)
%101 = fdiv double %100, 2.000000e+00
store double %101, double* %7
br label %102
102: ; preds = %59, %56
br label %103
103: ; preds = %102, %41
%104 = load double, double* %7
ret double %104
}

LLVM IR (-O2):
@.str = [47 x i8] c"x only accepts real values between 0.0 and 1.0\00"
@.str.1 = [47 x i8] c" The Two Inputs should be nonnegative and real\00"
define double @ibeta_appx(double %0, double %1, double %2) {
%4 = fcmp olt double %0, 0.000000e+00
%5 = fcmp ogt double %0, 1.000000e+00
%6 = or i1 %4, %5
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %3
%11 = fcmp olt double %1, 0.000000e+00
%12 = fcmp olt double %2, 0.000000e+00
%13 = or i1 %11, %12
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %10
%18 = fadd double %1, %2
%19 = fadd double %18, -1.000000e+00
%20 = fsub double 1.000000e+00, %0
%21 = fmul double %20, %19
%22 = fcmp ugt double %21, 8.000000e-01
br i1 %22, label %31, label %23
23: ; preds = %17
%24 = fsub double 3.000000e+00, %0
%25 = fadd double %2, -1.000000e+00
%26 = fneg double %25
%27 = fmul double %20, %26
%28 = tail call double @llvm.fmuladd.f64(double %21, double %24, double %27)
%29 = fmul double %28, 5.000000e-01
%30 = tail call double @qgamma(double %29, double %2)
br label %62
31: ; preds = %17
%32 = fcmp ogt double %21, 8.000000e-01
br i1 %32, label %33, label %62
33: ; preds = %31
%34 = fmul double %0, %2
%35 = tail call double @pow(double %34, double 0x3FD5555555555555)
%36 = fmul double %20, %1
%37 = tail call double @pow(double %36, double 0x3FD5555555555555)
%38 = fmul double %2, 9.000000e+00
%39 = fdiv double 1.000000e+00, %38
%40 = fsub double 1.000000e+00, %39
%41 = fmul double %1, 9.000000e+00
%42 = fdiv double 1.000000e+00, %41
%43 = fsub double 1.000000e+00, %42
%44 = fneg double %37
%45 = fmul double %43, %44
%46 = tail call double @llvm.fmuladd.f64(double %35, double %40, double %45)
%47 = fmul double %46, -3.000000e+00
%48 = fdiv double %47, 0x3FF6A09E667F3BCD
%49 = insertelement <2 x double> poison, double %35, i64 0
%50 = insertelement <2 x double> %49, double %37, i64 1
%51 = fmul <2 x double> %50, %50
%52 = insertelement <2 x double> poison, double %2, i64 0
%53 = insertelement <2 x double> %52, double %1, i64 1
%54 = fdiv <2 x double> %51, %53
%55 = shufflevector <2 x double> %54, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%56 = fadd <2 x double> %54, %55
%57 = extractelement <2 x double> %56, i64 0
%58 = tail call double @sqrt(double %57)
%59 = fdiv double %48, %58
%60 = tail call double @erfc(double %59)
%61 = fmul double %60, 5.000000e-01
br label %62
62: ; preds = %31, %33, %23
%63 = phi double [ %30, %23 ], [ %61, %33 ], [ undef, %31 ]
ret double %63
}