#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 *);
scalar_t__ is_in_bound(int *, int, int *);
int /*<<< orphan*/ printf(char *, int, int);
scalar_t__ scanf(char *, int *);
int main() {
  int inp_array[50];
  int *ptr;
  int i = 0, valid = 0, length, counter_for_hops = 0;
  while ((scanf("%d", &inp_array[i])) != EOF) {
    i++;
  }
  ptr = inp_array;
  length = i;
  while (is_in_bound(inp_array, length, ptr) && counter_for_hops < 50) {
    if (*ptr == 0) {
      valid = 0;
      break;
    }
    ptr = hop(ptr);
    counter_for_hops++;
  }
  printf("%d\n%d", valid, counter_for_hops);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xdc(%rbp)
movl   $0x0,-0xe0(%rbp)
movl   $0x0,-0xe8(%rbp)
movslq -0xdc(%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    -0xdc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xdc(%rbp)
jmp    1170 <main+0x30>
lea    -0xd0(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    -0xdc(%rbp),%eax
mov    %eax,-0xe4(%rbp)
lea    -0xd0(%rbp),%rdi
mov    -0xe4(%rbp),%esi
mov    -0xd8(%rbp),%rdx
call   1060 <is_in_bound@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0xe9(%rbp)
je     120d <main+0xcd>
cmpl   $0x32,-0xe8(%rbp)
setl   %al
mov    %al,-0xe9(%rbp)
mov    -0xe9(%rbp),%al
test   $0x1,%al
jne    1220 <main+0xe0>
jmp    1266 <main+0x126>
mov    -0xd8(%rbp),%rax
cmpl   $0x0,(%rax)
jne    123f <main+0xff>
movl   $0x0,-0xe0(%rbp)
jmp    1266 <main+0x126>
mov    -0xd8(%rbp),%rdi
call   1030 <hop@plt>
mov    %rax,-0xd8(%rbp)
mov    -0xe8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe8(%rbp)
jmp    11cf <main+0x8f>
mov    -0xe0(%rbp),%esi
mov    -0xe8(%rbp),%edx
lea    0xd87(%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>
mov    %rsp,%r14
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r14,%rdx
call   1060 <is_in_bound@plt>
test   %rax,%rax
je     11e3 <main+0xa3>
xor    %r12d,%r12d
mov    %r14,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpl   $0x0,0x0(%rbp)
je     11e8 <main+0xa8>
mov    %rbp,%rdi
call   1030 <hop@plt>
mov    %rax,%rbp
lea    0x1(%r12),%r15d
mov    %r14,%rdi
mov    %ebx,%esi
mov    %rax,%rdx
call   1060 <is_in_bound@plt>
test   %rax,%rax
je     11eb <main+0xab>
cmp    $0x31,%r12d
mov    %r15d,%r12d
jb     11b0 <main+0x70>
jmp    11eb <main+0xab>
xor    %r15d,%r15d
jmp    11eb <main+0xab>
mov    %r12d,%r15d
lea    0xe0e(%rip),%rdi
xor    %esi,%esi
mov    %r15d,%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* %4
store i32 0, i32* %5
store i32 0, i32* %7
br label %8
8: ; preds = %15, %0
%9 = load i32, i32* %4
%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* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
br label %8
18: ; preds = %8
%19 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
store i32* %19, i32** %3
%20 = load i32, i32* %4
store i32 %20, i32* %6
br label %21
21: ; preds = %37, %18
%22 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%23 = load i32, i32* %6
%24 = load i32*, i32** %3
%25 = call i64 @is_in_bound(i32* %22, i32 %23, i32* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %21
%28 = load i32, i32* %7
%29 = icmp slt i32 %28, 50
br label %30
30: ; preds = %27, %21
%31 = phi i1 [ false, %21 ], [ %29, %27 ]
br i1 %31, label %32, label %42
32: ; preds = %30
%33 = load i32*, i32** %3
%34 = load i32, i32* %33
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 0, i32* %5
br label %42
37: ; preds = %32
%38 = load i32*, i32** %3
%39 = call i32* @hop(i32* %38)
store i32* %39, i32** %3
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %21
42: ; preds = %36, %30
%43 = load i32, i32* %5
%44 = load i32, i32* %7
%45 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %43, i32 %44)
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
%13 = call i64 @is_in_bound(i32* %12, i32 %11, i32* %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %27, label %15
15: ; preds = %10, %20
%16 = phi i32 [ %22, %20 ], [ 0, %10 ]
%17 = phi i32* [ %21, %20 ], [ %12, %10 ]
%18 = load i32, i32* %17
%19 = icmp eq i32 %18, 0
br i1 %19, label %27, label %20
20: ; preds = %15
%21 = call i32* @hop(i32* %17)
%22 = add nuw nsw i32 %16, 1
%23 = call i64 @is_in_bound(i32* %12, i32 %11, i32* %21)
%24 = icmp ne i64 %23, 0
%25 = icmp ult i32 %16, 49
%26 = select i1 %24, i1 %25, i1 false
br i1 %26, label %15, label %27
27: ; preds = %20, %15, %10
%28 = phi i32 [ 0, %10 ], [ %16, %15 ], [ %22, %20 ]
%29 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %28)
ret i32 0
}