#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 arr[50];
  int lenght = 0;
  int counter = 0;
  int *ptr = &arr[0];
  while (scanf("%d", &arr[lenght]) != EOF || lenght < 50) {
    lenght++;
  };
  for (; counter <= 50; counter++) {
    ptr = hop(ptr);
    if (*ptr == 0) {
      printf("1\n");
      printf("%d", counter);
      break;
    };
    if (!is_in_bound(arr, lenght, ptr)) {
      printf("0\n");
      printf("%d", counter);
      break;
    };
    if (counter == 50 && *ptr != 0) {
      printf("0\n");
      printf("%d", counter);
      break;
    };
  };
  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)
lea    -0xd0(%rbp),%rax
mov    %rax,-0xe0(%rbp)
movslq -0xd4(%rbp),%rax
lea    -0xd0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe70(%rip),%rdi
call   1050 <scanf@plt>
mov    %rax,%rcx
mov    $0x1,%al
mov    0x2e47(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0xe1(%rbp)
jne    11c0 <main+0x80>
cmpl   $0x32,-0xd4(%rbp)
setl   %al
mov    %al,-0xe1(%rbp)
mov    -0xe1(%rbp),%al
test   $0x1,%al
jne    11d3 <main+0x93>
jmp    11e7 <main+0xa7>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    1174 <main+0x34>
jmp    11ec <main+0xac>
cmpl   $0x32,-0xd8(%rbp)
jg     12e9 <main+0x1a9>
mov    -0xe0(%rbp),%rdi
call   1030 <hop@plt>
mov    %rax,-0xe0(%rbp)
mov    -0xe0(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1243 <main+0x103>
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xd8(%rbp),%esi
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e9 <main+0x1a9>
lea    -0xd0(%rbp),%rdi
mov    -0xd4(%rbp),%esi
mov    -0xe0(%rbp),%rdx
call   1060 <is_in_bound@plt>
cmp    $0x0,%eax
jne    128c <main+0x14c>
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xd8(%rbp),%esi
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e9 <main+0x1a9>
cmpl   $0x32,-0xd8(%rbp)
jne    12d0 <main+0x190>
mov    -0xe0(%rbp),%rax
cmpl   $0x0,(%rax)
je     12d0 <main+0x190>
lea    0xd56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xd8(%rbp),%esi
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e9 <main+0x1a9>
jmp    12d5 <main+0x195>
mov    -0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8(%rbp)
jmp    11ec <main+0xac>
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,%rbp
xor    %r13d,%r13d
lea    0xe92(%rip),%r14
mov    0x2e73(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rbx
mov    %r14,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
add    $0x1,%r13
add    $0x4,%rbp
cmp    (%r15),%rax
jne    1180 <main+0x30>
cmp    $0x32,%rbx
jb     1180 <main+0x30>
mov    %rsp,%rdi
call   1040 <hop@plt>
lea    0xe55(%rip),%rbx
cmpl   $0x0,(%rax)
je     11fe <main+0xae>
mov    %rax,%rbp
add    $0xffffffffffffffff,%r13
xor    %r15d,%r15d
mov    %rsp,%r12
lea    0xe3a(%rip),%r14
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %r13d,%esi
mov    %rbp,%rdx
call   1070 <is_in_bound@plt>
test   %eax,%eax
je     1204 <main+0xb4>
cmp    $0x32,%r15d
je     1231 <main+0xe1>
add    $0x1,%r15d
mov    %rbp,%rdi
call   1040 <hop@plt>
mov    %rax,%rbp
cmpl   $0x0,(%rax)
jne    11d0 <main+0x80>
jmp    1201 <main+0xb1>
xor    %r15d,%r15d
mov    %rbx,%r14
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xded(%rip),%rdi
mov    %r15d,%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
mov    $0x32,%r15d
cmpl   $0x0,0x0(%rbp)
jne    1204 <main+0xb4>
jmp    121d <main+0xcd>

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"
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* %4
%6 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
store i32* %6, i32** %5
br label %7
7: ; preds = %19, %0
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %9
%11 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %10)
%12 = load i64, i64* @EOF
%13 = icmp ne i64 %11, %12
br i1 %13, label %17, label %14
14: ; preds = %7
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 50
br label %17
17: ; preds = %14, %7
%18 = phi i1 [ true, %7 ], [ %16, %14 ]
br i1 %18, label %19, label %22
19: ; preds = %17
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %7
22: ; preds = %17
br label %23
23: ; preds = %58, %22
%24 = load i32, i32* %4
%25 = icmp sle i32 %24, 50
br i1 %25, label %26, label %61
26: ; preds = %23
%27 = load i32*, i32** %5
%28 = call i32* @hop(i32* %27)
store i32* %28, i32** %5
%29 = load i32*, i32** %5
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %26
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%34 = load i32, i32* %4
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %34)
br label %61
36: ; preds = %26
%37 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%38 = load i32, i32* %3
%39 = load i32*, i32** %5
%40 = call i32 @is_in_bound(i32* %37, i32 %38, i32* %39)
%41 = icmp ne i32 %40, 0
br i1 %41, label %46, label %42
42: ; preds = %36
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%44 = load i32, i32* %4
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %44)
br label %61
46: ; preds = %36
%47 = load i32, i32* %4
%48 = icmp eq i32 %47, 50
br i1 %48, label %49, label %57
49: ; preds = %46
%50 = load i32*, i32** %5
%51 = load i32, i32* %50
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %49
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%55 = load i32, i32* %4
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %55)
br label %61
57: ; preds = %49, %46
br label %58
58: ; preds = %57
%59 = load i32, i32* %4
%60 = add nsw i32 %59, 1
store i32 %60, i32* %4
br label %23
61: ; preds = %53, %42, %32, %23
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@str.3 = [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 = %3, %0
%4 = phi i64 [ %11, %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 ne i64 %6, %7
%9 = icmp ult i64 %4, 50
%10 = select i1 %8, i1 true, i1 %9
%11 = add nuw i64 %4, 1
br i1 %10, label %3, label %12
12: ; preds = %3
%13 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 0
%14 = trunc i64 %4 to i32
%15 = call i32* @hop(i32* %13)
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 0
br i1 %17, label %33, label %18
18: ; preds = %12, %28
%19 = phi i32* [ %30, %28 ], [ %15, %12 ]
%20 = phi i32 [ %29, %28 ], [ 0, %12 ]
%21 = call i32 @is_in_bound(i32* %13, i32 %14, i32* %19)
%22 = icmp eq i32 %21, 0
br i1 %22, label %33, label %23
23: ; preds = %18
%24 = icmp eq i32 %20, 50
br i1 %24, label %25, label %28
25: ; preds = %23
%26 = load i32, i32* %19
%27 = icmp eq i32 %26, 0
br i1 %27, label %38, label %33
28: ; preds = %23
%29 = add nuw nsw i32 %20, 1
%30 = call i32* @hop(i32* %19)
%31 = load i32, i32* %30
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %18
33: ; preds = %28, %18, %12, %25
%34 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.3, i64 0, i64 0), %25 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.4, i64 0, i64 0), %12 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.3, i64 0, i64 0), %18 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.4, i64 0, i64 0), %28 ]
%35 = phi i32 [ 50, %25 ], [ 0, %12 ], [ %20, %18 ], [ %29, %28 ]
%36 = call i32 @puts(i8* dereferenceable(1) %34)
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %35)
br label %38
38: ; preds = %33, %25
ret i32 0
}