#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;

/* Variables and functions */
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_divexact(int /*<<< orphan*/, int /*<<< orphan*/,
                                int /*<<< orphan*/);
int /*<<< orphan*/ mpz_fac_ui(int /*<<< orphan*/, unsigned long);
unsigned long mpz_get_ui(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_mul(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set_ui(int /*<<< orphan*/, int /*<<< orphan*/);
unsigned long int nCr(unsigned long int n, unsigned long int r) {
  mpz_t a, b, c, answer;
  unsigned long int ret;
  mpz_init(answer);
  mpz_init(a);
  mpz_init(b);
  mpz_init(c);
  if (n > r) {
    mpz_fac_ui(a, n);
    mpz_fac_ui(b, r);
    mpz_fac_ui(c, n - r);
    mpz_mul(b, b, c);
    mpz_divexact(answer, a, b);
  } else {
    mpz_set_ui(answer, 0);
  }
  ret = mpz_get_ui(answer);
  mpz_clear(answer);
  mpz_clear(a);
  mpz_clear(b);
  mpz_clear(c);
  return ret;
}


x86 assembly (clang, -O0):
<nCr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x20(%rbp),%edi
call   1030 <mpz_init@plt>
mov    -0x14(%rbp),%edi
call   1030 <mpz_init@plt>
mov    -0x18(%rbp),%edi
call   1030 <mpz_init@plt>
mov    -0x1c(%rbp),%edi
call   1030 <mpz_init@plt>
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jbe    11f7 <nCr+0x87>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1050 <mpz_fac_ui@plt>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <mpz_fac_ui@plt>
mov    -0x1c(%rbp),%edi
mov    -0x8(%rbp),%rsi
sub    -0x10(%rbp),%rsi
call   1050 <mpz_fac_ui@plt>
mov    -0x18(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <mpz_mul@plt>
mov    -0x20(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1070 <mpz_divexact@plt>
jmp    1201 <nCr+0x91>
mov    -0x20(%rbp),%edi
xor    %esi,%esi
call   1080 <mpz_set_ui@plt>
mov    -0x20(%rbp),%edi
call   1060 <mpz_get_ui@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%edi
call   1090 <mpz_clear@plt>
mov    -0x14(%rbp),%edi
call   1090 <mpz_clear@plt>
mov    -0x18(%rbp),%edi
call   1090 <mpz_clear@plt>
mov    -0x1c(%rbp),%edi
call   1090 <mpz_clear@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nCr>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <mpz_init@plt>
call   1030 <mpz_init@plt>
call   1030 <mpz_init@plt>
call   1030 <mpz_init@plt>
mov    %r15,%rbx
sub    %r14,%rbx
jbe    11bb <nCr+0x4b>
mov    %r15,%rsi
call   1050 <mpz_fac_ui@plt>
mov    %r14,%rsi
call   1050 <mpz_fac_ui@plt>
mov    %rbx,%rsi
call   1050 <mpz_fac_ui@plt>
call   1040 <mpz_mul@plt>
call   1070 <mpz_divexact@plt>
jmp    11c2 <nCr+0x52>
xor    %esi,%esi
call   1080 <mpz_set_ui@plt>
call   1060 <mpz_get_ui@plt>
mov    %rax,%rbx
call   1090 <mpz_clear@plt>
call   1090 <mpz_clear@plt>
call   1090 <mpz_clear@plt>
call   1090 <mpz_clear@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @nCr(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%10 = load i32, i32* %8
%11 = call i32 @mpz_init(i32 %10)
%12 = load i32, i32* %5
%13 = call i32 @mpz_init(i32 %12)
%14 = load i32, i32* %6
%15 = call i32 @mpz_init(i32 %14)
%16 = load i32, i32* %7
%17 = call i32 @mpz_init(i32 %16)
%18 = load i64, i64* %3
%19 = load i64, i64* %4
%20 = icmp ugt i64 %18, %19
br i1 %20, label %21, label %41
21: ; preds = %2
%22 = load i32, i32* %5
%23 = load i64, i64* %3
%24 = call i32 @mpz_fac_ui(i32 %22, i64 %23)
%25 = load i32, i32* %6
%26 = load i64, i64* %4
%27 = call i32 @mpz_fac_ui(i32 %25, i64 %26)
%28 = load i32, i32* %7
%29 = load i64, i64* %3
%30 = load i64, i64* %4
%31 = sub i64 %29, %30
%32 = call i32 @mpz_fac_ui(i32 %28, i64 %31)
%33 = load i32, i32* %6
%34 = load i32, i32* %6
%35 = load i32, i32* %7
%36 = call i32 @mpz_mul(i32 %33, i32 %34, i32 %35)
%37 = load i32, i32* %8
%38 = load i32, i32* %5
%39 = load i32, i32* %6
%40 = call i32 @mpz_divexact(i32 %37, i32 %38, i32 %39)
br label %44
41: ; preds = %2
%42 = load i32, i32* %8
%43 = call i32 @mpz_set_ui(i32 %42, i32 0)
br label %44
44: ; preds = %41, %21
%45 = load i32, i32* %8
%46 = call i64 @mpz_get_ui(i32 %45)
store i64 %46, i64* %9
%47 = load i32, i32* %8
%48 = call i32 @mpz_clear(i32 %47)
%49 = load i32, i32* %5
%50 = call i32 @mpz_clear(i32 %49)
%51 = load i32, i32* %6
%52 = call i32 @mpz_clear(i32 %51)
%53 = load i32, i32* %7
%54 = call i32 @mpz_clear(i32 %53)
%55 = load i64, i64* %9
ret i64 %55
}

LLVM IR (-O2):
define i64 @nCr(i64 %0, i64 %1) {
%3 = tail call i32 @mpz_init(i32 undef)
%4 = tail call i32 @mpz_init(i32 undef)
%5 = tail call i32 @mpz_init(i32 undef)
%6 = tail call i32 @mpz_init(i32 undef)
%7 = icmp ugt i64 %0, %1
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = tail call i32 @mpz_fac_ui(i32 undef, i64 %0)
%10 = tail call i32 @mpz_fac_ui(i32 undef, i64 %1)
%11 = sub i64 %0, %1
%12 = tail call i32 @mpz_fac_ui(i32 undef, i64 %11)
%13 = tail call i32 @mpz_mul(i32 undef, i32 undef, i32 undef)
%14 = tail call i32 @mpz_divexact(i32 undef, i32 undef, i32 undef)
br label %17
15: ; preds = %2
%16 = tail call i32 @mpz_set_ui(i32 undef, i32 0)
br label %17
17: ; preds = %15, %8
%18 = tail call i64 @mpz_get_ui(i32 undef)
%19 = tail call i32 @mpz_clear(i32 undef)
%20 = tail call i32 @mpz_clear(i32 undef)
%21 = tail call i32 @mpz_clear(i32 undef)
%22 = tail call i32 @mpz_clear(i32 undef)
ret i64 %18
}