#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 */
int EOF;
char getchar();
int *hop(int *);
int /*<<< orphan*/ is_in_bound(int *, int, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int arr[50] = {0};
  int size = 0;
  for (int i = 0; i < 50 && getchar() != '\n'; ++i) {
    scanf("%d", &arr[i]);
    size = i;
    if (arr[i] == EOF)
      break;
  }
  int *a = &arr[0];
  for (int i = 0; i < 50; ++i) {
    if (!is_in_bound(arr, size, a)) {
      printf("%d\n%d\n", 0, i + 1);
      return 0;
    }
    if (*a == 0) {
      printf("%d\n%d\n", 1, i + 1);
      return 0;
    }
    a = hop(a);
  }
  printf("0\n50");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xd0(%rbp),%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1050 <memset@plt>
movl   $0x0,-0xd4(%rbp)
movl   $0x0,-0xd8(%rbp)
xor    %eax,%eax
cmpl   $0x32,-0xd8(%rbp)
mov    %al,-0xe5(%rbp)
jge    11c4 <main+0x64>
mov    $0x0,%al
call   1060 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0xe5(%rbp)
mov    -0xe5(%rbp),%al
test   $0x1,%al
jne    11d7 <main+0x77>
jmp    123f <main+0xdf>
movslq -0xd8(%rbp),%rax
lea    -0xd0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe0d(%rip),%rdi
call   1070 <scanf@plt>
mov    -0xd8(%rbp),%eax
mov    %eax,-0xd4(%rbp)
movslq -0xd8(%rbp),%rax
mov    -0xd0(%rbp,%rax,4),%eax
mov    0x2dcf(%rip),%rcx
cmp    (%rcx),%eax
jne    1226 <main+0xc6>
jmp    123f <main+0xdf>
jmp    122b <main+0xcb>
mov    -0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8(%rbp)
jmp    1199 <main+0x39>
lea    -0xd0(%rbp),%rax
mov    %rax,-0xe0(%rbp)
movl   $0x0,-0xe4(%rbp)
cmpl   $0x32,-0xe4(%rbp)
jge    130a <main+0x1aa>
lea    -0xd0(%rbp),%rdi
mov    -0xd4(%rbp),%esi
mov    -0xe0(%rbp),%rdx
call   1080 <is_in_bound@plt>
cmp    $0x0,%eax
jne    12ab <main+0x14b>
mov    -0xe4(%rbp),%edx
add    $0x1,%edx
lea    0xd6d(%rip),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    131f <main+0x1bf>
mov    -0xe0(%rbp),%rax
cmpl   $0x0,(%rax)
jne    12e3 <main+0x183>
mov    -0xe4(%rbp),%edx
add    $0x1,%edx
lea    0xd38(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    131f <main+0x1bf>
mov    -0xe0(%rbp),%rdi
call   1030 <hop@plt>
mov    %rax,-0xe0(%rbp)
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    1257 <main+0xf7>
lea    0xcf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd0,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0xc0(%rsp)
xor    %r15d,%r15d
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     1217 <main+0xc7>
mov    $0xffffffff,%r15d
mov    %rsp,%rbp
lea    0xe2d(%rip),%r14
mov    0x2e0e(%rip),%r12
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
mov    0x0(%rbp),%eax
cmp    (%r12),%eax
je     1213 <main+0xc3>
cmp    $0x31,%rbx
jae    1213 <main+0xc3>
add    $0x1,%rbx
xor    %eax,%eax
call   1050 <getchar@plt>
add    $0x1,%r15d
add    $0x4,%rbp
cmp    $0xa,%al
jne    11e0 <main+0x90>
jmp    1217 <main+0xc7>
add    $0x1,%r15d
mov    $0x1,%ebp
mov    %rsp,%r14
mov    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15d,%esi
mov    %rbx,%rdx
call   1070 <is_in_bound@plt>
test   %eax,%eax
je     126a <main+0x11a>
cmpl   $0x0,(%rbx)
je     1275 <main+0x125>
mov    %rbx,%rdi
call   1030 <hop@plt>
mov    %rax,%rbx
add    $0x1,%ebp
cmp    $0x33,%ebp
jne    1230 <main+0xe0>
lea    0xda9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    128a <main+0x13a>
lea    0xd92(%rip),%rdi
xor    %esi,%esi
jmp    1281 <main+0x131>
lea    0xd87(%rip),%rdi
mov    $0x1,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@EOF = global i32 0
@.str.1 = [7 x i8] c"%d\0A%d\0A\00"
@.str.2 = [5 x i8] c"0\0A50\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [50 x i32]* %2 to i8*
store i32 0, i32* %3
store i32 0, i32* %4
br label %8
8: ; preds = %31, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 50
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = call signext i8 (...) @getchar()
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 10
br label %15
15: ; preds = %11, %8
%16 = phi i1 [ false, %8 ], [ %14, %11 ]
br i1 %16, label %17, label %34
17: ; preds = %15
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %19
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %20)
%22 = load i32, i32* %4
store i32 %22, i32* %3
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = load i32, i32* @EOF
%28 = icmp eq i32 %26, %27
br i1 %28, label %29, label %30
29: ; preds = %17
br label %34
30: ; preds = %17
br label %31
31: ; preds = %30
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %8
34: ; preds = %29, %15
%35 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
store i32* %35, i32** %5
store i32 0, i32* %6
br label %36
36: ; preds = %60, %34
%37 = load i32, i32* %6
%38 = icmp slt i32 %37, 50
br i1 %38, label %39, label %63
39: ; preds = %36
%40 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%41 = load i32, i32* %3
%42 = load i32*, i32** %5
%43 = call i32 @is_in_bound(i32* %40, i32 %41, i32* %42)
%44 = icmp ne i32 %43, 0
br i1 %44, label %49, label %45
45: ; preds = %39
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %47)
store i32 0, i32* %1
br label %65
49: ; preds = %39
%50 = load i32*, i32** %5
%51 = load i32, i32* %50
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %49
%54 = load i32, i32* %6
%55 = add nsw i32 %54, 1
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %55)
store i32 0, i32* %1
br label %65
57: ; preds = %49
%58 = load i32*, i32** %5
%59 = call i32* @hop(i32* %58)
store i32* %59, i32** %5
br label %60
60: ; preds = %57
%61 = load i32, i32* %6
%62 = add nsw i32 %61, 1
store i32 %62, i32* %6
br label %36
63: ; preds = %36
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %65
65: ; preds = %63, %53, %45
%66 = load i32, i32* %1
ret i32 %66
}

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