#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int strlen(char *);
int main() {
  int r, n, p, x, k, i, j;
  char a[100];
  printf("Enter the string");
  scanf("%s", a);
  n = strlen(a);
  printf("Enter r\n");
  scanf("%d", &r);
  k = (n - r);
  x = 1;
  for (i = n, j = k; i >= 1, j >= 1; i--, j--) {
    r = x * i / j;
  }
  printf("The r combinations of a given string are %d ", r);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x90(%rbp),%rsi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    -0x90(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe94(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x1,-0x20(%rbp)
jl     11df <main+0xaf>
mov    -0x14(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltd
idivl  -0x20(%rbp)
mov    %eax,-0x8(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    11b0 <main+0x80>
mov    -0x8(%rbp),%esi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb4(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
lea    0xec7(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8b(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
cmp    %esi,%ebx
jle    11a4 <main+0x64>
add    $0x1,%esi
mov    %esi,0xc(%rsp)
lea    0xe6c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Enter the string\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [9 x i8] c"Enter r\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [45 x i8] c"The r combinations of a given string are %d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [100 x i8]
store i32 0, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%17 = load i32, i32* %3
%18 = load i32, i32* %2
%19 = sub nsw i32 %17, %18
store i32 %19, i32* %6
store i32 1, i32* %5
%20 = load i32, i32* %3
store i32 %20, i32* %7
%21 = load i32, i32* %6
store i32 %21, i32* %8
br label %22
22: ; preds = %34, %0
%23 = load i32, i32* %7
%24 = icmp sge i32 %23, 1
%25 = zext i1 %24 to i32
%26 = load i32, i32* %8
%27 = icmp sge i32 %26, 1
br i1 %27, label %28, label %39
28: ; preds = %22
%29 = load i32, i32* %5
%30 = load i32, i32* %7
%31 = mul nsw i32 %29, %30
%32 = load i32, i32* %8
%33 = sdiv i32 %31, %32
store i32 %33, i32* %2
br label %34
34: ; preds = %28
%35 = load i32, i32* %7
%36 = add nsw i32 %35, -1
store i32 %36, i32* %7
%37 = load i32, i32* %8
%38 = add nsw i32 %37, -1
store i32 %38, i32* %8
br label %22
39: ; preds = %22
%40 = load i32, i32* %2
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i32 %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Enter the string\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [45 x i8] c"The r combinations of a given string are %d \00"
@str = [8 x i8] c"Enter r\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%7 = call i32 @strlen(i8* %4)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = icmp sgt i32 %7, %10
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = add nsw i32 %10, 1
store i32 %13, i32* %1
br label %14
14: ; preds = %12, %0
%15 = phi i32 [ %13, %12 ], [ %10, %0 ]
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i32 %15)
ret i32 0
}