#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);
int /*<<< orphan*/ puts(char *);
void recursive_truc(int i, int n, int *T) {
  int j, temp;
  if (i == n) {
    for (j = 0; j < n; j++) {
      printf("%d", T[j]);
    }
    puts("");
  } else {
    for (j = i; j < n; j++) {
      temp = T[i];
      T[i] = T[j];
      T[j] = temp;
      recursive_truc(i + 1, n, T);
      temp = T[i];
      T[i] = T[j];
      T[j] = temp;
    }
  }
}


x86 assembly (clang, -O0):
<recursive_truc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1197 <recursive_truc+0x67>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1186 <recursive_truc+0x56>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1155 <recursive_truc+0x25>
lea    0xe75(%rip),%rdi
call   1030 <puts@plt>
jmp    1232 <recursive_truc+0x102>
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    122d <recursive_truc+0xfd>
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%edi
add    $0x1,%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1050 <recursive_truc@plt>
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119d <recursive_truc+0x6d>
jmp    1232 <recursive_truc+0x102>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recursive_truc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %edi,%r15d
cmp    %esi,%edi
jne    118c <recursive_truc+0x5c>
test   %r15d,%r15d
jle    1174 <recursive_truc+0x44>
mov    %r15d,%r15d
xor    %ebp,%ebp
lea    0xeaa(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx,%rbp,4),%esi
mov    %r14,%rdi
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1160 <recursive_truc+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
jge    11ec <recursive_truc+0xbc>
mov    %esi,%r13d
movslq %r15d,%r12
lea    (%rbx,%r12,4),%rbp
mov    %esi,%eax
sub    %r15d,%eax
mov    %rax,(%rsp)
add    $0x1,%r15d
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%r12,4),%eax
mov    0x0(%rbp,%r14,4),%ecx
mov    %ecx,(%rbx,%r12,4)
mov    %eax,0x0(%rbp,%r14,4)
mov    %r15d,%edi
mov    %r13d,%esi
mov    %rbx,%rdx
call   1050 <recursive_truc@plt>
mov    (%rbx,%r12,4),%eax
mov    0x0(%rbp,%r14,4),%ecx
mov    %ecx,(%rbx,%r12,4)
mov    %eax,0x0(%rbp,%r14,4)
add    $0x1,%r14
cmp    %r14d,(%rsp)
jne    11b0 <recursive_truc+0x80>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [1 x i8] zeroinitializer
define void @recursive_truc(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%9 = load i32, i32* %4
%10 = load i32, i32* %5
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %29
12: ; preds = %3
store i32 0, i32* %7
br label %13
13: ; preds = %24, %12
%14 = load i32, i32* %7
%15 = load i32, i32* %5
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %27
17: ; preds = %13
%18 = load i32*, i32** %6
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
%22 = load i32, i32* %21
%23 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %17
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %13
27: ; preds = %13
%28 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %82
29: ; preds = %3
%30 = load i32, i32* %4
store i32 %30, i32* %7
br label %31
31: ; preds = %78, %29
%32 = load i32, i32* %7
%33 = load i32, i32* %5
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %81
35: ; preds = %31
%36 = load i32*, i32** %6
%37 = load i32, i32* %4
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = load i32, i32* %39
store i32 %40, i32* %8
%41 = load i32*, i32** %6
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
%45 = load i32, i32* %44
%46 = load i32*, i32** %6
%47 = load i32, i32* %4
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
store i32 %45, i32* %49
%50 = load i32, i32* %8
%51 = load i32*, i32** %6
%52 = load i32, i32* %7
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32, i32* %51, i64 %53
store i32 %50, i32* %54
%55 = load i32, i32* %4
%56 = add nsw i32 %55, 1
%57 = load i32, i32* %5
%58 = load i32*, i32** %6
%59 = load i32*, i32** %6
%60 = load i32, i32* %4
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* %59, i64 %61
%63 = load i32, i32* %62
store i32 %63, i32* %8
%64 = load i32*, i32** %6
%65 = load i32, i32* %7
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i32, i32* %64, i64 %66
%68 = load i32, i32* %67
%69 = load i32*, i32** %6
%70 = load i32, i32* %4
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i32, i32* %69, i64 %71
store i32 %68, i32* %72
%73 = load i32, i32* %8
%74 = load i32*, i32** %6
%75 = load i32, i32* %7
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i32, i32* %74, i64 %76
store i32 %73, i32* %77
br label %78
78: ; preds = %35
%79 = load i32, i32* %7
%80 = add nsw i32 %79, 1
store i32 %80, i32* %7
br label %31
81: ; preds = %31
br label %82
82: ; preds = %81, %27
ret void
}

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