#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 *hop(int *);
int /*<<< orphan*/ is_in_bound(int *, int, int *);
int /*<<< orphan*/ printf(char *, int, int);
scalar_t__ scanf(char *, int *);
int main() {
  int array[50];
  int size = 0;
  int hops = 0;
  int has_road = 0;
  while (scanf("%d", &array[size]) != EOF) {
    size++;
  }
  int i = 0;
  int *element = array;
  for (i = 0; i < 50; ++i) {
    if (*element == 0) {
      has_road = 1;
      break;
    } else if (!is_in_bound(array, size, element)) {
      break;
    } else {
      element = hop(element);
      hops++;
    }
  }
  printf("%d\n%d", has_road, hops);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xd4(%rbp)
movl   $0x0,-0xd8(%rbp)
movl   $0x0,-0xdc(%rbp)
movslq -0xd4(%rbp),%rax
lea    -0xd0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe77(%rip),%rdi
call   1050 <scanf@plt>
mov    0x2e50(%rip),%rcx
cmp    (%rcx),%rax
je     11b5 <main+0x75>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    1170 <main+0x30>
movl   $0x0,-0xe0(%rbp)
lea    -0xd0(%rbp),%rax
mov    %rax,-0xe8(%rbp)
movl   $0x0,-0xe0(%rbp)
cmpl   $0x32,-0xe0(%rbp)
jge    126a <main+0x12a>
mov    -0xe8(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1203 <main+0xc3>
movl   $0x1,-0xdc(%rbp)
jmp    126a <main+0x12a>
lea    -0xd0(%rbp),%rdi
mov    -0xd4(%rbp),%esi
mov    -0xe8(%rbp),%rdx
call   1060 <is_in_bound@plt>
cmp    $0x0,%eax
jne    122a <main+0xea>
jmp    126a <main+0x12a>
mov    -0xe8(%rbp),%rdi
call   1030 <hop@plt>
mov    %rax,-0xe8(%rbp)
mov    -0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8(%rbp)
jmp    1251 <main+0x111>
jmp    1256 <main+0x116>
mov    -0xe0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe0(%rbp)
jmp    11d7 <main+0x97>
mov    -0xdc(%rbp),%esi
mov    -0xd8(%rbp),%edx
lea    0xd83(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd0,%rsp
mov    $0xffffffff,%ebx
mov    %rsp,%rbp
lea    0xea5(%rip),%r14
mov    0x2e83(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
add    $0x1,%ebx
add    $0x4,%rbp
cmp    (%r15),%rax
jne    1170 <main+0x30>
xor    %r12d,%r12d
mov    %rsp,%r15
mov    %r15,%rbp
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpl   $0x0,0x0(%rbp)
je     11d4 <main+0x94>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %rbp,%rdx
call   1060 <is_in_bound@plt>
test   %eax,%eax
je     11da <main+0x9a>
mov    %rbp,%rdi
call   1030 <hop@plt>
mov    %rax,%rbp
add    $0x1,%r12d
cmp    $0x32,%r12d
jne    11a0 <main+0x60>
mov    $0x32,%r12d
jmp    11da <main+0x9a>
mov    $0x1,%r14d
lea    0xe1f(%rip),%rdi
mov    %r14d,%esi
mov    %r12d,%edx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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