#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 fact(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  int n, r, p1, p2, p3;
  printf("Enter the values of n and r ");
  scanf("%d %d", &n, &r);
  p1 = fact(n);
  p2 = fact(r);
  p3 = fact(n - r);
  printf("The value of ncr is %d", p1 / (p2 * p3));
  printf("The value of npr is %d", p1 / p2);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
call   1050 <scanf@plt>
mov    -0x4(%rbp),%edi
call   1040 <fact@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <fact@plt>
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
sub    -0x8(%rbp),%edi
call   1040 <fact@plt>
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
imul   -0x14(%rbp),%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1050 <scanf@plt>
mov    0x4(%rsp),%edi
call   1040 <fact@plt>
mov    %eax,%ebx
mov    (%rsp),%edi
call   1040 <fact@plt>
mov    %eax,%ebp
mov    0x4(%rsp),%edi
sub    (%rsp),%edi
call   1040 <fact@plt>
mov    %eax,%ecx
imul   %ebp,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
lea    0xe9c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%eax
cltd
idiv   %ebp
lea    0xe9e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Enter the values of n and r \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [23 x i8] c"The value of ncr is %d\00"
@.str.3 = [23 x i8] c"The value of npr is %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%8 = load i32, i32* %1
%9 = call i32 @fact(i32 %8)
store i32 %9, i32* %3
%10 = load i32, i32* %2
%11 = call i32 @fact(i32 %10)
store i32 %11, i32* %4
%12 = load i32, i32* %1
%13 = load i32, i32* %2
%14 = sub nsw i32 %12, %13
%15 = call i32 @fact(i32 %14)
store i32 %15, i32* %5
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = load i32, i32* %5
%19 = mul nsw i32 %17, %18
%20 = sdiv i32 %16, %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = sdiv i32 %22, %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"Enter the values of n and r \00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [23 x i8] c"The value of ncr is %d\00"
@.str.3 = [23 x i8] c"The value of npr is %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = load i32, i32* %1
%8 = call i32 @fact(i32 %7)
%9 = load i32, i32* %2
%10 = call i32 @fact(i32 %9)
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = sub nsw i32 %11, %12
%14 = call i32 @fact(i32 %13)
%15 = mul nsw i32 %14, %10
%16 = sdiv i32 %8, %15
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = sdiv i32 %8, %10
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %18)
ret i32 0
}