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


x86 assembly (clang, -O0):
<beta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jae    1172 <beta+0x32>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1195 <beta+0x55>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe7a(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x4,%edi
call   1060 <exit@plt>
movsd  -0x8(%rbp),%xmm0
call   1050 <lngamma@plt>
mov    %rax,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <lngamma@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
call   1050 <lngamma@plt>
mov    -0x20(%rbp),%rdi
sub    %rax,%rdi
call   1040 <exp@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<beta>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rdx
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm2
jae    1198 <beta+0x58>
ucomisd %xmm1,%xmm2
jae    1198 <beta+0x58>
movsd  %xmm0,0x8(%rsp)
movsd  %xmm1,(%rsp)
call   1050 <lngamma@plt>
mov    %rax,%rbx
movsd  (%rsp),%xmm0
call   1050 <lngamma@plt>
add    %rax,%rbx
movsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
call   1050 <lngamma@plt>
sub    %rax,%rbx
mov    %rbx,%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1040 <exp@plt>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
lea    0xe58(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x4,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [65 x i8] c"%s: IMPLEMENTATION ERROR! (Invalid argument in function \22beta\22)\0A\00"
define double @beta(double %0, double %1, i8* %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca i8*
store double %0, double* %4
store double %1, double* %5
store i8* %2, i8** %6
%7 = load double, double* %4
%8 = fcmp ole double %7, 0.000000e+00
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = load double, double* %5
%11 = fcmp ole double %10, 0.000000e+00
br i1 %11, label %12, label %17
12: ; preds = %9, %3
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %6
%15 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = call i32 @exit(i32 4)
unreachable
17: ; preds = %9
%18 = load double, double* %4
%19 = call i64 @lngamma(double %18)
%20 = load double, double* %5
%21 = call i64 @lngamma(double %20)
%22 = add nsw i64 %19, %21
%23 = load double, double* %4
%24 = load double, double* %5
%25 = fadd double %23, %24
%26 = call i64 @lngamma(double %25)
%27 = sub nsw i64 %22, %26
%28 = call double @exp(i64 %27)
ret double %28
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [65 x i8] c"%s: IMPLEMENTATION ERROR! (Invalid argument in function \22beta\22)\0A\00"
define double @beta(double %0, double %1, i8* %2) {
%4 = fcmp ole double %0, 0.000000e+00
%5 = fcmp ole double %1, 0.000000e+00
%6 = or i1 %4, %5
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* %2)
%10 = tail call i32 @exit(i32 4)
unreachable
11: ; preds = %3
%12 = tail call i64 @lngamma(double %0)
%13 = tail call i64 @lngamma(double %1)
%14 = add nsw i64 %13, %12
%15 = fadd double %0, %1
%16 = tail call i64 @lngamma(double %15)
%17 = sub i64 %14, %16
%18 = tail call double @exp(i64 %17)
ret double %18
}