#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*/ permute(char *, int, int);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int /*<<< orphan*/ swap(char *, char *);
int main() {
  char arr[10];
  int i, n, x, y;
  scanf("%s", arr);
  i = 0;
  n = strlen(arr);
  for (x = n - 1; x > 0; x--) {
    for (y = 0; y < x; y++) {
      if (arr[y] > arr[y + 1])
        swap(arr + y, arr + y + 1);
    }
  }
  permute(arr, i, n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xe(%rbp),%rsi
lea    0xea6(%rip),%rdi
call   1050 <scanf@plt>
movl   $0x0,-0x14(%rbp)
lea    -0xe(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    11fc <main+0xbc>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11e9 <main+0xa9>
movslq -0x20(%rbp),%rax
movsbl -0xe(%rbp,%rax,1),%eax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl -0xe(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jle    11d6 <main+0x96>
lea    -0xe(%rbp),%rdi
movslq -0x20(%rbp),%rax
add    %rax,%rdi
lea    -0xe(%rbp),%rsi
movslq -0x20(%rbp),%rax
add    %rax,%rsi
add    $0x1,%rsi
call   1060 <swap@plt>
jmp    11db <main+0x9b>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    118c <main+0x4c>
jmp    11ee <main+0xae>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    117b <main+0x3b>
lea    -0xe(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1030 <permute@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeab(%rip),%rdi
lea    0xe(%rsp),%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,0x8(%rsp)
cmp    $0x2,%eax
jl     11d3 <main+0x93>
mov    0x8(%rsp),%r12d
mov    %r12d,%ebp
add    $0xffffffff,%ebp
lea    0xf(%rsp),%r15
jmp    119a <main+0x5a>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0xffffffffffffffff,%rbp
cmp    $0x3,%r13d
jl     11d3 <main+0x93>
mov    %r12d,%r13d
lea    -0x1(%r13),%r12d
mov    %r15,%rbx
xor    %r14d,%r14d
jmp    11b9 <main+0x79>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %r14,%rbp
je     1190 <main+0x50>
movzbl -0x1(%rbx),%eax
add    $0x1,%r14
cmp    (%rbx),%al
jle    11b0 <main+0x70>
lea    -0x1(%rbx),%rdi
mov    %rbx,%rsi
call   1060 <swap@plt>
jmp    11b0 <main+0x70>
lea    0xe(%rsp),%rdi
xor    %esi,%esi
mov    0x8(%rsp),%edx
call   1030 <permute@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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