#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 *, int);
scalar_t__ scanf(char *, int *);
int main() {
  int arr[50];
  int num;
  int size = 0;
  int hops = 0;
  int found = 0;
  int currPos = 0;
  int *ptr = arr;
  while (scanf("%d", &num) != EOF) {
    arr[size] = num;
    size++;
  }
  while (hops < 50) {
    if (!is_in_bound(arr, size, ptr)) {
      break;
    }
    ptr = hop(&arr[currPos]);
    if (arr[currPos] == 0) {
      found = 1;
      break;
    }
    currPos = currPos + arr[currPos];
    hops++;
  }
  printf("%d\n", found);
  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,-0xd8(%rbp)
movl   $0x0,-0xdc(%rbp)
movl   $0x0,-0xe0(%rbp)
movl   $0x0,-0xe4(%rbp)
lea    -0xd0(%rbp),%rax
mov    %rax,-0xf0(%rbp)
lea    0xe71(%rip),%rdi
lea    -0xd4(%rbp),%rsi
call   1050 <scanf@plt>
mov    0x2e46(%rip),%rcx
cmp    (%rcx),%rax
je     11d3 <main+0x93>
mov    -0xd4(%rbp),%ecx
movslq -0xd8(%rbp),%rax
mov    %ecx,-0xd0(%rbp,%rax,4)
mov    -0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8(%rbp)
jmp    1188 <main+0x48>
jmp    11d8 <main+0x98>
cmpl   $0x32,-0xdc(%rbp)
jge    127f <main+0x13f>
lea    -0xd0(%rbp),%rdi
mov    -0xd8(%rbp),%esi
mov    -0xf0(%rbp),%rdx
call   1060 <is_in_bound@plt>
cmp    $0x0,%eax
jne    120c <main+0xcc>
jmp    127f <main+0x13f>
movslq -0xe4(%rbp),%rax
lea    -0xd0(%rbp),%rdi
shl    $0x2,%rax
add    %rax,%rdi
call   1030 <hop@plt>
mov    %rax,-0xf0(%rbp)
movslq -0xe4(%rbp),%rax
cmpl   $0x0,-0xd0(%rbp,%rax,4)
jne    1251 <main+0x111>
movl   $0x1,-0xe0(%rbp)
jmp    127f <main+0x13f>
mov    -0xe4(%rbp),%eax
movslq -0xe4(%rbp),%rcx
add    -0xd0(%rbp,%rcx,4),%eax
mov    %eax,-0xe4(%rbp)
mov    -0xdc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xdc(%rbp)
jmp    11d8 <main+0x98>
mov    -0xe0(%rbp),%esi
lea    0xd77(%rip),%rdi
call   1040 <printf@plt>
mov    -0xdc(%rbp),%esi
lea    0xd65(%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   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
lea    0xea8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x2e7f(%rip),%r15
xor    %r12d,%r12d
mov    $0x0,%ebx
cmp    (%r15),%rax
je     11ac <main+0x6c>
xor    %ebx,%ebx
lea    0xe81(%rip),%r14
lea    0xc(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0xc(%rsp),%eax
mov    %eax,0x10(%rsp,%rbx,4)
add    $0x1,%rbx
mov    %r14,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
cmp    (%r15),%rax
jne    1190 <main+0x50>
lea    0x10(%rsp),%r15
mov    %r15,%rax
xor    %r13d,%r13d
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebx,%esi
mov    %rax,%rdx
call   1060 <is_in_bound@plt>
test   %eax,%eax
je     1204 <main+0xc4>
movslq %r12d,%rbp
lea    (%rsp,%rbp,4),%rdi
add    $0x10,%rdi
call   1030 <hop@plt>
mov    0x10(%rsp,%rbp,4),%ecx
test   %ecx,%ecx
je     11fe <main+0xbe>
add    %ecx,%r12d
add    $0x1,%r13d
cmp    $0x32,%r13d
jne    11c0 <main+0x80>
mov    $0x32,%r13d
jmp    1204 <main+0xc4>
mov    $0x1,%r14d
lea    0xdf8(%rip),%rbx
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r13d,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xd8,%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 = [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
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%9 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
store i32* %9, i32** %8
br label %10
10: ; preds = %14, %0
%11 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%12 = load i64, i64* @EOF
%13 = icmp ne i64 %11, %12
br i1 %13, label %14, label %21
14: ; preds = %10
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %17
store i32 %15, i32* %18
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %10
21: ; preds = %10
br label %22
22: ; preds = %43, %21
%23 = load i32, i32* %5
%24 = icmp slt i32 %23, 50
br i1 %24, label %25, label %52
25: ; preds = %22
%26 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%27 = load i32, i32* %4
%28 = load i32*, i32** %8
%29 = call i32 @is_in_bound(i32* %26, i32 %27, i32* %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %25
br label %52
32: ; preds = %25
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %34
%36 = call i32* @hop(i32* %35)
store i32* %36, i32** %8
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %32
store i32 1, i32* %6
br label %52
43: ; preds = %32
%44 = load i32, i32* %7
%45 = load i32, i32* %7
%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 = add nsw i32 %44, %48
store i32 %49, i32* %7
%50 = load i32, i32* %5
%51 = add nsw i32 %50, 1
store i32 %51, i32* %5
br label %22
52: ; preds = %42, %31, %22
%53 = load i32, i32* %6
%54 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %53)
%55 = load i32, i32* %5
%56 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %55)
ret i32 0
}

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