#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*/ permutations(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  char arr[20];
  int arrSize, i;
  printf("ENTER SIZE OF THE ARRAY:\n");
  scanf("%d", &arrSize);
  printf("\nENTER ELEMENTS INTO THE ARRAY:\n");
  for (i = 0; i < arrSize; i++) {
    scanf("%c", &arr[i]);
    if (arr[i] == '\n' || arr[i] == '\t' || arr[i] == ' ')
      i--;
  }
  printf("\nPermutations:\n");
  permutations(arr, 0, arrSize);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11e7 <main+0xb7>
movslq -0x28(%rbp),%rax
lea    -0x20(%rbp),%rsi
add    %rax,%rsi
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movslq -0x28(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0xa,%eax
je     11cb <main+0x9b>
movslq -0x28(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x9,%eax
je     11cb <main+0x9b>
movslq -0x28(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x20,%eax
jne    11d4 <main+0xa4>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    11d9 <main+0xa9>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1170 <main+0x40>
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
xor    %esi,%esi
call   1050 <permutations@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb3(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    11c4 <main+0x94>
lea    0xe90(%rip),%r15
movabs $0x100000600,%r14
xor    %ebp,%ebp
jmp    1199 <main+0x69>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jge    11c4 <main+0x94>
movslq %ebp,%rbx
lea    (%rsp,%rbx,1),%rsi
add    $0x10,%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <scanf@plt>
movzbl 0x10(%rsp,%rbx,1),%eax
cmp    $0x20,%rax
ja     1190 <main+0x60>
bt     %rax,%r14
jae    1190 <main+0x60>
add    $0xffffffff,%ebp
jmp    1190 <main+0x60>
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%edx
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1050 <permutations@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"ENTER SIZE OF THE ARRAY:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"\0AENTER ELEMENTS INTO THE ARRAY:\0A\00"
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [16 x i8] c"\0APermutations:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 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), i32* %3)
%7 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
br label %8
8: ; preds = %41, %0
%9 = load i32, i32* %4
%10 = load i32, i32* %3
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %44
12: ; preds = %8
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %14
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 10
br i1 %22, label %37, label %23
23: ; preds = %12
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 9
br i1 %29, label %37, label %30
30: ; preds = %23
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 32
br i1 %36, label %37, label %40
37: ; preds = %30, %23, %12
%38 = load i32, i32* %4
%39 = add nsw i32 %38, -1
store i32 %39, i32* %4
br label %40
40: ; preds = %37, %30
br label %41
41: ; preds = %40
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
store i32 %43, i32* %4
br label %8
44: ; preds = %8
%45 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%46 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%47 = load i32, i32* %3
%48 = call i32 @permutations(i8* %46, i32 0, i32 %47)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c"%c\00"
@str = [25 x i8] c"ENTER SIZE OF THE ARRAY:\00"
@str.5 = [32 x i8] c"\0AENTER ELEMENTS INTO THE ARRAY:\00"
@str.6 = [15 x i8] c"\0APermutations:\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 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), i32* %2)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.5, i64 0, i64 0))
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %23
10: ; preds = %0, %18
%11 = phi i32 [ %20, %18 ], [ 0, %0 ]
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %12
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%15 = load i8, i8* %13
switch i8 %15, label %18 [
i8 10, label %16
i8 9, label %16
i8 32, label %16
]
16: ; preds = %10, %10, %10
%17 = add nsw i32 %11, -1
br label %18
18: ; preds = %10, %16
%19 = phi i32 [ %17, %16 ], [ %11, %10 ]
%20 = add nsw i32 %19, 1
%21 = load i32, i32* %2
%22 = icmp slt i32 %20, %21
br i1 %22, label %10, label %23
23: ; preds = %18, %0
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.6, i64 0, i64 0))
%25 = load i32, i32* %2
%26 = call i32 @permutations(i8* %3, i32 0, i32 %25)
ret i32 0
}