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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
movw   $0x0,-0xd2(%rbp)
movzwl -0xd2(%rbp),%eax
cmp    $0x32,%eax
jge    11b6 <main+0x76>
movzwl -0xd2(%rbp),%eax
lea    -0xd0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe7e(%rip),%rdi
call   1050 <scanf@plt>
cmp    $0x1,%eax
je     119a <main+0x5a>
jmp    11b6 <main+0x76>
jmp    119f <main+0x5f>
mov    -0xd2(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0xd2(%rbp)
jmp    115b <main+0x1b>
mov    -0xd2(%rbp),%ax
mov    %ax,-0xd4(%rbp)
lea    -0xd0(%rbp),%rax
mov    %rax,-0xe0(%rbp)
movw   $0x0,-0xd2(%rbp)
movzwl -0xd2(%rbp),%eax
cmp    $0x32,%eax
jge    1251 <main+0x111>
mov    -0xe0(%rbp),%rax
cmpl   $0x0,(%rax)
je     1222 <main+0xe2>
lea    -0xd0(%rbp),%rdi
mov    -0xd4(%rbp),%ax
mov    -0xe0(%rbp),%rdx
movzwl %ax,%esi
call   1060 <is_in_bound@plt>
cmp    $0x0,%rax
jne    1227 <main+0xe7>
jmp    1251 <main+0x111>
mov    -0xe0(%rbp),%rdi
call   1030 <hop@plt>
mov    %rax,-0xe0(%rbp)
mov    -0xd2(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0xd2(%rbp)
jmp    11db <main+0x9b>
lea    -0xd0(%rbp),%rdi
mov    -0xd4(%rbp),%ax
mov    -0xe0(%rbp),%rdx
movzwl %ax,%esi
call   1060 <is_in_bound@plt>
cmp    $0x0,%rax
jne    128b <main+0x14b>
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e9 <main+0x1a9>
movzwl -0xd2(%rbp),%eax
cmp    $0x32,%eax
jne    12ae <main+0x16e>
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e4 <main+0x1a4>
mov    -0xe0(%rbp),%rax
cmpl   $0x0,(%rax)
jne    12d1 <main+0x191>
lea    0xd3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12df <main+0x19f>
lea    0xd28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e4 <main+0x1a4>
jmp    12e9 <main+0x1a9>
movzwl -0xd2(%rbp),%esi
lea    0xd0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xc8,%rsp
mov    %rsp,%rbx
xor    %ebp,%ebp
lea    0xe98(%rip),%r14
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    1192 <main+0x42>
add    $0x1,%rbp
add    $0x4,%rbx
cmp    $0x32,%rbp
jne    1170 <main+0x20>
mov    $0x32,%bp
mov    %rsp,%r14
xor    %ebx,%ebx
movzwl %bp,%r15d
mov    %r14,%rbp
xchg   %ax,%ax
cmpl   $0x0,0x0(%rbp)
je     11e7 <main+0x97>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %rbp,%rdx
call   1070 <is_in_bound@plt>
test   %rax,%rax
je     11e7 <main+0x97>
mov    %rbp,%rdi
call   1040 <hop@plt>
mov    %rax,%rbp
add    $0xffffffff,%ebx
cmp    $0xffce,%bx
jne    11a0 <main+0x50>
mov    %rsp,%rdi
mov    %r15d,%esi
mov    %rbp,%rdx
call   1070 <is_in_bound@plt>
mov    $0x32,%r14w
mov    $0x30,%edi
jmp    121e <main+0xce>
mov    %rsp,%rdi
mov    %r15d,%esi
mov    %rbp,%rdx
call   1070 <is_in_bound@plt>
mov    %ebx,%ecx
neg    %ecx
mov    $0x30,%edi
test   %rax,%rax
je     121b <main+0xcb>
mov    $0x32,%r14w
cmp    $0xffce,%bx
je     121e <main+0xce>
xor    %edi,%edi
cmpl   $0x0,0x0(%rbp)
sete   %dil
or     $0x30,%edi
mov    %ecx,%r14d
call   1030 <putchar@plt>
movzwl %r14w,%esi
lea    0xdd2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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