#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 pow(int, double);
double tgamma(double);
double uniform();
double beta(double a, double b) {
  double x = uniform();
  return ((tgamma(a + b) / (tgamma(a) * tgamma(b))) * pow(x, a - 1) *
          pow(1 - x, b - 1));
}


x86 assembly (clang, -O0):
<beta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    $0x0,%al
call   1030 <uniform@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
call   1040 <tgamma@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <tgamma@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <tgamma@plt>
movsd  -0x38(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
cvttsd2si -0x18(%rbp),%edi
movsd  -0x8(%rbp),%xmm0
movsd  0xe59(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe37(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
movsd  -0x10(%rbp),%xmm0
movsd  0xe21(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<beta>:
sub    $0x28,%rsp
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <uniform@plt>
movsd  %xmm0,0x18(%rsp)
movsd  (%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
call   1040 <tgamma@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1040 <tgamma@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <tgamma@plt>
mulsd  0x20(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
cvttsd2si 0x18(%rsp),%edi
movsd  (%rsp),%xmm0
addsd  0xe5a(%rip),%xmm0
call   1050 <pow@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xe4a(%rip),%xmm0
subsd  0x18(%rsp),%xmm0
cvttsd2si %xmm0,%edi
movsd  0x10(%rsp),%xmm0
addsd  0xe2a(%rip),%xmm0
call   1050 <pow@plt>
mulsd  (%rsp),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @beta(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %3
store double %1, double* %4
%6 = call double (...) @uniform()
store double %6, double* %5
%7 = load double, double* %3
%8 = load double, double* %4
%9 = fadd double %7, %8
%10 = call double @tgamma(double %9)
%11 = load double, double* %3
%12 = call double @tgamma(double %11)
%13 = load double, double* %4
%14 = call double @tgamma(double %13)
%15 = fmul double %12, %14
%16 = fdiv double %10, %15
%17 = load double, double* %5
%18 = fptosi double %17 to i32
%19 = load double, double* %3
%20 = fsub double %19, 1.000000e+00
%21 = call double @pow(i32 %18, double %20)
%22 = fmul double %16, %21
%23 = load double, double* %5
%24 = fsub double 1.000000e+00, %23
%25 = fptosi double %24 to i32
%26 = load double, double* %4
%27 = fsub double %26, 1.000000e+00
%28 = call double @pow(i32 %25, double %27)
%29 = fmul double %22, %28
ret double %29
}

LLVM IR (-O2):
define double @beta(double %0, double %1) {
%3 = tail call double (...) @uniform()
%4 = fadd double %0, %1
%5 = tail call double @tgamma(double %4)
%6 = tail call double @tgamma(double %0)
%7 = tail call double @tgamma(double %1)
%8 = fmul double %6, %7
%9 = fdiv double %5, %8
%10 = fptosi double %3 to i32
%11 = fadd double %0, -1.000000e+00
%12 = tail call double @pow(i32 %10, double %11)
%13 = fmul double %12, %9
%14 = fsub double 1.000000e+00, %3
%15 = fptosi double %14 to i32
%16 = fadd double %1, -1.000000e+00
%17 = tail call double @pow(i32 %15, double %16)
%18 = fmul double %17, %13
ret double %18
}