#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 *, ...);
scalar_t__ scanf(char *, int *);
int main(int argc, const char *argv[]) {
  int size = 0;
  int nums[50];
  while (scanf("%d", &nums[size]) != EOF) {
    size++;
  }
  int *ptr = nums;
  int hops = 0;
  while (1) {
    if (*ptr == 0) {
      printf("1\n");
      break;
    }
    ptr = hop(ptr);
    hops++;
    if (!is_in_bound(nums, size, ptr) || hops >= 50) {
      printf("0\n");
      break;
    }
  }
  printf("%d\n", hops);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
lea    -0xe0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe87(%rip),%rdi
call   1050 <scanf@plt>
mov    0x2e63(%rip),%rcx
cmp    (%rcx),%rax
je     119c <main+0x5c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1160 <main+0x20>
lea    -0xe0(%rbp),%rax
mov    %rax,-0xe8(%rbp)
movl   $0x0,-0xec(%rbp)
mov    -0xe8(%rbp),%rax
cmpl   $0x0,(%rax)
jne    11d7 <main+0x97>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    123d <main+0xfd>
mov    -0xe8(%rbp),%rdi
call   1030 <hop@plt>
mov    %rax,-0xe8(%rbp)
mov    -0xec(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xec(%rbp)
lea    -0xe0(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0xe8(%rbp),%rdx
call   1060 <is_in_bound@plt>
cmp    $0x0,%eax
je     1225 <main+0xe5>
cmpl   $0x32,-0xec(%rbp)
jl     1238 <main+0xf8>
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    123d <main+0xfd>
jmp    11b4 <main+0x74>
mov    -0xec(%rbp),%esi
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
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   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
mov    $0xffffffff,%ebp
mov    %rsp,%rbx
lea    0xe90(%rip),%r14
mov    0x2e71(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
add    $0x1,%ebp
add    $0x4,%rbx
cmp    (%r15),%rax
jne    1180 <main+0x30>
xor    %r14d,%r14d
mov    %rsp,%r12
lea    0xe65(%rip),%r15
mov    %r12,%r13
nopw   0x0(%rax,%rax,1)
cmpl   $0x0,0x0(%r13)
je     11ea <main+0x9a>
mov    %r13,%rdi
call   1040 <hop@plt>
mov    %rax,%r13
lea    0x1(%r14),%ebx
mov    %r12,%rdi
mov    %ebp,%esi
mov    %rax,%rdx
call   1070 <is_in_bound@plt>
test   %eax,%eax
je     11e0 <main+0x90>
cmp    $0x31,%r14d
mov    %ebx,%r14d
jb     11b0 <main+0x60>
lea    0xe20(%rip),%r15
mov    %ebx,%r14d
mov    %r15,%rdi
call   1030 <puts@plt>
lea    0xe0a(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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