#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 */
long factorielle(unsigned long, int);
int /*<<< orphan*/ printf(char *);
unsigned long nCr(unsigned long n, unsigned long p) {
  long nombreCombinaison = 0;
  if ((n >= 0) && (p >= 0))
    nombreCombinaison =
        factorielle(n, 1) / (factorielle(p, 1) * factorielle(n - p, 1));
  else
    printf("Input error : only positive numbers allowed for nCr\n");
  return nombreCombinaison;
}


x86 assembly (clang, -O0):
<nCr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
jb     11a1 <nCr+0x81>
cmpq   $0x0,-0x10(%rbp)
jb     11a1 <nCr+0x81>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1040 <factorielle@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1040 <factorielle@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
sub    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1040 <factorielle@plt>
mov    -0x28(%rbp),%rcx
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
imul   %rdx,%rcx
cqto
idiv   %rcx
mov    %rax,-0x18(%rbp)
jmp    11ad <nCr+0x8d>
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nCr>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%rbx
mov    $0x1,%esi
call   1030 <factorielle@plt>
mov    %rax,%r14
mov    %r15,%rdi
mov    $0x1,%esi
call   1030 <factorielle@plt>
mov    %rax,%r12
sub    %r15,%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <factorielle@plt>
mov    %rax,%rcx
imul   %r12,%rcx
mov    %r14,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     1168 <nCr+0x58>
mov    %r14,%rax
cqto
idiv   %rcx
jmp    116f <nCr+0x5f>
mov    %r14d,%eax
xor    %edx,%edx
div    %ecx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [53 x i8] c"Input error : only positive numbers allowed for nCr\0A\00"
define i64 @nCr(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
store i64 0, i64* %5
%6 = load i64, i64* %3
%7 = icmp uge i64 %6, 0
br i1 %7, label %8, label %22
8: ; preds = %2
%9 = load i64, i64* %4
%10 = icmp uge i64 %9, 0
br i1 %10, label %11, label %22
11: ; preds = %8
%12 = load i64, i64* %3
%13 = call i64 @factorielle(i64 %12, i32 1)
%14 = load i64, i64* %4
%15 = call i64 @factorielle(i64 %14, i32 1)
%16 = load i64, i64* %3
%17 = load i64, i64* %4
%18 = sub i64 %16, %17
%19 = call i64 @factorielle(i64 %18, i32 1)
%20 = mul nsw i64 %15, %19
%21 = sdiv i64 %13, %20
store i64 %21, i64* %5
br label %24
22: ; preds = %8, %2
%23 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %11
%25 = load i64, i64* %5
ret i64 %25
}

LLVM IR (-O2):
define i64 @nCr(i64 %0, i64 %1) {
%3 = tail call i64 @factorielle(i64 %0, i32 1)
%4 = tail call i64 @factorielle(i64 %1, i32 1)
%5 = sub i64 %0, %1
%6 = tail call i64 @factorielle(i64 %5, i32 1)
%7 = mul nsw i64 %6, %4
%8 = sdiv i64 %3, %7
ret i64 %8
}