#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__ EOF;
int atoi(char *);
int /*<<< orphan*/ free(char *);
int *hop(int *);
scalar_t__ is_in_bound(int *, int, int *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, char *);
int main() {
  char *input = malloc(sizeof(char) * 6 * 50);
  int fake[50];
  int i = 0;
  while (scanf("%300s", input) != EOF) {
    fake[i] = atoi(input);
    i += 1;
  }
  free(input);
  int real[i];
  int j = 0;
  for (j = 0; j <= i; j++) {
    real[j] = fake[j];
  }
  int hops = 0;
  int *ptr = real;
  while ((hops <= 50)) {
    if (is_in_bound(real, i, ptr)) {
      if (*ptr == 0) {
        printf("1\n%d", hops);
        return 1;
      }
      ptr = hop(ptr);
      hops += 1;
    } else {
      printf("0\n%d", hops);
      return 2;
    }
  }
  printf("0\n50\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x12c,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0xe4(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe5b(%rip),%rdi
call   1070 <scanf@plt>
mov    0x2e37(%rip),%rcx
cmp    (%rcx),%rax
je     11e7 <main+0x77>
mov    -0x10(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,%ecx
movslq -0xe4(%rbp),%rax
mov    %ecx,-0xe0(%rbp,%rax,4)
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    119a <main+0x2a>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0xe4(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0xf0(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x118(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xf8(%rbp)
movl   $0x0,-0xfc(%rbp)
movl   $0x0,-0xfc(%rbp)
mov    -0xfc(%rbp),%eax
cmp    -0xe4(%rbp),%eax
jg     127c <main+0x10c>
mov    -0x118(%rbp),%rax
movslq -0xfc(%rbp),%rcx
mov    -0xe0(%rbp,%rcx,4),%edx
movslq -0xfc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xfc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfc(%rbp)
jmp    1237 <main+0xc7>
mov    -0x118(%rbp),%rax
movl   $0x0,-0x100(%rbp)
mov    %rax,-0x108(%rbp)
cmpl   $0x32,-0x100(%rbp)
jg     1354 <main+0x1e4>
mov    -0x118(%rbp),%rdi
mov    -0xe4(%rbp),%esi
mov    -0x108(%rbp),%rdx
call   1090 <is_in_bound@plt>
cmp    $0x0,%rax
je     1325 <main+0x1b5>
mov    -0x108(%rbp),%rax
cmpl   $0x0,(%rax)
jne    12fe <main+0x18e>
mov    -0x100(%rbp),%esi
lea    0xd25(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1373 <main+0x203>
mov    -0x108(%rbp),%rdi
call   1040 <hop@plt>
mov    %rax,-0x108(%rbp)
mov    -0x100(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x100(%rbp)
jmp    134f <main+0x1df>
mov    -0x100(%rbp),%esi
lea    0xcd9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
jmp    1373 <main+0x203>
jmp    1294 <main+0x124>
lea    0xcb5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10c(%rbp)
mov    -0xf0(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
mov    $0x12c,%edi
call   1080 <malloc@plt>
mov    %rax,%r15
lea    0xe48(%rip),%rdi
mov    %rax,%rsi
call   1090 <scanf@plt>
mov    0x2e21(%rip),%r13
xor    %r14d,%r14d
mov    $0x0,%r12d
cmp    0x0(%r13),%rax
je     1205 <main+0x75>
xor    %r12d,%r12d
lea    0xe20(%rip),%rbx
mov    %r15,%rdi
call   10a0 <atoi@plt>
mov    %eax,-0xf0(%rbp,%r12,4)
ff
add    $0x1,%r12
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <scanf@plt>
cmp    0x0(%r13),%rax
jne    11e0 <main+0x50>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rsp,%r13
mov    %r12d,%eax
mov    %rsp,%r15
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r15
mov    %r15,%rsp
lea    0x4(,%rax,4),%rdx
lea    -0xf0(%rbp),%rsi
mov    %r15,%rdi
call   1070 <memcpy@plt>
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %r12d,%esi
mov    %rbx,%rdx
call   10b0 <is_in_bound@plt>
test   %rax,%rax
je     128d <main+0xfd>
cmpl   $0x0,(%rbx)
je     12a5 <main+0x115>
mov    %rbx,%rdi
call   1050 <hop@plt>
mov    %rax,%rbx
add    $0x1,%r14d
cmp    $0x33,%r14d
jne    1250 <main+0xc0>
lea    0xd8c(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
jmp    12bb <main+0x12b>
lea    0xd77(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x2,%eax
jmp    12bb <main+0x12b>
lea    0xd5a(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%eax
mov    %r13,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%300s\00"
@EOF = global i64 0
@.str.1 = [5 x i8] c"1\0A%d\00"
@.str.2 = [5 x i8] c"0\0A%d\00"
@.str.3 = [6 x i8] c"0\0A50\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [50 x i32]
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
store i32 0, i32* %1
%11 = call i8* @malloc(i32 300)
store i8* %11, i8** %2
store i32 0, i32* %4
br label %12
12: ; preds = %17, %0
%13 = load i8*, i8** %2
%14 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i64, i64* @EOF
%16 = icmp ne i64 %14, %15
br i1 %16, label %17, label %25
17: ; preds = %12
%18 = load i8*, i8** %2
%19 = call i32 @atoi(i8* %18)
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 %21
store i32 %19, i32* %22
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %12
25: ; preds = %12
%26 = load i8*, i8** %2
%27 = call i32 @free(i8* %26)
%28 = load i32, i32* %4
%29 = zext i32 %28 to i64
%30 = call i8* @llvm.stacksave()
store i8* %30, i8** %5
%31 = alloca i32, i64 %29
store i64 %29, i64* %6
store i32 0, i32* %7
store i32 0, i32* %7
br label %32
32: ; preds = %44, %25
%33 = load i32, i32* %7
%34 = load i32, i32* %4
%35 = icmp sle i32 %33, %34
br i1 %35, label %36, label %47
36: ; preds = %32
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = load i32, i32* %7
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %31, i64 %42
store i32 %40, i32* %43
br label %44
44: ; preds = %36
%45 = load i32, i32* %7
%46 = add nsw i32 %45, 1
store i32 %46, i32* %7
br label %32
47: ; preds = %32
store i32 0, i32* %8
store i32* %31, i32** %9
br label %48
48: ; preds = %71, %47
%49 = load i32, i32* %8
%50 = icmp sle i32 %49, 50
br i1 %50, label %51, label %72
51: ; preds = %48
%52 = load i32, i32* %4
%53 = load i32*, i32** %9
%54 = call i64 @is_in_bound(i32* %31, i32 %52, i32* %53)
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %68
56: ; preds = %51
%57 = load i32*, i32** %9
%58 = load i32, i32* %57
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %56
%61 = load i32, i32* %8
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %61)
store i32 1, i32* %1
store i32 1, i32* %10
br label %74
63: ; preds = %56
%64 = load i32*, i32** %9
%65 = call i32* @hop(i32* %64)
store i32* %65, i32** %9
%66 = load i32, i32* %8
%67 = add nsw i32 %66, 1
store i32 %67, i32* %8
br label %71
68: ; preds = %51
%69 = load i32, i32* %8
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %69)
store i32 2, i32* %1
store i32 1, i32* %10
br label %74
71: ; preds = %63
br label %48
72: ; preds = %48
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
store i32 1, i32* %10
br label %74
74: ; preds = %72, %68, %60
%75 = load i8*, i8** %5
%76 = load i32, i32* %1
ret i32 %76
}

LLVM IR (-O2):
@.str = [6 x i8] c"%300s\00"
@EOF = global i64 0
@.str.1 = [5 x i8] c"1\0A%d\00"
@.str.2 = [5 x i8] c"0\0A%d\00"
@str = [5 x i8] c"0\0A50\00"
define i32 @main() {
%1 = alloca [50 x i32]
%2 = bitcast [50 x i32]* %1 to i8*
%3 = tail call dereferenceable_or_null(300) i8* @malloc(i32 300)
%4 = tail call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = load i64, i64* @EOF
%6 = icmp eq i64 %4, %5
br i1 %6, label %17, label %7
7: ; preds = %0, %7
%8 = phi i64 [ %11, %7 ], [ 0, %0 ]
%9 = tail call i32 @atoi(i8* %3)
%10 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %8
store i32 %9, i32* %10
%11 = add nuw i64 %8, 1
%12 = tail call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %3)
%13 = load i64, i64* @EOF
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %7
15: ; preds = %7
%16 = trunc i64 %11 to i32
br label %17
17: ; preds = %15, %0
%18 = phi i32 [ 0, %0 ], [ %16, %15 ]
%19 = tail call i32 @free(i8* %3)
%20 = zext i32 %18 to i64
%21 = tail call i8* @llvm.stacksave()
%22 = alloca i32, i64 %20
%23 = bitcast i32* %22 to i8*
%24 = shl nuw nsw i64 %20, 2
%25 = add nuw nsw i64 %24, 4
br label %26
26: ; preds = %17, %36
%27 = phi i32* [ %37, %36 ], [ %22, %17 ]
%28 = phi i32 [ %38, %36 ], [ 0, %17 ]
%29 = call i64 @is_in_bound(i32* %22, i32 %18, i32* %27)
%30 = icmp eq i64 %29, 0
br i1 %30, label %40, label %31
31: ; preds = %26
%32 = load i32, i32* %27
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %44
36: ; preds = %31
%37 = call i32* @hop(i32* %27)
%38 = add nuw nsw i32 %28, 1
%39 = icmp eq i32 %38, 51
br i1 %39, label %42, label %26
40: ; preds = %26
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %28)
br label %44
42: ; preds = %36
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
br label %44
44: ; preds = %42, %40, %34
%45 = phi i32 [ 1, %34 ], [ 2, %40 ], [ 0, %42 ]
ret i32 %45
}