#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 ground[50], counter = 0, *ptr, hops = 0;
  while (scanf("%d", &ground[counter]) != EOF && counter++ < 50)
    ;
  ptr = &ground[0];
  do {
    if (*ptr == '0') {
      printf("1\n");
      break;
    }
    ptr = hop(ptr);
    hops++;
    if (!is_in_bound(ground, counter, ptr) || hops > 49) {
      printf("0\n");
      break;
    }
  } while (1);
  printf("%d\n", 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,-0xe4(%rbp)
movslq -0xd4(%rbp),%rax
lea    -0xd0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe7e(%rip),%rdi
call   1050 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
mov    0x2e55(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0xe5(%rbp)
je     11bf <main+0x7f>
mov    -0xd4(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xd4(%rbp)
cmp    $0x32,%eax
setl   %al
mov    %al,-0xe5(%rbp)
mov    -0xe5(%rbp),%al
test   $0x1,%al
jne    11d2 <main+0x92>
jmp    11d7 <main+0x97>
jmp    1166 <main+0x26>
lea    -0xd0(%rbp),%rax
mov    %rax,-0xe0(%rbp)
mov    -0xe0(%rbp),%rax
cmpl   $0x30,(%rax)
jne    1208 <main+0xc8>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1280 <main+0x140>
mov    -0xe0(%rbp),%rdi
call   1030 <hop@plt>
mov    %rax,-0xe0(%rbp)
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
lea    -0xd0(%rbp),%rdi
mov    -0xd4(%rbp),%esi
mov    -0xe0(%rbp),%rdx
call   1060 <is_in_bound@plt>
cmp    $0x0,%eax
je     1259 <main+0x119>
cmpl   $0x31,-0xe4(%rbp)
jle    126c <main+0x12c>
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1280 <main+0x140>
jmp    1271 <main+0x131>
mov    $0x1,%al
test   $0x1,%al
jne    11e5 <main+0xa5>
jmp    1280 <main+0x140>
mov    -0xe4(%rbp),%esi
lea    0xd7c(%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    %rsp,%rbx
xor    %r13d,%r13d
lea    0xe92(%rip),%r14
mov    0x2e73(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
cmp    0x0(%rbp),%rax
je     11a5 <main+0x55>
add    $0x1,%r13
add    $0x4,%rbx
cmp    $0x33,%r13
jne    1180 <main+0x30>
mov    $0x33,%r13d
xor    %r14d,%r14d
mov    %rsp,%r12
lea    0xe57(%rip),%r15
mov    %r12,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
cmpl   $0x30,(%rbx)
je     11f9 <main+0xa9>
mov    %rbx,%rdi
call   1040 <hop@plt>
mov    %rax,%rbx
lea    0x1(%r14),%ebp
mov    %r12,%rdi
mov    %r13d,%esi
mov    %rax,%rdx
call   1070 <is_in_bound@plt>
test   %eax,%eax
je     11ef <main+0x9f>
cmp    $0x31,%r14d
mov    %ebp,%r14d
jb     11c0 <main+0x70>
lea    0xe11(%rip),%r15
mov    %ebp,%r14d
mov    %r15,%rdi
call   1030 <puts@plt>
lea    0xdfb(%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() {
%1 = alloca i32
%2 = alloca [50 x i32]
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %5
br label %6
6: ; preds = %19, %0
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %8
%10 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
%11 = load i64, i64* @EOF
%12 = icmp ne i64 %10, %11
br i1 %12, label %13, label %17
13: ; preds = %6
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
%16 = icmp slt i32 %14, 50
br label %17
17: ; preds = %13, %6
%18 = phi i1 [ false, %6 ], [ %16, %13 ]
br i1 %18, label %19, label %20
19: ; preds = %17
br label %6
20: ; preds = %17
%21 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
store i32* %21, i32** %4
br label %22
22: ; preds = %44, %20
%23 = load i32*, i32** %4
%24 = load i32, i32* %23
%25 = icmp eq i32 %24, 48
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 %45
28: ; preds = %22
%29 = load i32*, i32** %4
%30 = call i32* @hop(i32* %29)
store i32* %30, i32** %4
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
%33 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%34 = load i32, i32* %3
%35 = load i32*, i32** %4
%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* %5
%40 = icmp sgt i32 %39, 49
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 %45
43: ; preds = %38
br label %44
44: ; preds = %43
br i1 true, label %22, label %45
45: ; preds = %44, %41, %26
%46 = load i32, i32* %5
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %46)
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() {
%1 = alloca [50 x i32]
%2 = bitcast [50 x i32]* %1 to i8*
br label %3
3: ; preds = %9, %0
%4 = phi i64 [ %10, %9 ], [ 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
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = add nuw nsw i64 %4, 1
%11 = icmp eq i64 %10, 51
br i1 %11, label %14, label %3
12: ; preds = %3
%13 = trunc i64 %4 to i32
br label %14
14: ; preds = %9, %12
%15 = phi i32 [ %13, %12 ], [ 51, %9 ]
%16 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 0
br label %17
17: ; preds = %22, %14
%18 = phi i32* [ %16, %14 ], [ %23, %22 ]
%19 = phi i32 [ 0, %14 ], [ %24, %22 ]
%20 = load i32, i32* %18
%21 = icmp eq i32 %20, 48
br i1 %21, label %29, label %22
22: ; preds = %17
%23 = call i32* @hop(i32* %18)
%24 = add nuw nsw i32 %19, 1
%25 = call i32 @is_in_bound(i32* %16, i32 %15, i32* %23)
%26 = icmp eq i32 %25, 0
%27 = icmp ugt i32 %19, 48
%28 = select i1 %26, i1 true, i1 %27
br i1 %28, label %29, label %17
29: ; preds = %22, %17
%30 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.4, i64 0, i64 0), %17 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0), %22 ]
%31 = phi i32 [ %19, %17 ], [ %24, %22 ]
%32 = call i32 @puts(i8* dereferenceable(1) %30)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %31)
ret i32 0
}