#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 /*<<< orphan*/ minmax(int *, int, int *, int *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  unsigned short n;
  do
    scanf("%hu", &n);
  while (n <= 0 && n >= 500);
  int arr[n], min, max;
  for (int i = 0; i < n; i++)
    scanf("%d", &arr[i]);
  minmax(arr, (int)n, &min, &max);
  printf("%d", max + min);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x6(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movzwl -0x6(%rbp),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x25(%rbp)
jg     1172 <main+0x42>
movzwl -0x6(%rbp),%eax
cmp    $0x1f4,%eax
setge  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    113f <main+0xf>
movzwl -0x6(%rbp),%edx
mov    %edx,%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %edx,%ecx
lea    0xf(,%rcx,4),%edx
mov    %edx,%ecx
and    $0xfffffff0,%ecx
mov    %ecx,%edx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
movzwl -0x6(%rbp),%ecx
cmp    %ecx,%eax
jge    11ec <main+0xbc>
mov    -0x30(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11b2 <main+0x82>
mov    -0x30(%rbp),%rdi
movzwl -0x6(%rbp),%esi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1050 <minmax@plt>
mov    -0x20(%rbp),%esi
add    -0x1c(%rbp),%esi
lea    0xdf6(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeb8(%rip),%rdi
xor    %r12d,%r12d
lea    -0x2a(%rbp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %rsp,%rbx
movzwl -0x2a(%rbp),%eax
lea    0xf(,%rax,4),%eax
and    $0xfffffff0,%eax
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
cmpw   $0x0,-0x2a(%rbp)
je     11b3 <main+0x83>
mov    %rbx,-0x40(%rbp)
lea    0xe82(%rip),%r15
mov    %r14,%rbx
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
add    $0x1,%r13
movzwl -0x2a(%rbp),%r12d
add    $0x4,%rbx
cmp    %r12,%r13
jb     1190 <main+0x60>
mov    -0x40(%rbp),%rbx
lea    -0x34(%rbp),%rdx
lea    -0x30(%rbp),%rcx
mov    %r14,%rdi
mov    %r12d,%esi
call   1050 <minmax@plt>
mov    -0x34(%rbp),%esi
add    -0x30(%rbp),%esi
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
mov    %rbx,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%hu\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i16
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
br label %8
8: ; preds = %18, %0
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i16* %2)
br label %10
10: ; preds = %8
%11 = load i16, i16* %2
%12 = zext i16 %11 to i32
%13 = icmp sle i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i16, i16* %2
%16 = zext i16 %15 to i32
%17 = icmp sge i32 %16, 500
br label %18
18: ; preds = %14, %10
%19 = phi i1 [ false, %10 ], [ %17, %14 ]
br i1 %19, label %8, label %20
20: ; preds = %18
%21 = load i16, i16* %2
%22 = zext i16 %21 to i64
%23 = call i8* @llvm.stacksave()
store i8* %23, i8** %3
%24 = alloca i32, i64 %22
store i64 %22, i64* %4
store i32 0, i32* %7
br label %25
25: ; preds = %35, %20
%26 = load i32, i32* %7
%27 = load i16, i16* %2
%28 = zext i16 %27 to i32
%29 = icmp slt i32 %26, %28
br i1 %29, label %30, label %38
30: ; preds = %25
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %24, i64 %32
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %33)
br label %35
35: ; preds = %30
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
br label %25
38: ; preds = %25
%39 = load i16, i16* %2
%40 = zext i16 %39 to i32
%41 = call i32 @minmax(i32* %24, i32 %40, i32* %5, i32* %6)
%42 = load i32, i32* %6
%43 = load i32, i32* %5
%44 = add nsw i32 %42, %43
%45 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %44)
store i32 0, i32* %1
%46 = load i8*, i8** %3
%47 = load i32, i32* %1
ret i32 %47
}

LLVM IR (-O2):
@.str = [4 x i8] c"%hu\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i16
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i16* %1 to i8*
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i16* %1)
%6 = load i16, i16* %1
%7 = zext i16 %6 to i64
%8 = call i8* @llvm.stacksave()
%9 = alloca i32, i64 %7
%10 = bitcast i32* %2 to i8*
%11 = bitcast i32* %3 to i8*
%12 = load i16, i16* %1
%13 = icmp eq i16 %12, 0
br i1 %13, label %16, label %23
14: ; preds = %23
%15 = zext i16 %28 to i32
br label %16
16: ; preds = %0, %14
%17 = phi i32 [ %15, %14 ], [ 0, %0 ]
%18 = call i32 @minmax(i32* %9, i32 %17, i32* %2, i32* %3)
%19 = load i32, i32* %3
%20 = load i32, i32* %2
%21 = add nsw i32 %20, %19
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %21)
ret i32 0
23: ; preds = %0, %23
%24 = phi i64 [ %27, %23 ], [ 0, %0 ]
%25 = getelementptr inbounds i32, i32* %9, i64 %24
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %25)
%27 = add nuw nsw i64 %24, 1
%28 = load i16, i16* %1
%29 = zext i16 %28 to i64
%30 = icmp ult i64 %27, %29
br i1 %30, label %23, label %14
}