#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 LogChoose(long, long);
double exp(double);
long log(double);
double pdfBinomial(long n, double p, long x) {
  double s, t;
  s = LogChoose(n, x);
  t = x * log(p) + (n - x) * log(1.0 - p);
  return (exp(s + t));
}


x86 assembly (clang, -O0):
<pdfBinomial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <LogChoose@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <log@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
imul   %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
sub    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
movsd  0xe74(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1040 <log@plt>
mov    -0x38(%rbp),%rcx
mov    %rax,%rdx
mov    -0x30(%rbp),%rax
imul   %rdx,%rcx
add    %rcx,%rax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
call   1030 <exp@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pdfBinomial>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
movsd  %xmm0,(%rsp)
mov    %rdi,%rbx
call   1050 <LogChoose@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1040 <log@plt>
mov    %rax,%r15
imul   %r14,%r15
sub    %r14,%rbx
movsd  0xe95(%rip),%xmm0
subsd  (%rsp),%xmm0
call   1040 <log@plt>
imul   %rbx,%rax
add    %r15,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <exp@plt>

LLVM IR (-O0):
define double @pdfBinomial(i64 %0, double %1, i64 %2) {
%4 = alloca i64
%5 = alloca double
%6 = alloca i64
%7 = alloca double
%8 = alloca double
store i64 %0, i64* %4
store double %1, double* %5
store i64 %2, i64* %6
%9 = load i64, i64* %4
%10 = load i64, i64* %6
%11 = call double @LogChoose(i64 %9, i64 %10)
store double %11, double* %7
%12 = load i64, i64* %6
%13 = load double, double* %5
%14 = call i64 @log(double %13)
%15 = mul nsw i64 %12, %14
%16 = load i64, i64* %4
%17 = load i64, i64* %6
%18 = sub nsw i64 %16, %17
%19 = load double, double* %5
%20 = fsub double 1.000000e+00, %19
%21 = call i64 @log(double %20)
%22 = mul nsw i64 %18, %21
%23 = add nsw i64 %15, %22
%24 = sitofp i64 %23 to double
store double %24, double* %8
%25 = load double, double* %7
%26 = load double, double* %8
%27 = fadd double %25, %26
%28 = call double @exp(double %27)
ret double %28
}

LLVM IR (-O2):
define double @pdfBinomial(i64 %0, double %1, i64 %2) {
%4 = tail call double @LogChoose(i64 %0, i64 %2)
%5 = tail call i64 @log(double %1)
%6 = mul nsw i64 %5, %2
%7 = sub nsw i64 %0, %2
%8 = fsub double 1.000000e+00, %1
%9 = tail call i64 @log(double %8)
%10 = mul nsw i64 %9, %7
%11 = add nsw i64 %10, %6
%12 = sitofp i64 %11 to double
%13 = fadd double %4, %12
%14 = tail call double @exp(double %13)
ret double %14
}