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


x86 assembly (clang, -O0):
<pdfPascal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
add    -0x18(%rbp),%rdi
sub    $0x1,%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
mov    %rax,-0x38(%rbp)
movsd  0xe70(%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):
<pdfPascal>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r15
movsd  %xmm0,(%rsp)
mov    %rdi,%r14
add    %rsi,%rdi
add    $0xffffffffffffffff,%rdi
call   1050 <LogChoose@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1040 <log@plt>
mov    %rax,%rbx
imul   %r15,%rbx
movsd  0xe91(%rip),%xmm0
subsd  (%rsp),%xmm0
call   1040 <log@plt>
imul   %r14,%rax
add    %rbx,%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 @pdfPascal(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 = add nsw i64 %9, %10
%12 = sub nsw i64 %11, 1
%13 = load i64, i64* %6
%14 = call double @LogChoose(i64 %12, i64 %13)
store double %14, double* %7
%15 = load i64, i64* %6
%16 = load double, double* %5
%17 = call i64 @log(double %16)
%18 = mul nsw i64 %15, %17
%19 = load i64, i64* %4
%20 = load double, double* %5
%21 = fsub double 1.000000e+00, %20
%22 = call i64 @log(double %21)
%23 = mul nsw i64 %19, %22
%24 = add nsw i64 %18, %23
%25 = sitofp i64 %24 to double
store double %25, double* %8
%26 = load double, double* %7
%27 = load double, double* %8
%28 = fadd double %26, %27
%29 = call double @exp(double %28)
ret double %29
}

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