#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__ beta_log(double, double);
int /*<<< orphan*/ exit(int);
double exp(scalar_t__);
double log(int);
int /*<<< orphan*/ printf(char *);
double betapdf(double x, double a, double b) {
  double oup, la, lb;
  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);
  }
  if (a == 1. || x == 0.) {
    la = 0.;
  } else {
    la = (a - 1.) * log(x);
  }
  if (b == 1. || x == 1.) {
    lb = 0.;
  } else {
    lb = (b - 1.) * log(1. - x);
  }
  oup = exp(la + lb - beta_log(a, b));
  return oup;
}


x86 assembly (clang, -O0):
<betapdf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
ja     118c <betapdf+0x3c>
movsd  -0x8(%rbp),%xmm0
movsd  0xe7e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a2 <betapdf+0x52>
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     11be <betapdf+0x6e>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11d4 <betapdf+0x84>
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movsd  -0x10(%rbp),%xmm0
movsd  0xe1f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11f6 <betapdf+0xa6>
jp     11f6 <betapdf+0xa6>
jmp    120e <betapdf+0xbe>
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    121b <betapdf+0xcb>
jp     121b <betapdf+0xcb>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    124c <betapdf+0xfc>
movsd  -0x10(%rbp),%xmm0
movsd  0xdd8(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
cvttsd2si -0x8(%rbp),%edi
call   1060 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xda7(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    126e <betapdf+0x11e>
jp     126e <betapdf+0x11e>
jmp    128b <betapdf+0x13b>
movsd  -0x8(%rbp),%xmm0
movsd  0xd85(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1298 <betapdf+0x148>
jp     1298 <betapdf+0x148>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    12d5 <betapdf+0x185>
movsd  -0x18(%rbp),%xmm0
movsd  0xd5b(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xd4a(%rip),%xmm0
subsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1050 <beta_log@plt>
movsd  -0x48(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <exp@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<betapdf>:
sub    $0x28,%rsp
movapd %xmm0,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm3,%xmm0
ja     128d <betapdf+0x13d>
ucomisd 0xe92(%rip),%xmm3
ja     128d <betapdf+0x13d>
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
ja     1296 <betapdf+0x146>
ucomisd %xmm2,%xmm0
ja     1296 <betapdf+0x146>
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm3
xorpd  %xmm0,%xmm0
movsd  %xmm2,0x20(%rsp)
movsd  %xmm1,0x18(%rsp)
jne    11a8 <betapdf+0x58>
jnp    11f5 <betapdf+0xa5>
ucomisd 0xe50(%rip),%xmm1
xorpd  %xmm0,%xmm0
jne    11b8 <betapdf+0x68>
jnp    11f5 <betapdf+0xa5>
movsd  0xe48(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
cvttsd2si %xmm3,%edi
movsd  %xmm3,0x8(%rsp)
call   1060 <log@plt>
xorpd  %xmm4,%xmm4
movsd  0x8(%rsp),%xmm3
movsd  0x18(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
mulsd  0x10(%rsp),%xmm0
ucomisd 0xe03(%rip),%xmm3
jne    1201 <betapdf+0xb1>
jnp    1256 <betapdf+0x106>
ucomisd 0xdf7(%rip),%xmm2
jne    120d <betapdf+0xbd>
jnp    1256 <betapdf+0x106>
movsd  0xdf3(%rip),%xmm4
addsd  %xmm2,%xmm4
movsd  %xmm4,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
movsd  0xdd3(%rip),%xmm0
subsd  %xmm3,%xmm0
cvttsd2si %xmm0,%edi
call   1060 <log@plt>
movsd  0x18(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
movapd %xmm0,%xmm4
movsd  0x8(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm4
addsd  %xmm4,%xmm0
movsd  %xmm0,0x8(%rsp)
movapd %xmm1,%xmm0
movapd %xmm2,%xmm1
call   1050 <beta_log@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
add    $0x28,%rsp
jmp    1040 <exp@plt>
lea    0xd7c(%rip),%rdi
jmp    129d <betapdf+0x14d>
lea    0xda2(%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 @betapdf(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%10 = load double, double* %4
%11 = fcmp olt double %10, 0.000000e+00
br i1 %11, label %15, label %12
12: ; preds = %3
%13 = load double, double* %4
%14 = fcmp ogt double %13, 1.000000e+00
br i1 %14, label %15, label %18
15: ; preds = %12, %3
%16 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %12
%19 = load double, double* %5
%20 = fcmp olt double %19, 0.000000e+00
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = load double, double* %6
%23 = fcmp olt double %22, 0.000000e+00
br i1 %23, label %24, label %27
24: ; preds = %21, %18
%25 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %21
%28 = load double, double* %5
%29 = fcmp oeq double %28, 1.000000e+00
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = load double, double* %4
%32 = fcmp oeq double %31, 0.000000e+00
br i1 %32, label %33, label %34
33: ; preds = %30, %27
store double 0.000000e+00, double* %8
br label %41
34: ; preds = %30
%35 = load double, double* %5
%36 = fsub double %35, 1.000000e+00
%37 = load double, double* %4
%38 = fptosi double %37 to i32
%39 = call double @log(i32 %38)
%40 = fmul double %36, %39
store double %40, double* %8
br label %41
41: ; preds = %34, %33
%42 = load double, double* %6
%43 = fcmp oeq double %42, 1.000000e+00
br i1 %43, label %47, label %44
44: ; preds = %41
%45 = load double, double* %4
%46 = fcmp oeq double %45, 1.000000e+00
br i1 %46, label %47, label %48
47: ; preds = %44, %41
store double 0.000000e+00, double* %9
br label %56
48: ; preds = %44
%49 = load double, double* %6
%50 = fsub double %49, 1.000000e+00
%51 = load double, double* %4
%52 = fsub double 1.000000e+00, %51
%53 = fptosi double %52 to i32
%54 = call double @log(i32 %53)
%55 = fmul double %50, %54
store double %55, double* %9
br label %56
56: ; preds = %48, %47
%57 = load double, double* %8
%58 = load double, double* %9
%59 = fadd double %57, %58
%60 = load double, double* %5
%61 = load double, double* %6
%62 = call i64 @beta_log(double %60, double %61)
%63 = sitofp i64 %62 to double
%64 = fsub double %59, %63
%65 = fptosi double %64 to i64
%66 = call double @exp(i64 %65)
store double %66, double* %7
%67 = load double, double* %7
ret double %67
}

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 @betapdf(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 = fcmp oeq double %1, 1.000000e+00
%19 = fcmp oeq double %0, 0.000000e+00
%20 = or i1 %19, %18
br i1 %20, label %26, label %21
21: ; preds = %17
%22 = fadd double %1, -1.000000e+00
%23 = fptosi double %0 to i32
%24 = tail call double @log(i32 %23)
%25 = fmul double %22, %24
br label %26
26: ; preds = %17, %21
%27 = phi double [ %25, %21 ], [ 0.000000e+00, %17 ]
%28 = fcmp oeq double %2, 1.000000e+00
%29 = fcmp oeq double %0, 1.000000e+00
%30 = or i1 %29, %28
br i1 %30, label %37, label %31
31: ; preds = %26
%32 = fadd double %2, -1.000000e+00
%33 = fsub double 1.000000e+00, %0
%34 = fptosi double %33 to i32
%35 = tail call double @log(i32 %34)
%36 = fmul double %32, %35
br label %37
37: ; preds = %26, %31
%38 = phi double [ %36, %31 ], [ 0.000000e+00, %26 ]
%39 = fadd double %27, %38
%40 = tail call i64 @beta_log(double %1, double %2)
%41 = sitofp i64 %40 to double
%42 = fsub double %39, %41
%43 = fptosi double %42 to i64
%44 = tail call double @exp(i64 %43)
ret double %44
}