#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 exp(double);
double lgamma(int);
int log(double);
double probability(double p, double q, int m, int n) {
  double temp = lgamma(m + n + 1.0);
  temp -= lgamma(n + 1.0) + lgamma(m + 1.0);
  temp += m * log(p) + n * log(q);
  return exp(temp);
}


x86 assembly (clang, -O0):
<probability>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    %esi,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xea6(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <lgamma@plt>
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x18(%rbp),%xmm0
movsd  0xe87(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <lgamma@plt>
movsd  %xmm0,-0x38(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xe68(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <lgamma@plt>
movsd  -0x38(%rbp),%xmm1
addsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <log@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <log@plt>
mov    -0x28(%rbp),%ecx
mov    %eax,%edx
mov    -0x24(%rbp),%eax
imul   %edx,%ecx
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <exp@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<probability>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %esi,%r14d
mov    %edi,%ebx
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x10(%rsp)
lea    (%r14,%rbx,1),%edi
add    $0x1,%edi
call   1040 <lgamma@plt>
movsd  %xmm0,(%rsp)
lea    0x1(%r14),%edi
call   1040 <lgamma@plt>
movsd  %xmm0,0x8(%rsp)
lea    0x1(%rbx),%edi
call   1040 <lgamma@plt>
addsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <log@plt>
mov    %eax,%ebp
imul   %ebx,%ebp
movsd  0x18(%rsp),%xmm0
call   1050 <log@plt>
imul   %r14d,%eax
add    %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  (%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <exp@plt>

LLVM IR (-O0):
define double @probability(double %0, double %1, i32 %2, i32 %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
store double %0, double* %5
store double %1, double* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %7
%11 = load i32, i32* %8
%12 = add nsw i32 %10, %11
%13 = sitofp i32 %12 to double
%14 = fadd double %13, 1.000000e+00
%15 = fptosi double %14 to i32
%16 = call double @lgamma(i32 %15)
store double %16, double* %9
%17 = load i32, i32* %8
%18 = sitofp i32 %17 to double
%19 = fadd double %18, 1.000000e+00
%20 = fptosi double %19 to i32
%21 = call double @lgamma(i32 %20)
%22 = load i32, i32* %7
%23 = sitofp i32 %22 to double
%24 = fadd double %23, 1.000000e+00
%25 = fptosi double %24 to i32
%26 = call double @lgamma(i32 %25)
%27 = fadd double %21, %26
%28 = load double, double* %9
%29 = fsub double %28, %27
store double %29, double* %9
%30 = load i32, i32* %7
%31 = load double, double* %5
%32 = call i32 @log(double %31)
%33 = mul nsw i32 %30, %32
%34 = load i32, i32* %8
%35 = load double, double* %6
%36 = call i32 @log(double %35)
%37 = mul nsw i32 %34, %36
%38 = add nsw i32 %33, %37
%39 = sitofp i32 %38 to double
%40 = load double, double* %9
%41 = fadd double %40, %39
store double %41, double* %9
%42 = load double, double* %9
%43 = call double @exp(double %42)
ret double %43
}

LLVM IR (-O2):
define double @probability(double %0, double %1, i32 %2, i32 %3) {
%5 = add nsw i32 %3, %2
%6 = add i32 %5, 1
%7 = tail call double @lgamma(i32 %6)
%8 = add i32 %3, 1
%9 = tail call double @lgamma(i32 %8)
%10 = add i32 %2, 1
%11 = tail call double @lgamma(i32 %10)
%12 = fadd double %9, %11
%13 = fsub double %7, %12
%14 = tail call i32 @log(double %0)
%15 = mul nsw i32 %14, %2
%16 = tail call i32 @log(double %1)
%17 = mul nsw i32 %16, %3
%18 = add nsw i32 %17, %15
%19 = sitofp i32 %18 to double
%20 = fadd double %13, %19
%21 = tail call double @exp(double %20)
ret double %21
}