#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 */
typedef int /*<<< orphan*/ mpz_t;
typedef int /*<<< orphan*/ mpf_t;

/* Variables and functions */
int /*<<< orphan*/ fp_poch_rising_d(int /*<<< orphan*/, double, unsigned int);
int /*<<< orphan*/ mpf_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpf_div(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpf_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpf_set_z(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_fac_ui(int /*<<< orphan*/, unsigned int);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
void fp_binomial_d(mpf_t bin, double s, unsigned int k) {
  mpf_t top, bot;
  mpz_t fac;
  mpf_init(top);
  mpf_init(bot);
  mpz_init(fac);
  fp_poch_rising_d(top, s - k + 1, k);
  mpz_fac_ui(fac, k);
  mpf_set_z(bot, fac);
  mpf_div(bin, top, bot);
  mpf_clear(top);
  mpf_clear(bot);
  mpz_clear(fac);
}


x86 assembly (clang, -O0):
<fp_binomial_d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <mpf_init@plt>
mov    -0x1c(%rbp),%edi
call   1050 <mpf_init@plt>
mov    -0x20(%rbp),%edi
call   1040 <mpz_init@plt>
mov    -0x18(%rbp),%edi
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%eax
cvtsi2sd %rax,%xmm1
subsd  %xmm1,%xmm0
movsd  0xe39(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x14(%rbp),%esi
call   1030 <fp_poch_rising_d@plt>
mov    -0x20(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1070 <mpz_fac_ui@plt>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1080 <mpf_set_z@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   10a0 <mpf_div@plt>
mov    -0x18(%rbp),%edi
call   1060 <mpf_clear@plt>
mov    -0x1c(%rbp),%edi
call   1060 <mpf_clear@plt>
mov    -0x20(%rbp),%edi
call   1090 <mpz_clear@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fp_binomial_d>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
movsd  %xmm0,(%rsp)
mov    %edi,%ebp
call   1050 <mpf_init@plt>
call   1050 <mpf_init@plt>
call   1040 <mpz_init@plt>
mov    %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
addsd  0xe4a(%rip),%xmm1
movapd %xmm1,%xmm0
mov    %ebx,%esi
call   1030 <fp_poch_rising_d@plt>
mov    %ebx,%esi
call   1070 <mpz_fac_ui@plt>
call   1080 <mpf_set_z@plt>
mov    %ebp,%edi
call   10a0 <mpf_div@plt>
call   1060 <mpf_clear@plt>
call   1060 <mpf_clear@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1090 <mpz_clear@plt>

LLVM IR (-O0):
define void @fp_binomial_d(i32 %0, double %1, i32 %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store double %1, double* %5
store i32 %2, i32* %6
%10 = load i32, i32* %7
%11 = call i32 @mpf_init(i32 %10)
%12 = load i32, i32* %8
%13 = call i32 @mpf_init(i32 %12)
%14 = load i32, i32* %9
%15 = call i32 @mpz_init(i32 %14)
%16 = load i32, i32* %7
%17 = load double, double* %5
%18 = load i32, i32* %6
%19 = uitofp i32 %18 to double
%20 = fsub double %17, %19
%21 = fadd double %20, 1.000000e+00
%22 = load i32, i32* %6
%23 = call i32 @fp_poch_rising_d(i32 %16, double %21, i32 %22)
%24 = load i32, i32* %9
%25 = load i32, i32* %6
%26 = call i32 @mpz_fac_ui(i32 %24, i32 %25)
%27 = load i32, i32* %8
%28 = load i32, i32* %9
%29 = call i32 @mpf_set_z(i32 %27, i32 %28)
%30 = load i32, i32* %4
%31 = load i32, i32* %7
%32 = load i32, i32* %8
%33 = call i32 @mpf_div(i32 %30, i32 %31, i32 %32)
%34 = load i32, i32* %7
%35 = call i32 @mpf_clear(i32 %34)
%36 = load i32, i32* %8
%37 = call i32 @mpf_clear(i32 %36)
%38 = load i32, i32* %9
%39 = call i32 @mpz_clear(i32 %38)
ret void
}

LLVM IR (-O2):
define void @fp_binomial_d(i32 %0, double %1, i32 %2) {
%4 = tail call i32 @mpf_init(i32 undef)
%5 = tail call i32 @mpf_init(i32 undef)
%6 = tail call i32 @mpz_init(i32 undef)
%7 = uitofp i32 %2 to double
%8 = fsub double %1, %7
%9 = fadd double %8, 1.000000e+00
%10 = tail call i32 @fp_poch_rising_d(i32 undef, double %9, i32 %2)
%11 = tail call i32 @mpz_fac_ui(i32 undef, i32 %2)
%12 = tail call i32 @mpf_set_z(i32 undef, i32 undef)
%13 = tail call i32 @mpf_div(i32 %0, i32 undef, i32 undef)
%14 = tail call i32 @mpf_clear(i32 undef)
%15 = tail call i32 @mpf_clear(i32 undef)
%16 = tail call i32 @mpz_clear(i32 undef)
ret void
}