#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 /*<<< orphan*/ PrintResult(int, int);
int *hop(int *);
scalar_t__ is_in_bound(int *, int, int *);
scalar_t__ scanf(char *, int *);
int main() {
  int arr[50];
  int step = 1;
  int *p = NULL;
  int i = 1;
  int j = 0;
  int index = 0;
  int tempIndex = 0;
  while (scanf("%d", &arr[j]) != EOF) {
    j++;
  }
  while (true) {
    p = &arr[index];
    if (step == 50 || is_in_bound(arr, j, p) == 0) {
      if (step < 50)
        step--;
      PrintResult(0, step);
      return 0;
    }
    if (*p == 0) {
      PrintResult(1, step);
      return 0;
    }
    tempIndex = *p;
    p = hop(&arr[index]);
    index = index + tempIndex;
    step++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xd4(%rbp)
movq   $0x0,-0xe0(%rbp)
movl   $0x1,-0xe4(%rbp)
movl   $0x0,-0xe8(%rbp)
movl   $0x0,-0xec(%rbp)
movl   $0x0,-0xf0(%rbp)
movslq -0xe8(%rbp),%rax
lea    -0xd0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe55(%rip),%rdi
call   1040 <scanf@plt>
mov    0x2e31(%rip),%rcx
cmp    (%rcx),%rax
je     11d4 <main+0x94>
mov    -0xe8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe8(%rbp)
jmp    118f <main+0x4f>
jmp    11d9 <main+0x99>
movslq -0xec(%rbp),%rcx
lea    -0xd0(%rbp),%rax
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0xe0(%rbp)
cmpl   $0x32,-0xd4(%rbp)
je     1225 <main+0xe5>
lea    -0xd0(%rbp),%rdi
mov    -0xe8(%rbp),%esi
mov    -0xe0(%rbp),%rdx
call   1060 <is_in_bound@plt>
cmp    $0x0,%rax
jne    125a <main+0x11a>
cmpl   $0x32,-0xd4(%rbp)
jge    1241 <main+0x101>
mov    -0xd4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xd4(%rbp)
mov    -0xd4(%rbp),%esi
xor    %edi,%edi
call   1050 <PrintResult@plt>
movl   $0x0,-0x4(%rbp)
jmp    12dc <main+0x19c>
mov    -0xe0(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1286 <main+0x146>
mov    -0xd4(%rbp),%esi
mov    $0x1,%edi
call   1050 <PrintResult@plt>
movl   $0x0,-0x4(%rbp)
jmp    12dc <main+0x19c>
mov    -0xe0(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xf0(%rbp)
movslq -0xec(%rbp),%rax
lea    -0xd0(%rbp),%rdi
shl    $0x2,%rax
add    %rax,%rdi
call   1030 <hop@plt>
mov    %rax,-0xe0(%rbp)
mov    -0xec(%rbp),%eax
add    -0xf0(%rbp),%eax
mov    %eax,-0xec(%rbp)
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    11d9 <main+0x99>
mov    -0x4(%rbp),%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,%ebx
mov    %rsp,%rbp
lea    0xea0(%rip),%r14
mov    0x2e81(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbp,%rsi
call   1040 <scanf@plt>
add    $0x1,%ebx
add    $0x4,%rbp
cmp    (%r15),%rax
jne    1170 <main+0x30>
mov    $0x1,%r15d
xor    %r12d,%r12d
mov    %rsp,%r14
mov    %r14,%r13
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r13,%rdx
call   1060 <is_in_bound@plt>
test   %rax,%rax
je     11dc <main+0x9c>
mov    0x0(%r13),%ebp
test   %ebp,%ebp
je     11e8 <main+0xa8>
mov    %r13,%rdi
call   1030 <hop@plt>
add    %ebp,%r12d
add    $0x1,%r15d
movslq %r12d,%rax
lea    (%rsp,%rax,4),%r13
cmp    $0x32,%r15d
jne    11a0 <main+0x60>
mov    $0x32,%r15d
cmp    $0x32,%r15d
sbb    $0x0,%r15d
xor    %edi,%edi
jmp    11ed <main+0xad>
mov    $0x1,%edi
mov    %r15d,%esi
call   1050 <PrintResult@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
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 1, i32* %3
store i32* null, i32** %4
store i32 1, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %16, %0
%10 = load i32, i32* %6
%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 %19
16: ; preds = %9
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 1
store i32 %18, i32* %6
br label %9
19: ; preds = %9
br label %20
20: ; preds = %19, %48
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %22
store i32* %23, i32** %4
%24 = load i32, i32* %3
%25 = icmp eq i32 %24, 50
br i1 %25, label %32, label %26
26: ; preds = %20
%27 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%28 = load i32, i32* %6
%29 = load i32*, i32** %4
%30 = call i64 @is_in_bound(i32* %27, i32 %28, i32* %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %41
32: ; preds = %26, %20
%33 = load i32, i32* %3
%34 = icmp slt i32 %33, 50
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i32, i32* %3
%37 = add nsw i32 %36, -1
store i32 %37, i32* %3
br label %38
38: ; preds = %35, %32
%39 = load i32, i32* %3
%40 = call i32 @PrintResult(i32 0, i32 %39)
store i32 0, i32* %1
br label %60
41: ; preds = %26
%42 = load i32*, i32** %4
%43 = load i32, i32* %42
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = load i32, i32* %3
%47 = call i32 @PrintResult(i32 1, i32 %46)
store i32 0, i32* %1
br label %60
48: ; preds = %41
%49 = load i32*, i32** %4
%50 = load i32, i32* %49
store i32 %50, i32* %8
%51 = load i32, i32* %7
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %52
%54 = call i32* @hop(i32* %53)
store i32* %54, i32** %4
%55 = load i32, i32* %7
%56 = load i32, i32* %8
%57 = add nsw i32 %55, %56
store i32 %57, i32* %7
%58 = load i32, i32* %3
%59 = add nsw i32 %58, 1
store i32 %59, i32* %3
br label %20
60: ; preds = %45, %38
%61 = load i32, i32* %1
ret i32 %61
}

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