#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, short);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
int main() {
  FILE *f = fopen("INP.TXT", "r");
  char n;
  short a, tmp = -1;
  fscanf(f, "%hhd", &n);
  for (; n; n--) {
    fscanf(f, "%hd", &a);
    tmp = (a > tmp && a % 2 == 0) ? a : tmp;
  }
  fclose(f);
  f = fopen("OUT.TXT", "w");
  fprintf(f, "%hd\n", tmp);
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xeab(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
movw   $0xffff,-0x16(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe93(%rip),%rsi
lea    -0x11(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
cmpb   $0x0,-0x11(%rbp)
je     11ee <main+0xae>
mov    -0x10(%rbp),%rdi
lea    0xe78(%rip),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
movswl -0x14(%rbp),%eax
movswl -0x16(%rbp),%ecx
cmp    %ecx,%eax
jle    11d3 <main+0x93>
movswl -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11d3 <main+0x93>
movswl -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11da <main+0x9a>
movswl -0x16(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %ax,-0x16(%rbp)
mov    -0x11(%rbp),%al
add    $0xff,%al
mov    %al,-0x11(%rbp)
jmp    1182 <main+0x42>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe15(%rip),%rdi
lea    0xe16(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe04(%rip),%rsi
movswl -0x16(%rbp),%edx
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xead(%rip),%rdi
lea    0xeae(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r12
lea    0xea1(%rip),%rsi
lea    0xd(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1040 <fscanf@plt>
cmpb   $0x0,0xd(%rsp)
je     11bd <main+0x7d>
mov    $0xffff,%bx
lea    0xe85(%rip),%r14
lea    0xe(%rsp),%r15
nop
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
movzwl 0xe(%rsp),%eax
test   $0x1,%al
mov    %eax,%ebp
cmovne %ebx,%ebp
cmp    %bx,%ax
cmovle %ebx,%ebp
addb   $0xff,0xd(%rsp)
mov    %ebp,%ebx
jne    1190 <main+0x50>
jmp    11c1 <main+0x81>
mov    $0xffff,%bp
mov    %r12,%rdi
call   1030 <fclose@plt>
lea    0xe43(%rip),%rdi
lea    0xe44(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
movswl %bp,%edx
lea    0xe34(%rip),%rsi
mov    %rax,%rdi
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"INP.TXT\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c"%hhd\00"
@.str.3 = [4 x i8] c"%hd\00"
@.str.4 = [8 x i8] c"OUT.TXT\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [5 x i8] c"%hd\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8
%4 = alloca i16
%5 = alloca i16
store i32 0, i32* %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %2
store i16 -1, i16* %5
%7 = load i32*, i32** %2
%8 = call i32 (i32*, i8*, ...) @fscanf(i32* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %3)
br label %9
9: ; preds = %34, %0
%10 = load i8, i8* %3
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %37
12: ; preds = %9
%13 = load i32*, i32** %2
%14 = call i32 (i32*, i8*, ...) @fscanf(i32* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i16* %4)
%15 = load i16, i16* %4
%16 = sext i16 %15 to i32
%17 = load i16, i16* %5
%18 = sext i16 %17 to i32
%19 = icmp sgt i32 %16, %18
br i1 %19, label %20, label %28
20: ; preds = %12
%21 = load i16, i16* %4
%22 = sext i16 %21 to i32
%23 = srem i32 %22, 2
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load i16, i16* %4
%27 = sext i16 %26 to i32
br label %31
28: ; preds = %20, %12
%29 = load i16, i16* %5
%30 = sext i16 %29 to i32
br label %31
31: ; preds = %28, %25
%32 = phi i32 [ %27, %25 ], [ %30, %28 ]
%33 = trunc i32 %32 to i16
store i16 %33, i16* %5
br label %34
34: ; preds = %31
%35 = load i8, i8* %3
%36 = add i8 %35, -1
store i8 %36, i8* %3
br label %9
37: ; preds = %9
%38 = load i32*, i32** %2
%39 = call i32 @fclose(i32* %38)
%40 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %40, i32** %2
%41 = load i32*, i32** %2
%42 = load i16, i16* %5
%43 = call i32 @fprintf(i32* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i16 signext %42)
%44 = load i32*, i32** %2
%45 = call i32 @fclose(i32* %44)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"INP.TXT\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c"%hhd\00"
@.str.3 = [4 x i8] c"%hd\00"
@.str.4 = [8 x i8] c"OUT.TXT\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [5 x i8] c"%hd\0A\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i16
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = bitcast i16* %2 to i8*
%5 = call i32 (i32*, i8*, ...) @fscanf(i32* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%6 = load i8, i8* %1
%7 = icmp eq i8 %6, 0
br i1 %7, label %20, label %8
8: ; preds = %0, %8
%9 = phi i16 [ %16, %8 ], [ -1, %0 ]
%10 = call i32 (i32*, i8*, ...) @fscanf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i16* %2)
%11 = load i16, i16* %2
%12 = icmp sgt i16 %11, %9
%13 = and i16 %11, 1
%14 = icmp eq i16 %13, 0
%15 = and i1 %12, %14
%16 = select i1 %15, i16 %11, i16 %9
%17 = load i8, i8* %1
%18 = add i8 %17, -1
store i8 %18, i8* %1
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %8
20: ; preds = %8, %0
%21 = phi i16 [ -1, %0 ], [ %16, %8 ]
%22 = call i32 @fclose(i32* %3)
%23 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 @fprintf(i32* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i16 signext %21)
%25 = call i32 @fclose(i32* %23)
ret i32 0
}