#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 *, ...);
void AllPermutation(int a[], int n, int depth, int b[]) {
  if (depth < n) {
    int i;
    for (i = 0; i < n; i++) {
      b[depth] = a[i];
      AllPermutation(a, n, depth + 1, b);
    }
  } else {
    int j;
    printf("\n");
    for (j = 0; j < n; j++) {
      printf("%d", b[j]);
    }
  }
}


x86 assembly (clang, -O0):
<AllPermutation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1194 <AllPermutation+0x74>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118f <AllPermutation+0x6f>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
mov    -0x18(%rbp),%rcx
call   1030 <AllPermutation@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1149 <AllPermutation+0x29>
jmp    11e1 <AllPermutation+0xc1>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11dc <AllPermutation+0xbc>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a9 <AllPermutation+0x89>
jmp    11e1 <AllPermutation+0xc1>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AllPermutation>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %esi,0x4(%rsp)
cmp    %esi,%edx
jge    1196 <AllPermutation+0x66>
cmpl   $0x0,0x4(%rsp)
jle    11d6 <AllPermutation+0xa6>
mov    %edx,%r15d
mov    %rdi,%rbp
movslq %edx,%r12
add    $0x1,%r15d
mov    0x4(%rsp),%r13d
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
mov    0x0(%rbp,%r14,4),%eax
mov    %eax,(%rbx,%r12,4)
mov    %rbp,%rdi
mov    0x4(%rsp),%esi
mov    %r15d,%edx
mov    %rbx,%rcx
call   1040 <AllPermutation@plt>
add    $0x1,%r14
cmp    %r14,%r13
jne    1170 <AllPermutation+0x40>
jmp    11d6 <AllPermutation+0xa6>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpl   $0x0,0x4(%rsp)
jle    11d6 <AllPermutation+0xa6>
mov    0x4(%rsp),%r15d
lea    0xe4d(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rbx,%rbp,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    11c0 <AllPermutation+0x90>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [3 x i8] c"%d\00"
define void @AllPermutation(i32* %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32* %3, i32** %8
%11 = load i32, i32* %7
%12 = load i32, i32* %6
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %38
14: ; preds = %4
store i32 0, i32* %9
br label %15
15: ; preds = %34, %14
%16 = load i32, i32* %9
%17 = load i32, i32* %6
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %37
19: ; preds = %15
%20 = load i32*, i32** %5
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
%24 = load i32, i32* %23
%25 = load i32*, i32** %8
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
store i32 %24, i32* %28
%29 = load i32*, i32** %5
%30 = load i32, i32* %6
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
%33 = load i32*, i32** %8
br label %34
34: ; preds = %19
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
store i32 %36, i32* %9
br label %15
37: ; preds = %15
br label %55
38: ; preds = %4
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %10
br label %40
40: ; preds = %51, %38
%41 = load i32, i32* %10
%42 = load i32, i32* %6
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %54
44: ; preds = %40
%45 = load i32*, i32** %8
%46 = load i32, i32* %10
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %45, i64 %47
%49 = load i32, i32* %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %44
%52 = load i32, i32* %10
%53 = add nsw i32 %52, 1
store i32 %53, i32* %10
br label %40
54: ; preds = %40
br label %55
55: ; preds = %54, %37
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
define void @AllPermutation(i32* nocapture %0, i32 %1, i32 %2, i32* nocapture %3) {
%5 = icmp slt i32 %2, %1
br i1 %5, label %6, label %19
6: ; preds = %4
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %31
8: ; preds = %6
%9 = sext i32 %2 to i64
%10 = getelementptr inbounds i32, i32* %3, i64 %9
%11 = add nsw i32 %2, 1
%12 = zext i32 %1 to i64
br label %13
13: ; preds = %8, %13
%14 = phi i64 [ 0, %8 ], [ %17, %13 ]
%15 = getelementptr inbounds i32, i32* %0, i64 %14
%16 = load i32, i32* %15
store i32 %16, i32* %10
tail call void @AllPermutation(i32* %0, i32 %1, i32 %11, i32* %3)
%17 = add nuw nsw i64 %14, 1
%18 = icmp eq i64 %17, %12
br i1 %18, label %31, label %13
19: ; preds = %4
%20 = tail call i32 @putchar(i32 10)
%21 = icmp sgt i32 %1, 0
br i1 %21, label %22, label %31
22: ; preds = %19
%23 = zext i32 %1 to i64
br label %24
24: ; preds = %22, %24
%25 = phi i64 [ 0, %22 ], [ %29, %24 ]
%26 = getelementptr inbounds i32, i32* %3, i64 %25
%27 = load i32, i32* %26
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = add nuw nsw i64 %25, 1
%30 = icmp eq i64 %29, %23
br i1 %30, label %31, label %24
31: ; preds = %24, %13, %19, %6
ret void
}