#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 /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, int *);
int main() {
  int i, n;
  long votes[100001];
  int win, candidate, max = 0;
  scanf("%d", &n);
  if (n < 1)
    exit(0);
  for (i = 0; i < 100001; i++)
    votes[i] = 0;
  while (scanf("%d", &candidate) != EOF) {
    if (candidate < 1)
      exit(0);
    if (max < ++votes[candidate]) {
      win = candidate;
      max = votes[candidate];
    }
  }
  printf("%d", win);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc3530,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc352c(%rbp)
lea    0xead(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0xc(%rbp)
jge    116d <main+0x3d>
xor    %edi,%edi
call   1050 <exit@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x186a1,-0x8(%rbp)
jge    119f <main+0x6f>
movslq -0x8(%rbp),%rax
movq   $0x0,-0xc3520(%rbp,%rax,8)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1174 <main+0x44>
jmp    11a4 <main+0x74>
lea    0xe55(%rip),%rdi
lea    -0xc3528(%rbp),%rsi
call   1040 <scanf@plt>
mov    0x2e2a(%rip),%rcx
cmp    (%rcx),%rax
je     122c <main+0xfc>
cmpl   $0x1,-0xc3528(%rbp)
jge    11db <main+0xab>
xor    %edi,%edi
call   1050 <exit@plt>
movslq -0xc352c(%rbp),%rax
movslq -0xc3528(%rbp),%rdx
mov    -0xc3520(%rbp,%rdx,8),%rcx
ff
add    $0x1,%rcx
mov    %rcx,-0xc3520(%rbp,%rdx,8)
ff
cmp    %rcx,%rax
jge    1227 <main+0xf7>
mov    -0xc3528(%rbp),%eax
mov    %eax,-0xc3524(%rbp)
movslq -0xc3528(%rbp),%rax
mov    -0xc3520(%rbp,%rax,8),%rax
ff
mov    %eax,-0xc352c(%rbp)
jmp    11a4 <main+0x74>
mov    -0xc3524(%rbp),%esi
lea    0xdc7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xc3530,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xc3520,%rsp
lea    0xeaa(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11f3 <main+0xb3>
lea    0x10(%rsp),%rdi
xor    %ebx,%ebx
mov    $0xc3508,%edx
xor    %esi,%esi
call   1040 <memset@plt>
lea    0xe7b(%rip),%r14
lea    0x8(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    0x2e4c(%rip),%r12
nopl   0x0(%rax)
mov    0x8(%rsp),%eax
test   %eax,%eax
jle    11f3 <main+0xb3>
movslq %ebx,%rbx
mov    0x10(%rsp,%rax,8),%rcx
lea    0x1(%rcx),%rdx
mov    %rdx,0x10(%rsp,%rax,8)
cmp    %rbx,%rcx
cmovge %eax,%ebp
cmovge %edx,%ebx
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
cmp    (%r12),%rax
jne    11a0 <main+0x60>
lea    0xe26(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xc3520,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
call   1060 <exit@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [100001 x i64]
%3 = bitcast [100001 x i64]* %2 to i8*
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %4 to i8*
%7 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 1
br i1 %9, label %14, label %10
10: ; preds = %0
%11 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%12 = load i64, i64* @EOF
%13 = icmp ne i64 %11, %12
br label %16
14: ; preds = %0
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %10, %23
%17 = phi i32 [ %32, %23 ], [ 0, %10 ]
%18 = phi i32 [ %31, %23 ], [ undef, %10 ]
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 1
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = call i32 @exit(i32 0)
unreachable
23: ; preds = %16
%24 = sext i32 %17 to i64
%25 = zext i32 %19 to i64
%26 = getelementptr inbounds [100001 x i64], [100001 x i64]* %2, i64 0, i64 %25
%27 = load i64, i64* %26
%28 = add nsw i64 %27, 1
store i64 %28, i64* %26
%29 = icmp slt i64 %27, %24
%30 = trunc i64 %28 to i32
%31 = select i1 %29, i32 %18, i32 %19
%32 = select i1 %29, i32 %17, i32 %30
%33 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%34 = load i64, i64* @EOF
%35 = icmp eq i64 %33, %34
br i1 %35, label %36, label %16
36: ; preds = %23
%37 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %31)
ret i32 0
}