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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xe4(%rbp)
movl   $0x0,-0xd4(%rbp)
movslq -0xd4(%rbp),%rax
lea    -0xd0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe81(%rip),%rdi
call   1050 <scanf@plt>
mov    0x2e5a(%rip),%rcx
cmp    (%rcx),%rax
je     11b0 <main+0x70>
jmp    119c <main+0x5c>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    1166 <main+0x26>
lea    -0xd0(%rbp),%rdi
call   1030 <hops@plt>
mov    %rax,-0xf0(%rbp)
movl   $0x0,-0xd8(%rbp)
cmpl   $0x32,-0xd8(%rbp)
jge    128d <main+0x14d>
mov    -0xf0(%rbp),%rax
lea    -0xd0(%rbp),%rcx
sub    %rcx,%rax
sar    $0x2,%rax
mov    %eax,-0xe0(%rbp)
lea    -0xd0(%rbp),%rdi
mov    -0xd4(%rbp),%esi
mov    -0xf0(%rbp),%rdx
call   1060 <is_in_bound@plt>
mov    %eax,-0xdc(%rbp)
cmpl   $0x1,-0xdc(%rbp)
jne    126f <main+0x12f>
mov    -0xe0(%rbp),%eax
cmp    -0xd4(%rbp),%eax
jge    126f <main+0x12f>
movslq -0xe0(%rbp),%rax
cmpl   $0x0,-0xd0(%rbp,%rax,4)
jne    1257 <main+0x117>
movl   $0x1,-0xe4(%rbp)
jmp    128d <main+0x14d>
mov    -0xf0(%rbp),%rdi
call   1030 <hops@plt>
mov    %rax,-0xf0(%rbp)
jmp    1274 <main+0x134>
jmp    128d <main+0x14d>
jmp    1279 <main+0x139>
mov    -0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8(%rbp)
jmp    11cd <main+0x8d>
cmpl   $0x32,-0xd8(%rbp)
jne    12b7 <main+0x177>
mov    -0xe4(%rbp),%esi
mov    -0xd8(%rbp),%edx
lea    0xd53(%rip),%rdi
call   1040 <printf@plt>
jmp    12d2 <main+0x192>
mov    -0xe4(%rbp),%esi
mov    -0xd8(%rbp),%edx
add    $0x1,%edx
lea    0xd33(%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   %rbx
sub    $0xc8,%rsp
mov    $0xffffffff,%ebx
mov    %rsp,%rbp
lea    0xea7(%rip),%r14
mov    0x2e85(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
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
call   1030 <hops@plt>
mov    %rax,%rbp
mov    $0x1,%r15d
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
mov    %rbp,%rdx
call   1060 <is_in_bound@plt>
xor    %esi,%esi
cmp    $0x1,%eax
jne    11f4 <main+0xb4>
mov    %rbp,%rax
sub    %r14,%rax
shr    $0x2,%rax
cmp    %eax,%ebx
jle    11f4 <main+0xb4>
cltq
cmpl   $0x0,(%rsp,%rax,4)
je     11ef <main+0xaf>
mov    %rbp,%rdi
call   1030 <hops@plt>
mov    %rax,%rbp
add    $0x1,%r15d
cmp    $0x33,%r15d
jne    11a0 <main+0x60>
lea    0xe1a(%rip),%rdi
xor    %esi,%esi
mov    $0x32,%edx
jmp    11fe <main+0xbe>
mov    $0x1,%esi
lea    0xe05(%rip),%rdi
mov    %r15d,%edx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
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
%8 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %7
store i32 0, i32* %3
br label %9
9: ; preds = %17, %0
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %11
%13 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %12)
%14 = load i64, i64* @EOF
%15 = icmp ne i64 %13, %14
br i1 %15, label %16, label %20
16: ; preds = %9
br label %17
17: ; preds = %16
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %9
20: ; preds = %9
%21 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%22 = call i32* @hops(i32* %21)
store i32* %22, i32** %8
store i32 0, i32* %4
br label %23
23: ; preds = %56, %20
%24 = load i32, i32* %4
%25 = icmp slt i32 %24, 50
br i1 %25, label %26, label %59
26: ; preds = %23
%27 = load i32*, i32** %8
%28 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%29 = ptrtoint i32* %27 to i64
%30 = ptrtoint i32* %28 to i64
%31 = sub i64 %29, %30
%32 = sdiv exact i64 %31, 4
%33 = trunc i64 %32 to i32
store i32 %33, i32* %6
%34 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%35 = load i32, i32* %3
%36 = load i32*, i32** %8
%37 = call i32 @is_in_bound(i32* %34, i32 %35, i32* %36)
store i32 %37, i32* %5
%38 = load i32, i32* %5
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %54
40: ; preds = %26
%41 = load i32, i32* %6
%42 = load i32, i32* %3
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %54
44: ; preds = %40
%45 = load i32, i32* %6
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %44
store i32 1, i32* %7
br label %59
51: ; preds = %44
%52 = load i32*, i32** %8
%53 = call i32* @hops(i32* %52)
store i32* %53, i32** %8
br label %55
54: ; preds = %40, %26
br label %59
55: ; preds = %51
br label %56
56: ; preds = %55
%57 = load i32, i32* %4
%58 = add nsw i32 %57, 1
store i32 %58, i32* %4
br label %23
59: ; preds = %54, %50, %23
%60 = load i32, i32* %4
%61 = icmp eq i32 %60, 50
br i1 %61, label %62, label %66
62: ; preds = %59
%63 = load i32, i32* %7
%64 = load i32, i32* %4
%65 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %63, i32 %64)
br label %71
66: ; preds = %59
%67 = load i32, i32* %7
%68 = load i32, i32* %4
%69 = add nsw i32 %68, 1
%70 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %67, i32 %69)
br label %71
71: ; preds = %66, %62
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 i32* @hops(i32* %12)
%14 = ptrtoint [50 x i32]* %1 to i64
br label %15
15: ; preds = %10, %32
%16 = phi i32* [ %13, %10 ], [ %33, %32 ]
%17 = phi i32 [ 0, %10 ], [ %34, %32 ]
%18 = ptrtoint i32* %16 to i64
%19 = sub i64 %18, %14
%20 = call i32 @is_in_bound(i32* %12, i32 %11, i32* %16)
%21 = icmp eq i32 %20, 1
%22 = lshr exact i64 %19, 2
%23 = trunc i64 %22 to i32
%24 = icmp sgt i32 %11, %23
%25 = select i1 %21, i1 %24, i1 false
br i1 %25, label %26, label %38
26: ; preds = %15
%27 = shl i64 %19, 30
%28 = ashr i64 %27, 32
%29 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, 0
br i1 %31, label %38, label %32
32: ; preds = %26
%33 = call i32* @hops(i32* %16)
%34 = add nuw nsw i32 %17, 1
%35 = icmp eq i32 %34, 50
br i1 %35, label %36, label %15
36: ; preds = %32
%37 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 50)
br label %42
38: ; preds = %15, %26
%39 = phi i32 [ 0, %15 ], [ 1, %26 ]
%40 = add nuw nsw i32 %17, 1
%41 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %39, i32 %40)
br label %42
42: ; preds = %38, %36
ret i32 0
}