#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 change(char);
int /*<<< orphan*/ printf(char *, char *);
char reverse(int);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  int i = 0, n = 0;
  int a = 0, b = 0;
  int p = 0;
  char s[14];
  scanf("%s", s);
  n = strlen(s);
  while (1) {
    p = 0;
    for (i = 0; i < n - 1; i++) {
      a = change(s[i]);
      b = change(s[i + 1]);
      if (a > b) {
        a = a + b;
        b = a - b;
        a = a - b;
        p = 1;
      }
      s[i] = reverse(a);
      s[i + 1] = reverse(b);
    }
    if (p == 0) {
      break;
    }
  }
  printf("%s\n", s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0x26(%rbp),%rsi
lea    0xe73(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x26(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1247 <main+0xf7>
movslq -0x8(%rbp),%rax
movsbl -0x26(%rbp,%rax,1),%edi
call   1040 <change@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x26(%rbp,%rax,1),%edi
call   1040 <change@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    1211 <main+0xc1>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <reverse@plt>
mov    %al,%cl
movslq -0x8(%rbp),%rax
mov    %cl,-0x26(%rbp,%rax,1)
mov    -0x14(%rbp),%edi
call   1030 <reverse@plt>
mov    %al,%cl
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
mov    %cl,-0x26(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ac <main+0x5c>
cmpl   $0x0,-0x18(%rbp)
jne    1256 <main+0x106>
jmp    125b <main+0x10b>
jmp    119e <main+0x4e>
lea    -0x26(%rbp),%rsi
lea    0xd9d(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x30,%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    0xe9b(%rip),%rdi
lea    0xa(%rsp),%rbx
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    -0x1(%rax),%r14d
cmp    $0x2,%eax
jl     11f0 <main+0xa0>
setl   0x9(%rsp)
mov    $0x1,%r12d
xchg   %ax,%ax
xor    %ebp,%ebp
mov    0xa(%rsp),%al
xor    %r13d,%r13d
nopl   0x0(%rax)
movsbl %al,%edi
call   1040 <change@plt>
mov    %eax,%ebx
lea    0x1(%rbp),%r15
movsbl 0xb(%rsp,%rbp,1),%edi
call   1040 <change@plt>
cmp    %eax,%ebx
mov    %ebx,%edi
cmovg  %eax,%edi
cmovle %eax,%ebx
cmovg  %r12d,%r13d
call   1030 <reverse@plt>
mov    %al,0xa(%rsp,%rbp,1)
mov    %ebx,%edi
call   1030 <reverse@plt>
mov    %al,0xb(%rsp,%rbp,1)
mov    %r15,%rbp
cmp    %r15,%r14
jne    11a0 <main+0x50>
test   %r13d,%r13d
sete   %al
or     0x9(%rsp),%al
cmp    $0x1,%al
jne    1190 <main+0x40>
lea    0xe0c(%rip),%rdi
lea    0xa(%rsp),%rsi
call   1060 <printf@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"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [14 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%8 = getelementptr inbounds [14 x i8], [14 x i8]* %7, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [14 x i8], [14 x i8]* %7, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %3
br label %12
12: ; preds = %0, %62
store i32 0, i32* %6
store i32 0, i32* %2
br label %13
13: ; preds = %55, %12
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = sub nsw i32 %15, 1
%17 = icmp slt i32 %14, %16
br i1 %17, label %18, label %58
18: ; preds = %13
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [14 x i8], [14 x i8]* %7, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = call i32 @change(i8 signext %22)
store i32 %23, i32* %4
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [14 x i8], [14 x i8]* %7, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = call i32 @change(i8 signext %28)
store i32 %29, i32* %5
%30 = load i32, i32* %4
%31 = load i32, i32* %5
%32 = icmp sgt i32 %30, %31
br i1 %32, label %33, label %43
33: ; preds = %18
%34 = load i32, i32* %4
%35 = load i32, i32* %5
%36 = add nsw i32 %34, %35
store i32 %36, i32* %4
%37 = load i32, i32* %4
%38 = load i32, i32* %5
%39 = sub nsw i32 %37, %38
store i32 %39, i32* %5
%40 = load i32, i32* %4
%41 = load i32, i32* %5
%42 = sub nsw i32 %40, %41
store i32 %42, i32* %4
store i32 1, i32* %6
br label %43
43: ; preds = %33, %18
%44 = load i32, i32* %4
%45 = call signext i8 @reverse(i32 %44)
%46 = load i32, i32* %2
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [14 x i8], [14 x i8]* %7, i64 0, i64 %47
store i8 %45, i8* %48
%49 = load i32, i32* %5
%50 = call signext i8 @reverse(i32 %49)
%51 = load i32, i32* %2
%52 = add nsw i32 %51, 1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [14 x i8], [14 x i8]* %7, i64 0, i64 %53
store i8 %50, i8* %54
br label %55
55: ; preds = %43
%56 = load i32, i32* %2
%57 = add nsw i32 %56, 1
store i32 %57, i32* %2
br label %13
58: ; preds = %13
%59 = load i32, i32* %6
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %58
br label %63
62: ; preds = %58
br label %12
63: ; preds = %61
%64 = getelementptr inbounds [14 x i8], [14 x i8]* %7, i64 0, i64 0
%65 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %64)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [14 x i8]
%2 = getelementptr inbounds [14 x i8], [14 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 = add i32 %4, -1
%6 = icmp sgt i32 %4, 1
%7 = zext i32 %5 to i64
br i1 %6, label %8, label %32
8: ; preds = %0
%9 = xor i1 %6, true
br label %10
10: ; preds = %8, %29
%11 = load i8, i8* %2
br label %12
12: ; preds = %10, %12
%13 = phi i8 [ %11, %10 ], [ %27, %12 ]
%14 = phi i64 [ 0, %10 ], [ %18, %12 ]
%15 = phi i32 [ 0, %10 ], [ %25, %12 ]
%16 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 %14
%17 = call i32 @change(i8 signext %13)
%18 = add nuw nsw i64 %14, 1
%19 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = call i32 @change(i8 signext %20)
%22 = icmp sgt i32 %17, %21
%23 = select i1 %22, i32 %21, i32 %17
%24 = select i1 %22, i32 %17, i32 %21
%25 = select i1 %22, i32 1, i32 %15
%26 = call signext i8 @reverse(i32 %23)
store i8 %26, i8* %16
%27 = call signext i8 @reverse(i32 %24)
store i8 %27, i8* %19
%28 = icmp eq i64 %18, %7
br i1 %28, label %29, label %12
29: ; preds = %12
%30 = icmp eq i32 %25, 0
%31 = select i1 %30, i1 true, i1 %9
br i1 %31, label %32, label %10
32: ; preds = %29, %0
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
ret i32 0
}