#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 get_rudolph_number(int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int barn[200] = {0};
  int deer_count;
  int counter = 0;
  int rudolph_index;
  scanf("%d", &deer_count);
  if (deer_count > 200) {
    printf("deer count can't be more than 200\n");
    return -1;
  } else if (!(deer_count % 2)) {
    printf("deer count must be odd\n");
  }
  for (; counter < deer_count; counter++) {
    int current_deer;
    scanf("%d", &current_deer);
    if (current_deer < 1 || current_deer > 100) {
      printf("Invalid deer number\n");
    }
    barn[counter] = current_deer;
  }
  rudolph_index = get_rudolph_number(barn);
  printf("%d", rudolph_index);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x340,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x330(%rbp),%rdi
xor    %esi,%esi
mov    $0x320,%edx
call   1050 <memset@plt>
movl   $0x0,-0x338(%rbp)
lea    0xe8a(%rip),%rdi
lea    -0x334(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0xc8,-0x334(%rbp)
jle    11ac <main+0x6c>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    127d <main+0x13d>
mov    -0x334(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11d1 <main+0x91>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11d6 <main+0x96>
jmp    11db <main+0x9b>
mov    -0x338(%rbp),%eax
cmp    -0x334(%rbp),%eax
jge    1250 <main+0x110>
lea    0xe0c(%rip),%rdi
lea    -0x340(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x1,-0x340(%rbp)
jl     121a <main+0xda>
cmpl   $0x64,-0x340(%rbp)
jle    1228 <main+0xe8>
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x340(%rbp),%ecx
movslq -0x338(%rbp),%rax
mov    %ecx,-0x330(%rbp,%rax,4)
mov    -0x338(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x338(%rbp)
jmp    11db <main+0x9b>
lea    -0x330(%rbp),%rdi
call   1030 <get_rudolph_number@plt>
mov    %eax,-0x33c(%rbp)
mov    -0x33c(%rbp),%esi
lea    0xd91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x340,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x338,%rsp
lea    0x10(%rsp),%rdi
mov    $0x320,%edx
xor    %esi,%esi
call   1060 <memset@plt>
lea    0xe8a(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x8(%rsp),%eax
cmp    $0xc9,%eax
jl     11a1 <main+0x51>
lea    0xe9c(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebx
jmp    1223 <main+0xd3>
test   $0x1,%al
jne    11b5 <main+0x65>
lea    0xe57(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%rsp),%eax
test   %eax,%eax
jle    1207 <main+0xb7>
xor    %ebx,%ebx
lea    0xe3e(%rip),%r14
lea    0xc(%rsp),%r12
lea    0xe4c(%rip),%r15
jmp    11e2 <main+0x92>
mov    %eax,0x10(%rsp,%rbx,4)
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
cmp    %rax,%rbx
jge    1207 <main+0xb7>
mov    %r14,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%eax
lea    -0x65(%rax),%ecx
cmp    $0xffffff9b,%ecx
ja     11d0 <main+0x80>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%eax
jmp    11d0 <main+0x80>
lea    0x10(%rsp),%rdi
call   1030 <get_rudolph_number@plt>
lea    0xde8(%rip),%rdi
xor    %ebx,%ebx
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%eax
add    $0x338,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [35 x i8] c"deer count can't be more than 200\0A\00"
@.str.2 = [24 x i8] c"deer count must be odd\0A\00"
@.str.3 = [21 x i8] c"Invalid deer number\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [200 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [200 x i32]* %2 to i8*
store i32 0, i32* %4
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 200
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %47
13: ; preds = %0
%14 = load i32, i32* %3
%15 = srem i32 %14, 2
%16 = icmp ne i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %17, %13
br label %20
20: ; preds = %19
br label %21
21: ; preds = %39, %20
%22 = load i32, i32* %4
%23 = load i32, i32* %3
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %42
25: ; preds = %21
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%27 = load i32, i32* %6
%28 = icmp slt i32 %27, 1
br i1 %28, label %32, label %29
29: ; preds = %25
%30 = load i32, i32* %6
%31 = icmp sgt i32 %30, 100
br i1 %31, label %32, label %34
32: ; preds = %29, %25
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %32, %29
%35 = load i32, i32* %6
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [200 x i32], [200 x i32]* %2, i64 0, i64 %37
store i32 %35, i32* %38
br label %39
39: ; preds = %34
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %21
42: ; preds = %21
%43 = getelementptr inbounds [200 x i32], [200 x i32]* %2, i64 0, i64 0
%44 = call i32 @get_rudolph_number(i32* %43)
store i32 %44, i32* %5
%45 = load i32, i32* %5
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %45)
store i32 0, i32* %1
br label %47
47: ; preds = %42, %11
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@str = [23 x i8] c"deer count must be odd\00"
@str.4 = [20 x i8] c"Invalid deer number\00"
@str.5 = [34 x i8] c"deer count can't be more than 200\00"
define i32 @main() {
%1 = alloca [200 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [200 x i32]* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 200
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.5, i64 0, i64 0))
br label %42
11: ; preds = %0
%12 = and i32 %7, 1
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%16 = load i32, i32* %2
br label %17
17: ; preds = %11, %14
%18 = phi i32 [ %7, %11 ], [ %16, %14 ]
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %38
20: ; preds = %17
%21 = bitcast i32* %3 to i8*
br label %22
22: ; preds = %20, %31
%23 = phi i64 [ 0, %20 ], [ %34, %31 ]
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%25 = load i32, i32* %3
%26 = add i32 %25, -101
%27 = icmp ult i32 %26, -100
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.4, i64 0, i64 0))
%30 = load i32, i32* %3
br label %31
31: ; preds = %22, %28
%32 = phi i32 [ %25, %22 ], [ %30, %28 ]
%33 = getelementptr inbounds [200 x i32], [200 x i32]* %1, i64 0, i64 %23
store i32 %32, i32* %33
%34 = add nuw nsw i64 %23, 1
%35 = load i32, i32* %2
%36 = sext i32 %35 to i64
%37 = icmp slt i64 %34, %36
br i1 %37, label %22, label %38
38: ; preds = %31, %17
%39 = getelementptr inbounds [200 x i32], [200 x i32]* %1, i64 0, i64 0
%40 = call i32 @get_rudolph_number(i32* %39)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %38, %9
%43 = phi i32 [ -1, %9 ], [ 0, %38 ]
ret i32 %43
}