#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*/ fatalx(char *, double, double, double);
int /*<<< orphan*/ finite(double);
scalar_t__ lbeta(double, double);
double log(double);
double bprob(double p, double a, double b) {
  double q, yl;
  q = 1.0 - p;
  yl = (a - 1) * log(p) + (b - 1) * log(q);
  if (!finite(yl))
    fatalx("bad bprob %9.3f %9.3f %9.3f\n", p, a, b);
  yl -= lbeta(a, b);
  if (!finite(yl))
    fatalx("bad bprob (lbeta) %9.3f %9.3f %9.3f\n", p, a, b);
  return yl;
}


x86 assembly (clang, -O0):
<bprob>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  0xeb9(%rip),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xea2(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <log@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe7d(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1050 <log@plt>
movsd  -0x40(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movaps 0xe43(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe27(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11fe <bprob+0xce>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
lea    0xe27(%rip),%rdi
call   1030 <fatalx@plt>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1040 <lbeta@plt>
cvtsi2sd %rax,%xmm1
movsd  -0x28(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movaps 0xde4(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xdc8(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    125d <bprob+0x12d>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
lea    0xde5(%rip),%rdi
call   1030 <fatalx@plt>
movsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bprob>:
sub    $0x48,%rsp
movsd  %xmm2,0x8(%rsp)
movsd  0xebe(%rip),%xmm2
subsd  %xmm0,%xmm2
movsd  %xmm2,0x38(%rsp)
movsd  0xeb4(%rip),%xmm2
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
addsd  %xmm2,%xmm1
movsd  %xmm1,0x40(%rsp)
movsd  %xmm0,0x30(%rsp)
call   1050 <log@plt>
movapd %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0x38(%rsp),%xmm0
call   1050 <log@plt>
mulsd  0x18(%rsp),%xmm0
movapd 0x20(%rsp),%xmm1
mulsd  0x40(%rsp),%xmm1
addsd  %xmm0,%xmm1
movapd 0xe6a(%rip),%xmm0
movapd %xmm1,0x20(%rsp)
andpd  %xmm1,%xmm0
ucomisd 0xe48(%rip),%xmm0
jne    11e8 <bprob+0xb8>
lea    0xe5f(%rip),%rdi
movsd  0x30(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
call   1030 <fatalx@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   1040 <lbeta@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movapd 0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd 0xe0d(%rip),%xmm0
andpd  %xmm1,%xmm0
ucomisd 0xdf1(%rip),%xmm0
jne    124b <bprob+0x11b>
lea    0xe25(%rip),%rdi
movsd  0x30(%rsp),%xmm0
movapd %xmm1,0x20(%rsp)
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
call   1030 <fatalx@plt>
movapd 0x20(%rsp),%xmm1
movapd %xmm1,%xmm0
add    $0x48,%rsp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"bad bprob %9.3f %9.3f %9.3f\0A\00"
@.str.1 = [37 x i8] c"bad bprob (lbeta) %9.3f %9.3f %9.3f\0A\00"
define double @bprob(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
%9 = load double, double* %4
%10 = fsub double 1.000000e+00, %9
store double %10, double* %7
%11 = load double, double* %5
%12 = fsub double %11, 1.000000e+00
%13 = load double, double* %4
%14 = call double @log(double %13)
%15 = load double, double* %6
%16 = fsub double %15, 1.000000e+00
%17 = load double, double* %7
%18 = call double @log(double %17)
%19 = fmul double %16, %18
%20 = call double @llvm.fmuladd.f64(double %12, double %14, double %19)
store double %20, double* %8
%21 = load double, double* %8
%22 = call double @llvm.fabs.f64(double %21)
%23 = fcmp one double %22, 0x7FF0000000000000
br i1 %23, label %29, label %24
24: ; preds = %3
%25 = load double, double* %4
%26 = load double, double* %5
%27 = load double, double* %6
%28 = call i32 @fatalx(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), double %25, double %26, double %27)
br label %29
29: ; preds = %24, %3
%30 = load double, double* %5
%31 = load double, double* %6
%32 = call i64 @lbeta(double %30, double %31)
%33 = sitofp i64 %32 to double
%34 = load double, double* %8
%35 = fsub double %34, %33
store double %35, double* %8
%36 = load double, double* %8
%37 = call double @llvm.fabs.f64(double %36)
%38 = fcmp one double %37, 0x7FF0000000000000
br i1 %38, label %44, label %39
39: ; preds = %29
%40 = load double, double* %4
%41 = load double, double* %5
%42 = load double, double* %6
%43 = call i32 @fatalx(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double %40, double %41, double %42)
br label %44
44: ; preds = %39, %29
%45 = load double, double* %8
ret double %45
}

LLVM IR (-O2):
@.str = [29 x i8] c"bad bprob %9.3f %9.3f %9.3f\0A\00"
@.str.1 = [37 x i8] c"bad bprob (lbeta) %9.3f %9.3f %9.3f\0A\00"
define double @bprob(double %0, double %1, double %2) {
%4 = fsub double 1.000000e+00, %0
%5 = fadd double %1, -1.000000e+00
%6 = tail call double @log(double %0)
%7 = fadd double %2, -1.000000e+00
%8 = tail call double @log(double %4)
%9 = fmul double %7, %8
%10 = tail call double @llvm.fmuladd.f64(double %5, double %6, double %9)
%11 = tail call double @llvm.fabs.f64(double %10)
%12 = fcmp ueq double %11, 0x7FF0000000000000
br i1 %12, label %13, label %15
13: ; preds = %3
%14 = tail call i32 @fatalx(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), double %0, double %1, double %2)
br label %15
15: ; preds = %13, %3
%16 = tail call i64 @lbeta(double %1, double %2)
%17 = sitofp i64 %16 to double
%18 = fsub double %10, %17
%19 = tail call double @llvm.fabs.f64(double %18)
%20 = fcmp ueq double %19, 0x7FF0000000000000
br i1 %20, label %21, label %23
21: ; preds = %15
%22 = tail call i32 @fatalx(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double %0, double %1, double %2)
br label %23
23: ; preds = %21, %15
ret double %18
}