#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 beta_help(double, double, int, char const *);
int /*<<< orphan*/ exit(int);
double exp(scalar_t__);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
scalar_t__ lngamma(double);
double log(int);
int /*<<< orphan*/ stderr;
double incomplete_beta(double a, double b, double x, const char *prompt) {
  double c;
  if (a <= 0 || b <= 0) {
    fprintf(stderr,
            "%s: IMPLEMENTATION ERROR! (Invalid argument in function "
            "\"incomplete_beta\")\n",
            prompt);
    exit(4);
  }
  if (x < 0 || x > 1) {
    fprintf(stderr, "%s: Value out of range (0-1)!\n", prompt);
    exit(4);
  }
  c = ((((x) != (x)) || ((0.) != (0.))
            ? (((x) != (x)) && ((0.) != (0.)) ? 1 : 0)
            : !(x < 0. || 0. < x)) ||
       (((x) != (x)) || ((1.) != (1.))
            ? (((x) != (x)) && ((1.) != (1.)) ? 1 : 0)
            : !(x < 1. || 1. < x)))
          ? 0
          : exp(lngamma(a + b) - lngamma(a) - lngamma(b) + a * log(x) +
                b * log(1 - x));
  if (x < (a + 1) / (a + b + 2))
    return c * beta_help(a, b, x, prompt) / a;
  else
    return 1 - c * beta_help(b, a, 1 - x, prompt) / b;
}


