#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 *, ...);
scalar_t__ scanf(char *, int *);
int main() {
  int i = 0, in[51] = {0}, size = 0, *el = 0, a = 0;
  while (1) {
    if (scanf("%d", &in[i]) == EOF)
      break;
    else
      i++;
  }
  el = in;
  size = i;
  i = 1;
  for (a = 0; a < 50; a++) {
    if (is_in_bound(in, size, el) == 0) {
      i = 0;
      printf("0\n");
      break;
    }
    if (*el == 0) {
      i = 0;
      printf("1\n");
      break;
    }
    el = hop(el);
  }
  if (i)
    printf("0\n");
  printf("%d\n", a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0xcc,%edx
call   1050 <memset@plt>
movl   $0x0,-0xe4(%rbp)
movq   $0x0,-0xf0(%rbp)
movl   $0x0,-0xf4(%rbp)
movslq -0x8(%rbp),%rax
lea    -0xe0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe4c(%rip),%rdi
call   1060 <scanf@plt>
mov    0x2e28(%rip),%rcx
cmp    (%rcx),%rax
jne    11ce <main+0x7e>
jmp    11dc <main+0x8c>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119b <main+0x4b>
lea    -0xe0(%rbp),%rax
mov    %rax,-0xf0(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xe4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x0,-0xf4(%rbp)
cmpl   $0x32,-0xf4(%rbp)
jge    129f <main+0x14f>
lea    -0xe0(%rbp),%rdi
mov    -0xe4(%rbp),%esi
mov    -0xf0(%rbp),%rdx
call   1070 <is_in_bound@plt>
cmp    $0x0,%rax
jne    124e <main+0xfe>
movl   $0x0,-0x8(%rbp)
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    129f <main+0x14f>
mov    -0xf0(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1278 <main+0x128>
movl   $0x0,-0x8(%rbp)
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    129f <main+0x14f>
mov    -0xf0(%rbp),%rdi
call   1030 <hop@plt>
mov    %rax,-0xf0(%rbp)
mov    -0xf4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4(%rbp)
jmp    1204 <main+0xb4>
cmpl   $0x0,-0x8(%rbp)
je     12b7 <main+0x167>
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xf4(%rbp),%esi
lea    0xd45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0xbc(%rsp)
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)
mov    $0xffffffff,%ebx
mov    %rsp,%rbp
lea    0xe3e(%rip),%r14
mov    0x2e1f(%rip),%r15
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbp,%rsi
call   1060 <scanf@plt>
add    $0x1,%ebx
add    $0x4,%rbp
cmp    (%r15),%rax
jne    11d0 <main+0x80>
xor    %r12d,%r12d
mov    %rsp,%r15
lea    0xe15(%rip),%r14
lea    0xe0c(%rip),%r13
mov    %r15,%rbp
xchg   %ax,%ax
mov    %r15,%rdi
mov    %ebx,%esi
mov    %rbp,%rdx
call   1070 <is_in_bound@plt>
test   %rax,%rax
je     1238 <main+0xe8>
cmpl   $0x0,0x0(%rbp)
je     1235 <main+0xe5>
mov    %rbp,%rdi
call   1040 <hop@plt>
mov    %rax,%rbp
add    $0x1,%r12d
cmp    $0x32,%r12d
jne    1200 <main+0xb0>
mov    $0x32,%r12d
jmp    1238 <main+0xe8>
mov    %r13,%r14
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xdbc(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <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 = [3 x i8] c"0\0A\00"
@.str.2 = [3 x i8] c"1\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [51 x i32]
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%7 = bitcast [51 x i32]* %3 to i8*
store i32 0, i32* %4
store i32* null, i32** %5
store i32 0, i32* %6
br label %8
8: ; preds = %0, %19
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [51 x i32], [51 x i32]* %3, i64 0, i64 %10
%12 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %11)
%13 = load i64, i64* @EOF
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %8
br label %20
16: ; preds = %8
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %19
19: ; preds = %16
br label %8
20: ; preds = %15
%21 = getelementptr inbounds [51 x i32], [51 x i32]* %3, i64 0, i64 0
store i32* %21, i32** %5
%22 = load i32, i32* %2
store i32 %22, i32* %4
store i32 1, i32* %2
store i32 0, i32* %6
br label %23
23: ; preds = %43, %20
%24 = load i32, i32* %6
%25 = icmp slt i32 %24, 50
br i1 %25, label %26, label %46
26: ; preds = %23
%27 = getelementptr inbounds [51 x i32], [51 x i32]* %3, i64 0, i64 0
%28 = load i32, i32* %4
%29 = load i32*, i32** %5
%30 = call i64 @is_in_bound(i32* %27, i32 %28, i32* %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %26
store i32 0, i32* %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %46
34: ; preds = %26
%35 = load i32*, i32** %5
%36 = load i32, i32* %35
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %34
store i32 0, i32* %2
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %46
40: ; preds = %34
%41 = load i32*, i32** %5
%42 = call i32* @hop(i32* %41)
store i32* %42, i32** %5
br label %43
43: ; preds = %40
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %23
46: ; preds = %38, %32, %23
%47 = load i32, i32* %2
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %51
51: ; preds = %49, %46
%52 = load i32, i32* %6
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %52)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.3 = [4 x i8] c"%d\0A\00"
@str.4 = [2 x i8] c"1\00"
@str.5 = [2 x i8] c"0\00"
define i32 @main() {
%1 = alloca [51 x i32]
%2 = bitcast [51 x i32]* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = phi i64 [ %9, %3 ], [ 0, %0 ]
%5 = getelementptr inbounds [51 x i32], [51 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 [51 x i32], [51 x i32]* %1, i64 0, i64 0
br label %13
13: ; preds = %10, %21
%14 = phi i32 [ 0, %10 ], [ %23, %21 ]
%15 = phi i32* [ %12, %10 ], [ %22, %21 ]
%16 = call i64 @is_in_bound(i32* %12, i32 %11, i32* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %25, label %18
18: ; preds = %13
%19 = load i32, i32* %15
%20 = icmp eq i32 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %18
%22 = call i32* @hop(i32* %15)
%23 = add nuw nsw i32 %14, 1
%24 = icmp eq i32 %23, 50
br i1 %24, label %25, label %13
25: ; preds = %21, %18, %13
%26 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.5, i64 0, i64 0), %13 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.4, i64 0, i64 0), %18 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.5, i64 0, i64 0), %21 ]
%27 = phi i32 [ %14, %13 ], [ %14, %18 ], [ 50, %21 ]
%28 = call i32 @puts(i8* dereferenceable(1) %26)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %27)
ret i32 0
}