#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 */
scalar_t__ perm(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ strlen(char *);
int main() {
  char buffer[7];
  scanf("%s", buffer);
  printf("%s\n", perm(buffer, strlen(buffer)) ? buffer : "0");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xb(%rbp),%rsi
lea    0xea6(%rip),%rdi
call   1050 <scanf@plt>
lea    -0xb(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0xb(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
call   1060 <perm@plt>
cmp    $0x0,%rax
je     1192 <main+0x52>
lea    -0xb(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    11a2 <main+0x62>
lea    0xe6e(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11a2 <main+0x62>
mov    -0x20(%rbp),%rsi
lea    0xe56(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
lea    0x9(%rsp),%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <perm@plt>
test   %rax,%rax
lea    0xe92(%rip),%rsi
cmovne %rbx,%rsi
lea    0xe83(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [2 x i8] c"0\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [7 x i8]
store i32 0, i32* %1
%3 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%7 = call i32 @strlen(i8* %6)
%8 = call i64 @perm(i8* %5, i32 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
br label %13
12: ; preds = %0
br label %13
13: ; preds = %12, %10
%14 = phi i8* [ %11, %10 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %12 ]
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %14)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [2 x i8] c"0\00"
define i32 @main() {
%1 = alloca [7 x i8]
%2 = getelementptr inbounds [7 x i8], [7 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 = call i64 @perm(i8* %2, i32 %4)
%6 = icmp eq i64 %5, 0
%7 = select i1 %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %2
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %7)
ret i32 0
}