#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*/ string_permutation_dict(char *, int);
int strlen(char *);
void main() {
  char str[] = "21543";
  int len = strlen(str);
  int i;
  printf("str = %s\n", str);
  for (i = 2; i < len; i++) {
    string_permutation_dict(str, i);
    printf("%s\n", str);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0xec2(%rip),%eax
mov    %eax,-0x6(%rbp)
mov    0xebc(%rip),%ax
mov    %ax,-0x2(%rbp)
lea    -0x6(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
lea    -0x6(%rbp),%rsi
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a5 <main+0x75>
lea    -0x6(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1050 <string_permutation_dict@plt>
lea    -0x6(%rbp),%rsi
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116f <main+0x3f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movw   $0x33,0x4(%rsp)
movl   $0x34353132,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%r14d
lea    0xeac(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
cmp    $0x3,%r14d
jl     119d <main+0x6d>
mov    $0x2,%ebp
mov    %rsp,%rbx
lea    0xe95(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <string_permutation_dict@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%r14d
jne    1180 <main+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.str = [6 x i8] c"21543\00"
@.str = [10 x i8] c"str = %s\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @main() {
%1 = alloca [6 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [6 x i8]* %1 to i8*
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%6 = call i32 @strlen(i8* %5)
store i32 %6, i32* %2
%7 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%8 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %7)
store i32 2, i32* %3
br label %9
9: ; preds = %19, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %22
13: ; preds = %9
%14 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%15 = load i32, i32* %3
%16 = call i32 @string_permutation_dict(i8* %14, i32 %15)
%17 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %13
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %9
22: ; preds = %9
ret void
}

LLVM IR (-O2):
@__const.main.str = [6 x i8] c"21543\00"
@.str = [10 x i8] c"str = %s\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @main() {
%1 = alloca [6 x i8]
%2 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%3 = call i32 @strlen(i8* %2)
%4 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %2)
%5 = icmp sgt i32 %3, 2
br i1 %5, label %6, label %12
6: ; preds = %0, %6
%7 = phi i32 [ %10, %6 ], [ 2, %0 ]
%8 = call i32 @string_permutation_dict(i8* %2, i32 %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%10 = add nuw nsw i32 %7, 1
%11 = icmp eq i32 %10, %3
br i1 %11, label %12, label %6
12: ; preds = %6, %0
ret void
}