#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 */
scalar_t__ LnGamma(double);
int /*<<< orphan*/ error2(char *);
double exp(double);
double log(int);
double PDFBeta(double x, double p, double q) {
  double y, small = 1e-20;
  if (x < small || x > 1 - small)
    error2("bad x in PDFbeta");
  y = (p - 1) * log(x) + (q - 1) * log(1 - x);
  y -= LnGamma(p) + LnGamma(q) - LnGamma(p + q);
  return (exp(y));
}


x86 assembly (clang, -O0):
<PDFBeta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  0xea1(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
ja     1194 <PDFBeta+0x54>
movsd  -0x8(%rbp),%xmm0
movsd  0xe83(%rip),%xmm1
subsd  -0x28(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a0 <PDFBeta+0x60>
lea    0xe75(%rip),%rdi
call   1030 <error2@plt>
movsd  -0x10(%rbp),%xmm0
movsd  0xe5b(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
cvttsd2si -0x8(%rbp),%edi
call   1050 <log@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe36(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe25(%rip),%xmm0
subsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <log@plt>
movsd  -0x50(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1060 <LnGamma@plt>
mov    %rax,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1060 <LnGamma@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
call   1060 <LnGamma@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
sub    %rcx,%rax
cvtsi2sd %rax,%xmm1
movsd  -0x20(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <exp@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PDFBeta>:
push   %r14
push   %rbx
sub    $0x38,%rsp
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  0xea5(%rip),%xmm1
ucomisd %xmm0,%xmm1
movsd  %xmm0,0x20(%rsp)
ja     1171 <PDFBeta+0x31>
ucomisd 0xe99(%rip),%xmm0
jbe    1183 <PDFBeta+0x43>
lea    0xea0(%rip),%rdi
call   1030 <error2@plt>
movsd  0x20(%rsp),%xmm0
movsd  0xe85(%rip),%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  0x18(%rsp),%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,0x30(%rsp)
cvttsd2si %xmm0,%edi
call   1050 <log@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xe3e(%rip),%xmm0
subsd  0x20(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <log@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
mulsd  0x30(%rsp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1060 <LnGamma@plt>
mov    %rax,%r14
movsd  0x10(%rsp),%xmm0
call   1060 <LnGamma@plt>
mov    %rax,%rbx
add    %r14,%rbx
movsd  0x18(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
call   1060 <LnGamma@plt>
sub    %rax,%rbx
xorps  %xmm1,%xmm1
cvtsi2sd %rbx,%xmm1
movsd  0x8(%rsp),%xmm0
subsd  %xmm1,%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r14
jmp    1040 <exp@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"bad x in PDFbeta\00"
define double @PDFBeta(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* %4
store double %1, double* %5
store double %2, double* %6
store double 0x3BC79CA10C924223, double* %8
%9 = load double, double* %4
%10 = load double, double* %8
%11 = fcmp olt double %9, %10
br i1 %11, label %17, label %12
12: ; preds = %3
%13 = load double, double* %4
%14 = load double, double* %8
%15 = fsub double 1.000000e+00, %14
%16 = fcmp ogt double %13, %15
br i1 %16, label %17, label %19
17: ; preds = %12, %3
%18 = call i32 @error2(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %12
%20 = load double, double* %5
%21 = fsub double %20, 1.000000e+00
%22 = load double, double* %4
%23 = fptosi double %22 to i32
%24 = call double @log(i32 %23)
%25 = load double, double* %6
%26 = fsub double %25, 1.000000e+00
%27 = load double, double* %4
%28 = fsub double 1.000000e+00, %27
%29 = fptosi double %28 to i32
%30 = call double @log(i32 %29)
%31 = fmul double %26, %30
%32 = call double @llvm.fmuladd.f64(double %21, double %24, double %31)
store double %32, double* %7
%33 = load double, double* %5
%34 = call i64 @LnGamma(double %33)
%35 = load double, double* %6
%36 = call i64 @LnGamma(double %35)
%37 = add nsw i64 %34, %36
%38 = load double, double* %5
%39 = load double, double* %6
%40 = fadd double %38, %39
%41 = call i64 @LnGamma(double %40)
%42 = sub nsw i64 %37, %41
%43 = sitofp i64 %42 to double
%44 = load double, double* %7
%45 = fsub double %44, %43
store double %45, double* %7
%46 = load double, double* %7
%47 = call double @exp(double %46)
ret double %47
}

LLVM IR (-O2):
@.str = [17 x i8] c"bad x in PDFbeta\00"
define double @PDFBeta(double %0, double %1, double %2) {
%4 = fcmp olt double %0, 0x3BC79CA10C924223
%5 = fcmp ogt double %0, 1.000000e+00
%6 = or i1 %4, %5
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @error2(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %3, %7
%10 = fadd double %1, -1.000000e+00
%11 = fptosi double %0 to i32
%12 = tail call double @log(i32 %11)
%13 = fadd double %2, -1.000000e+00
%14 = fsub double 1.000000e+00, %0
%15 = fptosi double %14 to i32
%16 = tail call double @log(i32 %15)
%17 = fmul double %13, %16
%18 = tail call double @llvm.fmuladd.f64(double %10, double %12, double %17)
%19 = tail call i64 @LnGamma(double %1)
%20 = tail call i64 @LnGamma(double %2)
%21 = add nsw i64 %20, %19
%22 = fadd double %1, %2
%23 = tail call i64 @LnGamma(double %22)
%24 = sub i64 %21, %23
%25 = sitofp i64 %24 to double
%26 = fsub double %18, %25
%27 = tail call double @exp(double %26)
ret double %27
}