#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 *, char *);
int /*<<< orphan*/ swap(char *, char *);
void recursion_sort(char *c, int from, int to) {
  if (from == to) {
    printf("%s\n", c);
  }
  int i;
  for (i = from; i <= to; ++i) {
    swap(&c[i], &c[from]);
    recursion_sort(c, from + 1, to);
    swap(&c[i], &c[from]);
  }
}


x86 assembly (clang, -O0):
<recursion_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    115e <recursion_sort+0x2e>
mov    -0x8(%rbp),%rsi
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11c6 <recursion_sort+0x96>
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
movslq -0xc(%rbp),%rax
add    %rax,%rsi
call   1050 <swap@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
call   1040 <recursion_sort@plt>
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
movslq -0xc(%rbp),%rax
add    %rax,%rsi
call   1050 <swap@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1164 <recursion_sort+0x34>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recursion_sort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%ebx
mov    %rdi,%r14
cmp    %edx,%esi
jne    1156 <recursion_sort+0x26>
lea    0xeb2(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
cmp    %r15d,%ebx
jg     11a0 <recursion_sort+0x70>
movslq %ebx,%r13
add    %r14,%r13
lea    0x1(%rbx),%r12d
add    $0xffffffff,%ebx
mov    %r13,%rbp
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %r13,%rsi
call   1050 <swap@plt>
mov    %r14,%rdi
mov    %r12d,%esi
mov    %r15d,%edx
call   1040 <recursion_sort@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
call   1050 <swap@plt>
add    $0x1,%rbp
add    $0x1,%ebx
cmp    %ebx,%r15d
jne    1170 <recursion_sort+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @recursion_sort(i8* %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %1, %2
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %7
7: ; preds = %5, %3
%8 = icmp sgt i32 %1, %2
br i1 %8, label %22, label %9
9: ; preds = %7
%10 = sext i32 %1 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = add nsw i32 %1, 1
%13 = add i32 %2, 1
br label %14
14: ; preds = %9, %14
%15 = phi i64 [ %10, %9 ], [ %19, %14 ]
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = tail call i32 @swap(i8* %16, i8* %11)
tail call void @recursion_sort(i8* %0, i32 %12, i32 %2)
%18 = tail call i32 @swap(i8* %16, i8* %11)
%19 = add nsw i64 %15, 1
%20 = trunc i64 %19 to i32
%21 = icmp eq i32 %13, %20
br i1 %21, label %22, label %14
22: ; preds = %14, %7
ret void
}