#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(double, double, char const *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
double pow(int, double);
int /*<<< orphan*/ stderr;
double beta_distr_density(double a, double b, double x, const char *prompt) {
  if (a <= 0 || b <= 0) {
    fprintf(stderr,
            "%s: IMPLEMENTATION ERROR! (Invalid argument in function "
            "\"beta_distr_density\")\n",
            prompt);
    exit(4);
  }
  return x <= 0   ? 0
         : x >= 1 ? 1
                  : pow(x, a - 1) * pow(1 - x, b - 1) / beta(a, b, prompt);
}


x86 assembly (clang, -O0):
<beta_distr_density>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jae    1177 <beta_distr_density+0x37>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     119a <beta_distr_density+0x5a>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe7d(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x4,%edi
call   1060 <exit@plt>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11b5 <beta_distr_density+0x75>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1264 <beta_distr_density+0x124>
movsd  -0x18(%rbp),%xmm0
movsd  0xe3e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11de <beta_distr_density+0x9e>
movsd  0xe2c(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    125a <beta_distr_density+0x11a>
cvttsd2si -0x18(%rbp),%edi
movsd  -0x8(%rbp),%xmm0
movsd  0xe10(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1050 <pow@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  0xdfa(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
movsd  -0x10(%rbp),%xmm0
movsd  0xde4(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    -0x20(%rbp),%rdi
call   1040 <beta@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<beta_distr_density>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
movapd %xmm0,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm3,%xmm0
jae    1202 <beta_distr_density+0xc2>
ucomisd %xmm1,%xmm0
jae    1202 <beta_distr_density+0xc2>
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
jae    11fc <beta_distr_density+0xbc>
movsd  0xe86(%rip),%xmm0
ucomisd %xmm0,%xmm2
jae    11fc <beta_distr_density+0xbc>
cvttsd2si %xmm2,%edi
movapd %xmm3,%xmm0
addsd  0xe78(%rip),%xmm0
movsd  %xmm1,0x8(%rsp)
movsd  %xmm3,0x18(%rsp)
movsd  %xmm2,0x10(%rsp)
call   1050 <pow@plt>
movsd  %xmm0,(%rsp)
movsd  0xe4c(%rip),%xmm0
subsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%edi
movsd  0xe42(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
call   1050 <pow@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %rbx,%rdi
call   1040 <beta@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbx
ret
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
lea    0xdfe(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
mov    $0x4,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [79 x i8] c"%s: IMPLEMENTATION ERROR! (Invalid argument in function \22beta_distr_density\22)\0A\00"
define double @beta_distr_density(double %0, double %1, double %2, i8* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i8*
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store i8* %3, i8** %8
%9 = load double, double* %5
%10 = fcmp ole double %9, 0.000000e+00
br i1 %10, label %14, label %11
11: ; preds = %4
%12 = load double, double* %6
%13 = fcmp ole double %12, 0.000000e+00
br i1 %13, label %14, label %19
14: ; preds = %11, %4
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %8
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 4)
unreachable
19: ; preds = %11
%20 = load double, double* %7
%21 = fcmp ole double %20, 0.000000e+00
br i1 %21, label %22, label %23
22: ; preds = %19
br label %47
23: ; preds = %19
%24 = load double, double* %7
%25 = fcmp oge double %24, 1.000000e+00
br i1 %25, label %26, label %27
26: ; preds = %23
br label %45
27: ; preds = %23
%28 = load double, double* %7
%29 = fptosi double %28 to i32
%30 = load double, double* %5
%31 = fsub double %30, 1.000000e+00
%32 = call double @pow(i32 %29, double %31)
%33 = load double, double* %7
%34 = fsub double 1.000000e+00, %33
%35 = fptosi double %34 to i32
%36 = load double, double* %6
%37 = fsub double %36, 1.000000e+00
%38 = call double @pow(i32 %35, double %37)
%39 = fmul double %32, %38
%40 = load double, double* %5
%41 = load double, double* %6
%42 = load i8*, i8** %8
%43 = call double @beta(double %40, double %41, i8* %42)
%44 = fdiv double %39, %43
br label %45
45: ; preds = %27, %26
%46 = phi double [ 1.000000e+00, %26 ], [ %44, %27 ]
br label %47
47: ; preds = %45, %22
%48 = phi double [ 0.000000e+00, %22 ], [ %46, %45 ]
ret double %48
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [79 x i8] c"%s: IMPLEMENTATION ERROR! (Invalid argument in function \22beta_distr_density\22)\0A\00"
define double @beta_distr_density(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 ([79 x i8], [79 x i8]* @.str, i64 0, i64 0), i8* %3)
%11 = tail call i32 @exit(i32 4)
unreachable
12: ; preds = %4
%13 = fcmp ugt double %2, 0.000000e+00
br i1 %13, label %14, label %27
14: ; preds = %12
%15 = fcmp ult double %2, 1.000000e+00
br i1 %15, label %16, label %27
16: ; preds = %14
%17 = fptosi double %2 to i32
%18 = fadd double %0, -1.000000e+00
%19 = tail call double @pow(i32 %17, double %18)
%20 = fsub double 1.000000e+00, %2
%21 = fptosi double %20 to i32
%22 = fadd double %1, -1.000000e+00
%23 = tail call double @pow(i32 %21, double %22)
%24 = fmul double %19, %23
%25 = tail call double @beta(double %0, double %1, i8* %3)
%26 = fdiv double %24, %25
br label %27
27: ; preds = %16, %14, %12
%28 = phi double [ 0.000000e+00, %12 ], [ %26, %16 ], [ 1.000000e+00, %14 ]
ret double %28
}