#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 game(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ strlen(char *);
int main() {
  char buffer[10001];
  scanf("%s", buffer);
  int rank = game(buffer, strlen(buffer));
  if (rank == 0)
    printf("Legend\n");
  else
    printf("%d\n", rank);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2730,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x2720(%rbp),%rsi
lea    0xea0(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x2720(%rbp),%rax
mov    %rax,-0x2730(%rbp)
lea    -0x2720(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x2730(%rbp),%rdi
mov    %eax,%esi
call   1060 <game@plt>
mov    %eax,-0x2724(%rbp)
cmpl   $0x0,-0x2724(%rbp)
jne    11b3 <main+0x73>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11c7 <main+0x87>
mov    -0x2724(%rbp),%esi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x2730,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x2720,%rsp
lea    0xea1(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1070 <game@plt>
test   %eax,%eax
je     1192 <main+0x42>
lea    0xe7c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    119e <main+0x4e>
lea    0xe6e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x2720,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@str = [7 x i8] c"Legend\00"
define i32 @main() {
%1 = alloca [10001 x i8]
%2 = getelementptr inbounds [10001 x i8], [10001 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 i32 @game(i8* %2, i32 %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %5)
br label %11
11: ; preds = %9, %7
ret i32 0
}