#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 *);
scalar_t__ is_in_bound(int *, int, int *);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, int *);
int main() {
  int arr[50];
  int input;
  int size = 0;
  int output = 0;
  int *elem = NULL;
  int hops = 0;
  while (scanf("%d", &input) == EOF || size < 50) {
    arr[size] = input;
    size++;
  }
  elem = &arr[0];
  while (hops < 50) {
    if (is_in_bound(arr, size, elem) == 0) {
      break;
    }
    if (*elem == 0) {
      output = 1;
      break;
    }
    elem = hop(elem);
    hops++;
  }
  printf("\n%d", output);
  printf("\n%d", 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)
movq   $0x0,-0xe8(%rbp)
movl   $0x0,-0xec(%rbp)
lea    0xe7f(%rip),%rdi
lea    -0xd4(%rbp),%rsi
call   1050 <scanf@plt>
mov    %rax,%rcx
mov    $0x1,%al
mov    0x2e4e(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0xed(%rbp)
je     11b9 <main+0x79>
cmpl   $0x32,-0xd8(%rbp)
setl   %al
mov    %al,-0xed(%rbp)
mov    -0xed(%rbp),%al
test   $0x1,%al
jne    11cc <main+0x8c>
jmp    11f4 <main+0xb4>
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    117b <main+0x3b>
lea    -0xd0(%rbp),%rax
mov    %rax,-0xe8(%rbp)
cmpl   $0x32,-0xec(%rbp)
jge    127d <main+0x13d>
lea    -0xd0(%rbp),%rdi
mov    -0xd8(%rbp),%esi
mov    -0xe8(%rbp),%rdx
call   1060 <is_in_bound@plt>
cmp    $0x0,%rax
jne    1237 <main+0xf7>
jmp    127d <main+0x13d>
mov    -0xe8(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1256 <main+0x116>
movl   $0x1,-0xdc(%rbp)
jmp    127d <main+0x13d>
mov    -0xe8(%rbp),%rdi
call   1030 <hop@plt>
mov    %rax,-0xe8(%rbp)
mov    -0xec(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xec(%rbp)
jmp    1202 <main+0xc2>
mov    -0xdc(%rbp),%esi
lea    0xd76(%rip),%rdi
call   1040 <printf@plt>
mov    -0xec(%rbp),%esi
lea    0xd64(%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    0xea9(%rip),%r14
lea    0xc(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
xor    %r13d,%r13d
mov    0x2e76(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13,%rbx
mov    0xc(%rsp),%eax
mov    %eax,0x10(%rsp,%r13,4)
add    $0x1,%r13
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
cmp    0x0(%rbp),%rax
je     1180 <main+0x40>
cmp    $0x31,%rbx
jb     1180 <main+0x40>
xor    %r14d,%r14d
lea    0x10(%rsp),%r15
xor    %r12d,%r12d
mov    %r15,%rbp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    %r13d,%esi
mov    %rbp,%rdx
call   1060 <is_in_bound@plt>
test   %rax,%rax
je     11fc <main+0xbc>
cmpl   $0x0,0x0(%rbp)
je     11f6 <main+0xb6>
mov    %rbp,%rdi
call   1030 <hop@plt>
mov    %rax,%rbp
add    $0x1,%r12d
cmp    $0x32,%r12d
jne    11c0 <main+0x80>
mov    $0x32,%r12d
jmp    11fc <main+0xbc>
mov    $0x1,%r14d
lea    0xdfd(%rip),%rbx
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r12d,%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"\0A%d\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
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
store i32* null, i32** %6
store i32 0, i32* %7
br label %8
8: ; preds = %17, %0
%9 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%10 = load i64, i64* @EOF
%11 = icmp eq i64 %9, %10
br i1 %11, label %15, label %12
12: ; preds = %8
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 50
br label %15
15: ; preds = %12, %8
%16 = phi i1 [ true, %8 ], [ %14, %12 ]
br i1 %16, label %17, label %24
17: ; preds = %15
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %20
store i32 %18, i32* %21
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %8
24: ; preds = %15
%25 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
store i32* %25, i32** %6
br label %26
26: ; preds = %41, %24
%27 = load i32, i32* %7
%28 = icmp slt i32 %27, 50
br i1 %28, label %29, label %46
29: ; preds = %26
%30 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%31 = load i32, i32* %4
%32 = load i32*, i32** %6
%33 = call i64 @is_in_bound(i32* %30, i32 %31, i32* %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %29
br label %46
36: ; preds = %29
%37 = load i32*, i32** %6
%38 = load i32, i32* %37
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %36
store i32 1, i32* %5
br label %46
41: ; preds = %36
%42 = load i32*, i32** %6
%43 = call i32* @hop(i32* %42)
store i32* %43, i32** %6
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
br label %26
46: ; preds = %40, %35, %26
%47 = load i32, i32* %5
%48 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %47)
%49 = load i32, i32* %7
%50 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %49)
ret i32 0
}

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