#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 */
int Factorial(int);
int nCr(int n, int r) {
  int nFactorial = Factorial(n);
  if (nFactorial == -1)
    return -1;
  int rFactorial = Factorial(r);
  if (rFactorial == -1) {
    return -1;
  }
  int nmrFactorial = Factorial(n - r);
  if (nmrFactorial == -1) {
    return -1;
  }
  int denomiator = rFactorial * nmrFactorial;
  int returnValue = nFactorial / denomiator;
  return returnValue;
}


x86 assembly (clang, -O0):
<nCr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <Factorial@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jne    113f <nCr+0x2f>
movl   $0xffffffff,-0x4(%rbp)
jmp    119e <nCr+0x8e>
mov    -0xc(%rbp),%edi
call   1030 <Factorial@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1160 <nCr+0x50>
movl   $0xffffffff,-0x4(%rbp)
jmp    119e <nCr+0x8e>
mov    -0x8(%rbp),%edi
sub    -0xc(%rbp),%edi
call   1030 <Factorial@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1184 <nCr+0x74>
movl   $0xffffffff,-0x4(%rbp)
jmp    119e <nCr+0x8e>
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nCr>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebp
mov    %edi,%ebx
call   1030 <Factorial@plt>
mov    $0xffffffff,%r14d
cmp    $0xffffffff,%eax
je     115b <nCr+0x4b>
mov    %eax,%r15d
mov    %ebp,%edi
call   1030 <Factorial@plt>
cmp    $0xffffffff,%eax
je     115b <nCr+0x4b>
mov    %eax,%r12d
sub    %ebp,%ebx
mov    %ebx,%edi
call   1030 <Factorial@plt>
cmp    $0xffffffff,%eax
je     115b <nCr+0x4b>
mov    %eax,%ecx
imul   %r12d,%ecx
mov    %r15d,%eax
cltd
idiv   %ecx
mov    %eax,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @nCr(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%11 = load i32, i32* %4
%12 = call i32 @Factorial(i32 %11)
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %16
15: ; preds = %2
store i32 -1, i32* %3
br label %38
16: ; preds = %2
%17 = load i32, i32* %5
%18 = call i32 @Factorial(i32 %17)
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %22
21: ; preds = %16
store i32 -1, i32* %3
br label %38
22: ; preds = %16
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = sub nsw i32 %23, %24
%26 = call i32 @Factorial(i32 %25)
store i32 %26, i32* %8
%27 = load i32, i32* %8
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %30
29: ; preds = %22
store i32 -1, i32* %3
br label %38
30: ; preds = %22
%31 = load i32, i32* %7
%32 = load i32, i32* %8
%33 = mul nsw i32 %31, %32
store i32 %33, i32* %9
%34 = load i32, i32* %6
%35 = load i32, i32* %9
%36 = sdiv i32 %34, %35
store i32 %36, i32* %10
%37 = load i32, i32* %10
store i32 %37, i32* %3
br label %38
38: ; preds = %30, %29, %21, %15
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
define i32 @nCr(i32 %0, i32 %1) {
%3 = tail call i32 @Factorial(i32 %0)
%4 = icmp eq i32 %3, -1
br i1 %4, label %15, label %5
5: ; preds = %2
%6 = tail call i32 @Factorial(i32 %1)
%7 = icmp eq i32 %6, -1
br i1 %7, label %15, label %8
8: ; preds = %5
%9 = sub nsw i32 %0, %1
%10 = tail call i32 @Factorial(i32 %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %15, label %12
12: ; preds = %8
%13 = mul nsw i32 %10, %6
%14 = sdiv i32 %3, %13
br label %15
15: ; preds = %5, %8, %12, %2
%16 = phi i32 [ -1, %2 ], [ -1, %5 ], [ %14, %12 ], [ -1, %8 ]
ret i32 %16
}