x86 assembly (clang, -O0):
<incomplete_beta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jae    119a <incomplete_beta+0x3a>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11bd <incomplete_beta+0x5d>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xe62(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x4,%edi
call   1080 <exit@plt>
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
ja     11e2 <incomplete_beta+0x82>
movsd  -0x20(%rbp),%xmm0
movsd  0xe28(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1205 <incomplete_beta+0xa5>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xe66(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x4,%edi
call   1080 <exit@plt>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jne    1220 <incomplete_beta+0xc0>
jp     1220 <incomplete_beta+0xc0>
jmp    1268 <incomplete_beta+0x108>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jne    123b <incomplete_beta+0xdb>
jp     123b <incomplete_beta+0xdb>
jmp    1259 <incomplete_beta+0xf9>
xor    %eax,%eax
test   $0x1,%al
jne    124a <incomplete_beta+0xea>
jmp    1259 <incomplete_beta+0xf9>
mov    $0x1,%al
test   $0x1,%al
jne    1315 <incomplete_beta+0x1b5>
jmp    1288 <incomplete_beta+0x128>
xor    %eax,%eax
test   $0x1,%al
jne    1315 <incomplete_beta+0x1b5>
jmp    1288 <incomplete_beta+0x128>
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
ja     1288 <incomplete_beta+0x128>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1315 <incomplete_beta+0x1b5>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jne    12a3 <incomplete_beta+0x143>
jp     12a3 <incomplete_beta+0x143>
jmp    12eb <incomplete_beta+0x18b>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jne    12be <incomplete_beta+0x15e>
jp     12be <incomplete_beta+0x15e>
jmp    12dc <incomplete_beta+0x17c>
xor    %eax,%eax
test   $0x1,%al
jne    12cd <incomplete_beta+0x16d>
jmp    12dc <incomplete_beta+0x17c>
mov    $0x1,%al
test   $0x1,%al
jne    1315 <incomplete_beta+0x1b5>
jmp    1322 <incomplete_beta+0x1c2>
xor    %eax,%eax
test   $0x1,%al
jne    1315 <incomplete_beta+0x1b5>
jmp    1322 <incomplete_beta+0x1c2>
movsd  0xd0d(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
ja     1322 <incomplete_beta+0x1c2>
movsd  -0x20(%rbp),%xmm0
movsd  0xcf5(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1322 <incomplete_beta+0x1c2>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    13dd <incomplete_beta+0x27d>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
call   1060 <lngamma@plt>
mov    %rax,-0x68(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1060 <lngamma@plt>
mov    %rax,%rcx
mov    -0x68(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1060 <lngamma@plt>
mov    %rax,%rcx
mov    -0x60(%rbp),%rax
sub    %rcx,%rax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
cvttsd2si -0x20(%rbp),%edi
call   1070 <log@plt>
movsd  -0x58(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xc55(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1070 <log@plt>
movsd  -0x48(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1050 <exp@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  0xc0c(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
addsd  -0x18(%rbp),%xmm2
movsd  0xbfd(%rip),%xmm3
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    145a <incomplete_beta+0x2fa>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
cvttsd2si -0x20(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   1030 <beta_help@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    14a7 <incomplete_beta+0x347>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xb8a(%rip),%xmm2
subsd  -0x20(%rbp),%xmm2
cvttsd2si %xmm2,%edi
mov    -0x28(%rbp),%rsi
call   1030 <beta_help@plt>
movsd  -0x78(%rbp),%xmm1
mulsd  %xmm0,%xmm1
divsd  -0x18(%rbp),%xmm1
movsd  0xb62(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<incomplete_beta>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%r14
movapd %xmm0,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm3,%xmm0
jae    131d <incomplete_beta+0x1bd>
ucomisd %xmm1,%xmm0
jae    131d <incomplete_beta+0x1bd>
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
ja     132f <incomplete_beta+0x1cf>
ucomisd 0xe62(%rip),%xmm2
ja     132f <incomplete_beta+0x1cf>
ucomisd %xmm2,%xmm2
setp   %al
movsd  0xe4d(%rip),%xmm0
ucomisd %xmm2,%xmm0
seta   %cl
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
movapd %xmm3,%xmm4
addsd  %xmm1,%xmm4
movsd  %xmm1,0x10(%rsp)
movsd  %xmm3,0x18(%rsp)
jae    1285 <incomplete_beta+0x125>
or     %cl,%al
je     1285 <incomplete_beta+0x125>
movapd %xmm4,%xmm0
movsd  %xmm2,0x8(%rsp)
movsd  %xmm4,0x28(%rsp)
call   1060 <lngamma@plt>
mov    %rax,%rbx
movsd  0x18(%rsp),%xmm0
call   1060 <lngamma@plt>
mov    %rax,%r15
movsd  0x10(%rsp),%xmm0
call   1060 <lngamma@plt>
add    %r15,%rax
sub    %rax,%rbx
xorps  %xmm0,%xmm0
cvtsi2sd %rbx,%xmm0
movsd  %xmm0,0x20(%rsp)
cvttsd2si 0x8(%rsp),%edi
call   1070 <log@plt>
mulsd  0x18(%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0xdb2(%rip),%xmm0
subsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1070 <log@plt>
mulsd  0x10(%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
cvttsd2si %xmm0,%rdi
call   1050 <exp@plt>
movsd  0x28(%rsp),%xmm4
movsd  0x8(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
movsd  %xmm0,0x8(%rsp)
movsd  0xd6d(%rip),%xmm0
addsd  0xd6d(%rip),%xmm4
addsd  %xmm3,%xmm0
divsd  %xmm4,%xmm0
ucomisd %xmm2,%xmm0
jbe    12d5 <incomplete_beta+0x175>
cvttsd2si %xmm2,%edi
movapd %xmm3,%xmm0
movsd  0x10(%rsp),%xmm1
mov    %r14,%rsi
call   1030 <beta_help@plt>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
divsd  0x18(%rsp),%xmm0
jmp    1313 <incomplete_beta+0x1b3>
movsd  0xd23(%rip),%xmm0
subsd  %xmm2,%xmm0
cvttsd2si %xmm0,%edi
movsd  0x10(%rsp),%xmm0
movapd %xmm3,%xmm1
mov    %r14,%rsi
call   1030 <beta_help@plt>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
divsd  0x10(%rsp),%xmm1
movsd  0xcf1(%rip),%xmm0
subsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2cbc(%rip),%rax
mov    (%rax),%edi
lea    0xce3(%rip),%rsi
jmp    133f <incomplete_beta+0x1df>
mov    0x2caa(%rip),%rax
mov    (%rax),%edi
lea    0xd1d(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    $0x4,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [76 x i8] c"%s: IMPLEMENTATION ERROR! (Invalid argument in function \22incomplete_beta\22)\0A\00"
@.str.1 = [31 x i8] c"%s: Value out of range (0-1)!\0A\00"
define double @incomplete_beta(double %0, double %1, double %2, i8* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i8*
%10 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store i8* %3, i8** %9
%11 = load double, double* %6
%12 = fcmp ole double %11, 0.000000e+00
br i1 %12, label %16, label %13
13: ; preds = %4
%14 = load double, double* %7
%15 = fcmp ole double %14, 0.000000e+00
br i1 %15, label %16, label %21
16: ; preds = %13, %4
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %9
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call i32 @exit(i32 4)
unreachable
21: ; preds = %13
%22 = load double, double* %8
%23 = fcmp olt double %22, 0.000000e+00
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = load double, double* %8
%26 = fcmp ogt double %25, 1.000000e+00
br i1 %26, label %27, label %32
27: ; preds = %24, %21
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %9
%30 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = call i32 @exit(i32 4)
unreachable
32: ; preds = %24
%33 = load double, double* %8
%34 = load double, double* %8
%35 = fcmp une double %33, %34
br i1 %35, label %36, label %43
36: ; preds = %32
%37 = load double, double* %8
%38 = load double, double* %8
%39 = fcmp une double %37, %38
br i1 %39, label %40, label %42
40: ; preds = %36
br i1 false, label %41, label %42
41: ; preds = %40
br i1 true, label %66, label %49
42: ; preds = %40, %36
br i1 false, label %66, label %49
43: ; preds = %32
%44 = load double, double* %8
%45 = fcmp olt double %44, 0.000000e+00
br i1 %45, label %49, label %46
46: ; preds = %43
%47 = load double, double* %8
%48 = fcmp olt double 0.000000e+00, %47
br i1 %48, label %49, label %66
49: ; preds = %46, %43, %42, %41
%50 = load double, double* %8
%51 = load double, double* %8
%52 = fcmp une double %50, %51
br i1 %52, label %53, label %60
53: ; preds = %49
%54 = load double, double* %8
%55 = load double, double* %8
%56 = fcmp une double %54, %55
br i1 %56, label %57, label %59
57: ; preds = %53
br i1 false, label %58, label %59
58: ; preds = %57
br i1 true, label %66, label %67
59: ; preds = %57, %53
br i1 false, label %66, label %67
60: ; preds = %49
%61 = load double, double* %8
%62 = fcmp olt double %61, 1.000000e+00
br i1 %62, label %67, label %63
63: ; preds = %60
%64 = load double, double* %8
%65 = fcmp olt double 1.000000e+00, %64
br i1 %65, label %67, label %66
66: ; preds = %63, %59, %58, %46, %42, %41
br label %92
67: ; preds = %63, %60, %59, %58
%68 = load double, double* %6
%69 = load double, double* %7
%70 = fadd double %68, %69
%71 = call i64 @lngamma(double %70)
%72 = load double, double* %6
%73 = call i64 @lngamma(double %72)
%74 = sub nsw i64 %71, %73
%75 = load double, double* %7
%76 = call i64 @lngamma(double %75)
%77 = sub nsw i64 %74, %76
%78 = sitofp i64 %77 to double
%79 = load double, double* %6
%80 = load double, double* %8
%81 = fptosi double %80 to i32
%82 = call double @log(i32 %81)
%83 = call double @llvm.fmuladd.f64(double %79, double %82, double %78)
%84 = load double, double* %7
%85 = load double, double* %8
%86 = fsub double 1.000000e+00, %85
%87 = fptosi double %86 to i32
%88 = call double @log(i32 %87)
%89 = call double @llvm.fmuladd.f64(double %84, double %88, double %83)
%90 = fptosi double %89 to i64
%91 = call double @exp(i64 %90)
br label %92
92: ; preds = %67, %66
%93 = phi double [ 0.000000e+00, %66 ], [ %91, %67 ]
store double %93, double* %10
%94 = load double, double* %8
%95 = load double, double* %6
%96 = fadd double %95, 1.000000e+00
%97 = load double, double* %6
%98 = load double, double* %7
%99 = fadd double %97, %98
%100 = fadd double %99, 2.000000e+00
%101 = fdiv double %96, %100
%102 = fcmp olt double %94, %101
br i1 %102, label %103, label %114
103: ; preds = %92
%104 = load double, double* %10
%105 = load double, double* %6
%106 = load double, double* %7
%107 = load double, double* %8
%108 = fptosi double %107 to i32
%109 = load i8*, i8** %9
%110 = call double @beta_help(double %105, double %106, i32 %108, i8* %109)
%111 = fmul double %104, %110
%112 = load double, double* %6
%113 = fdiv double %111, %112
store double %113, double* %5
br label %127
114: ; preds = %92
%115 = load double, double* %10
%116 = load double, double* %7
%117 = load double, double* %6
%118 = load double, double* %8
%119 = fsub double 1.000000e+00, %118
%120 = fptosi double %119 to i32
%121 = load i8*, i8** %9
%122 = call double @beta_help(double %116, double %117, i32 %120, i8* %121)
%123 = fmul double %115, %122
%124 = load double, double* %7
%125 = fdiv double %123, %124
%126 = fsub double 1.000000e+00, %125
store double %126, double* %5
br label %127
127: ; preds = %114, %103
%128 = load double, double* %5
ret double %128
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [76 x i8] c"%s: IMPLEMENTATION ERROR! (Invalid argument in function \22incomplete_beta\22)\0A\00"
@.str.1 = [31 x i8] c"%s: Value out of range (0-1)!\0A\00"
define double @incomplete_beta(double %0, double %1, double %2, i8* %3) {
%5 = fcmp ole double %0, 0.000000e+00
%6 = fcmp ole double %1, 0.000000e+00
%7 = or i1 %5, %6
br i1 %7, label %8, label %12
8: ; preds = %4
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0), i8* %3)
%11 = tail call i32 @exit(i32 4)
unreachable
12: ; preds = %4
%13 = fcmp olt double %2, 0.000000e+00
%14 = fcmp ogt double %2, 1.000000e+00
%15 = or i1 %13, %14
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%19 = tail call i32 @exit(i32 4)
unreachable
20: ; preds = %12
%21 = fcmp uno double %2, 0.000000e+00
%22 = fcmp ugt double %2, 0.000000e+00
%23 = fcmp olt double %2, 1.000000e+00
%24 = or i1 %21, %23
%25 = and i1 %22, %24
%26 = fadd double %0, %1
br i1 %25, label %27, label %43
27: ; preds = %20
%28 = tail call i64 @lngamma(double %26)
%29 = tail call i64 @lngamma(double %0)
%30 = tail call i64 @lngamma(double %1)
%31 = add i64 %29, %30
%32 = sub i64 %28, %31
%33 = sitofp i64 %32 to double
%34 = fptosi double %2 to i32
%35 = tail call double @log(i32 %34)
%36 = tail call double @llvm.fmuladd.f64(double %0, double %35, double %33)
%37 = fsub double 1.000000e+00, %2
%38 = fptosi double %37 to i32
%39 = tail call double @log(i32 %38)
%40 = tail call double @llvm.fmuladd.f64(double %1, double %39, double %36)
%41 = fptosi double %40 to i64
%42 = tail call double @exp(i64 %41)
br label %43
43: ; preds = %20, %27
%44 = phi double [ %42, %27 ], [ 0.000000e+00, %20 ]
%45 = fadd double %0, 1.000000e+00
%46 = fadd double %26, 2.000000e+00
%47 = fdiv double %45, %46
%48 = fcmp ogt double %47, %2
br i1 %48, label %49, label %54
49: ; preds = %43
%50 = fptosi double %2 to i32
%51 = tail call double @beta_help(double %0, double %1, i32 %50, i8* %3)
%52 = fmul double %44, %51
%53 = fdiv double %52, %0
br label %61
54: ; preds = %43
%55 = fsub double 1.000000e+00, %2
%56 = fptosi double %55 to i32
%57 = tail call double @beta_help(double %1, double %0, i32 %56, i8* %3)
%58 = fmul double %44, %57
%59 = fdiv double %58, %1
%60 = fsub double 1.000000e+00, %59
br label %61
61: ; preds = %54, %49
%62 = phi double [ %53, %49 ], [ %60, %54 ]
ret double %62
}