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

/* Variables and functions */
int factorial(int);
int /*<<< orphan*/ printf(char *, int, ...);
uint64_t nCr_tupples(uint64_t n, uint64_t r) {
  if (n >= r) {
    printf("%luC%lu = %lu\n", n, r,
           (factorial(n) / ((factorial(n - r) * factorial(r)))));
    printf(" %lu\n", (factorial(n)));
    printf(" %lu\n", factorial(n - r));
    printf(" %lu\n", factorial(r));
    return (factorial(n) / ((factorial(n - r) * factorial(r))));
  } else {
    printf("Error: n < r (%lu, %lu)\n", n, r);
  }
}


x86 assembly (clang, -O0):
<nCr_tupples>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     120d <nCr_tupples+0xed>
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <factorial@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
sub    -0xc(%rbp),%edi
call   1030 <factorial@plt>
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <factorial@plt>
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%esi
mov    %eax,%edx
mov    -0x1c(%rbp),%eax
imul   %edx,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%edx
mov    %eax,%ecx
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1030 <factorial@plt>
mov    %eax,%esi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
sub    -0xc(%rbp),%edi
call   1030 <factorial@plt>
mov    %eax,%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%edi
call   1030 <factorial@plt>
mov    %eax,%esi
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1030 <factorial@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
sub    -0xc(%rbp),%edi
call   1030 <factorial@plt>
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <factorial@plt>
mov    -0x14(%rbp),%ecx
mov    %eax,%edx
mov    -0x10(%rbp),%eax
imul   %edx,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
jmp    1221 <nCr_tupples+0x101>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nCr_tupples>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebx
mov    %edi,%ebp
sub    %esi,%ebp
jge    114b <nCr_tupples+0x2b>
lea    0xed5(%rip),%rdi
mov    %ebx,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ed <nCr_tupples+0xcd>
mov    %ebx,%edi
call   1030 <factorial@plt>
mov    %eax,%r15d
mov    %ebp,%edi
call   1030 <factorial@plt>
mov    %eax,%r12d
mov    %r14d,%edi
call   1030 <factorial@plt>
mov    %eax,%ecx
imul   %r12d,%ecx
mov    %r15d,%eax
cltd
idiv   %ecx
lea    0xe86(%rip),%rdi
mov    %ebx,%esi
mov    %r14d,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
call   1030 <factorial@plt>
lea    0xe73(%rip),%r15
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
call   1030 <factorial@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%edi
call   1030 <factorial@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
call   1030 <factorial@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1030 <factorial@plt>
mov    %eax,%ebp
mov    %r14d,%edi
call   1030 <factorial@plt>
mov    %eax,%ecx
imul   %ebp,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"%luC%lu = %lu\0A\00"
@.str.1 = [6 x i8] c" %lu\0A\00"
@.str.2 = [25 x i8] c"Error: n < r (%lu, %lu)\0A\00"
define i32 @nCr_tupples(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = load i32, i32* %5
%8 = icmp sge i32 %6, %7
br i1 %8, label %9, label %44
9: ; preds = %2
%10 = load i32, i32* %4
%11 = load i32, i32* %5
%12 = load i32, i32* %4
%13 = call i32 @factorial(i32 %12)
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = sub nsw i32 %14, %15
%17 = call i32 @factorial(i32 %16)
%18 = load i32, i32* %5
%19 = call i32 @factorial(i32 %18)
%20 = mul nsw i32 %17, %19
%21 = sdiv i32 %13, %20
%22 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11, i32 %21)
%23 = load i32, i32* %4
%24 = call i32 @factorial(i32 %23)
%25 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = sub nsw i32 %26, %27
%29 = call i32 @factorial(i32 %28)
%30 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %5
%32 = call i32 @factorial(i32 %31)
%33 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %4
%35 = call i32 @factorial(i32 %34)
%36 = load i32, i32* %4
%37 = load i32, i32* %5
%38 = sub nsw i32 %36, %37
%39 = call i32 @factorial(i32 %38)
%40 = load i32, i32* %5
%41 = call i32 @factorial(i32 %40)
%42 = mul nsw i32 %39, %41
%43 = sdiv i32 %35, %42
store i32 %43, i32* %3
br label %48
44: ; preds = %2
%45 = load i32, i32* %4
%46 = load i32, i32* %5
%47 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %45, i32 %46)
br label %48
48: ; preds = %9, %44
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@.str = [15 x i8] c"%luC%lu = %lu\0A\00"
@.str.1 = [6 x i8] c" %lu\0A\00"
@.str.2 = [25 x i8] c"Error: n < r (%lu, %lu)\0A\00"
define i32 @nCr_tupples(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, %1
br i1 %3, label %23, label %4
4: ; preds = %2
%5 = tail call i32 @factorial(i32 %0)
%6 = sub nsw i32 %0, %1
%7 = tail call i32 @factorial(i32 %6)
%8 = tail call i32 @factorial(i32 %1)
%9 = mul nsw i32 %8, %7
%10 = sdiv i32 %5, %9
%11 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1, i32 %10)
%12 = tail call i32 @factorial(i32 %0)
%13 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = tail call i32 @factorial(i32 %6)
%15 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = tail call i32 @factorial(i32 %1)
%17 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = tail call i32 @factorial(i32 %0)
%19 = tail call i32 @factorial(i32 %6)
%20 = tail call i32 @factorial(i32 %1)
%21 = mul nsw i32 %20, %19
%22 = sdiv i32 %18, %21
br label %25
23: ; preds = %2
%24 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %0, i32 %1)
br label %25
25: ; preds = %4, %23
%26 = phi i32 [ %22, %4 ], [ undef, %23 ]
ret i32 %26
}