#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 */
int /*<<< orphan*/ assert(int);
double dstrb_betacfd(double const, double const, double const);
scalar_t__ dstrb_log_gamma_function(double const);
double exp(scalar_t__);
double const log(double const);
double dstrb_beta_cdf(const double a, const double b, const double x) {
  assert(x >= 0.0 && x <= 1.0);
  double bt;
  if (x == 0.0 || x == 1.0)
    bt = 0.0;
  else
    bt = exp(dstrb_log_gamma_function(a + b) - dstrb_log_gamma_function(a) -
             dstrb_log_gamma_function(b) + a * log(x) + b * log(1.0 - x));
  if (x < (a + 1.0) / (a + b + 2.0))
    return bt * dstrb_betacfd(a, b, x) / a;
  else
    return 1.0 - bt * dstrb_betacfd(b, a, 1.0 - x) / b;
}


x86 assembly (clang, -O0):
<dstrb_beta_cdf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x29(%rbp)
jb     1191 <dstrb_beta_cdf+0x41>
movsd  0xe7a(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
setae  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11bb <dstrb_beta_cdf+0x6b>
jp     11bb <dstrb_beta_cdf+0x6b>
jmp    11d8 <dstrb_beta_cdf+0x88>
movsd  -0x20(%rbp),%xmm0
movsd  0xe38(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11e5 <dstrb_beta_cdf+0x95>
jp     11e5 <dstrb_beta_cdf+0x95>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    129c <dstrb_beta_cdf+0x14c>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
call   1040 <dstrb_log_gamma_function@plt>
mov    %rax,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <dstrb_log_gamma_function@plt>
mov    %rax,%rcx
mov    -0x60(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x58(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <dstrb_log_gamma_function@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
sub    %rcx,%rax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1070 <log@plt>
movsd  -0x50(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xd92(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
call   1070 <log@plt>
movsd  -0x40(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1060 <exp@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  0xd57(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
addsd  -0x18(%rbp),%xmm2
movsd  0xd48(%rip),%xmm3
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    130b <dstrb_beta_cdf+0x1bb>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
call   1030 <dstrb_betacfd@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1350 <dstrb_beta_cdf+0x200>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xcd9(%rip),%xmm2
subsd  -0x20(%rbp),%xmm2
call   1030 <dstrb_betacfd@plt>
movsd  -0x70(%rbp),%xmm1
mulsd  %xmm0,%xmm1
divsd  -0x18(%rbp),%xmm1
movsd  0xcb9(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dstrb_beta_cdf>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movsd  %xmm2,0x18(%rsp)
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm2
setae  %al
movsd  0xe90(%rip),%xmm3
ucomisd %xmm2,%xmm3
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
setae  %cl
and    %al,%cl
movzbl %cl,%edi
call   1050 <assert@plt>
movsd  0x18(%rsp),%xmm3
movsd  0x10(%rsp),%xmm1
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
ucomisd 0xe66(%rip),%xmm3
movapd %xmm1,%xmm2
addsd  0x8(%rsp),%xmm2
jne    11bc <dstrb_beta_cdf+0x6c>
jnp    1264 <dstrb_beta_cdf+0x114>
ucomisd 0xe3c(%rip),%xmm3
jne    11cc <dstrb_beta_cdf+0x7c>
jnp    1264 <dstrb_beta_cdf+0x114>
movapd %xmm2,%xmm0
movsd  %xmm2,0x20(%rsp)
call   1040 <dstrb_log_gamma_function@plt>
mov    %rax,%rbx
movsd  0x10(%rsp),%xmm0
call   1040 <dstrb_log_gamma_function@plt>
mov    %rax,%r14
movsd  0x8(%rsp),%xmm0
call   1040 <dstrb_log_gamma_function@plt>
add    %r14,%rax
sub    %rax,%rbx
xorps  %xmm0,%xmm0
cvtsi2sd %rbx,%xmm0
movsd  %xmm0,(%rsp)
movsd  0x18(%rsp),%xmm0
call   1070 <log@plt>
mulsd  0x10(%rsp),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xdd3(%rip),%xmm0
subsd  0x18(%rsp),%xmm0
call   1070 <log@plt>
mulsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
cvttsd2si %xmm0,%rdi
call   1060 <exp@plt>
movsd  0x20(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
movsd  0x10(%rsp),%xmm1
movsd  %xmm0,(%rsp)
movsd  0xd94(%rip),%xmm0
addsd  0xd94(%rip),%xmm2
addsd  %xmm1,%xmm0
divsd  %xmm2,%xmm0
ucomisd %xmm3,%xmm0
jbe    12a6 <dstrb_beta_cdf+0x156>
movapd %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
movapd %xmm3,%xmm2
call   1030 <dstrb_betacfd@plt>
movsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
divsd  0x10(%rsp),%xmm1
jmp    12dc <dstrb_beta_cdf+0x18c>
movsd  0xd52(%rip),%xmm2
subsd  %xmm3,%xmm2
movsd  0x8(%rsp),%xmm0
call   1030 <dstrb_betacfd@plt>
movsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
divsd  0x8(%rsp),%xmm1
movsd  0xd2c(%rip),%xmm0
subsd  %xmm1,%xmm0
movapd %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @dstrb_beta_cdf(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 oge double %9, 0.000000e+00
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load double, double* %7
%13 = fcmp ole double %12, 1.000000e+00
br label %14
14: ; preds = %11, %3
%15 = phi i1 [ false, %3 ], [ %13, %11 ]
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load double, double* %7
%19 = fcmp oeq double %18, 0.000000e+00
br i1 %19, label %23, label %20
20: ; preds = %14
%21 = load double, double* %7
%22 = fcmp oeq double %21, 1.000000e+00
br i1 %22, label %23, label %24
23: ; preds = %20, %14
store double 0.000000e+00, double* %8
br label %47
24: ; preds = %20
%25 = load double, double* %5
%26 = load double, double* %6
%27 = fadd double %25, %26
%28 = call i64 @dstrb_log_gamma_function(double %27)
%29 = load double, double* %5
%30 = call i64 @dstrb_log_gamma_function(double %29)
%31 = sub nsw i64 %28, %30
%32 = load double, double* %6
%33 = call i64 @dstrb_log_gamma_function(double %32)
%34 = sub nsw i64 %31, %33
%35 = sitofp i64 %34 to double
%36 = load double, double* %5
%37 = load double, double* %7
%38 = call double @log(double %37)
%39 = call double @llvm.fmuladd.f64(double %36, double %38, double %35)
%40 = load double, double* %6
%41 = load double, double* %7
%42 = fsub double 1.000000e+00, %41
%43 = call double @log(double %42)
%44 = call double @llvm.fmuladd.f64(double %40, double %43, double %39)
%45 = fptosi double %44 to i64
%46 = call double @exp(i64 %45)
store double %46, double* %8
br label %47
47: ; preds = %24, %23
%48 = load double, double* %7
%49 = load double, double* %5
%50 = fadd double %49, 1.000000e+00
%51 = load double, double* %5
%52 = load double, double* %6
%53 = fadd double %51, %52
%54 = fadd double %53, 2.000000e+00
%55 = fdiv double %50, %54
%56 = fcmp olt double %48, %55
br i1 %56, label %57, label %66
57: ; preds = %47
%58 = load double, double* %8
%59 = load double, double* %5
%60 = load double, double* %6
%61 = load double, double* %7
%62 = call double @dstrb_betacfd(double %59, double %60, double %61)
%63 = fmul double %58, %62
%64 = load double, double* %5
%65 = fdiv double %63, %64
store double %65, double* %4
br label %77
66: ; preds = %47
%67 = load double, double* %8
%68 = load double, double* %6
%69 = load double, double* %5
%70 = load double, double* %7
%71 = fsub double 1.000000e+00, %70
%72 = call double @dstrb_betacfd(double %68, double %69, double %71)
%73 = fmul double %67, %72
%74 = load double, double* %6
%75 = fdiv double %73, %74
%76 = fsub double 1.000000e+00, %75
store double %76, double* %4
br label %77
77: ; preds = %66, %57
%78 = load double, double* %4
ret double %78
}

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