#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 *);
int main() {
  int arr[500], size, min, max, counter;
  int sum;
  scanf("%d", &size);
  if (size > 0 && size < 500) {
    for (counter = 0; counter < size; counter++) {
      scanf("%d", &arr[counter]);
    }
  }
  minmax(arr, size, &min, &max);
  sum = max + min;
  printf("%d\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x800,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x7e4(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x7e4(%rbp)
jle    11c8 <main+0x98>
cmpl   $0x1f4,-0x7e4(%rbp)
jge    11c8 <main+0x98>
movl   $0x0,-0x7f0(%rbp)
mov    -0x7f0(%rbp),%eax
cmp    -0x7e4(%rbp),%eax
jge    11c3 <main+0x93>
movslq -0x7f0(%rbp),%rax
lea    -0x7e0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe56(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x7f0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7f0(%rbp)
jmp    117c <main+0x4c>
jmp    11c8 <main+0x98>
lea    -0x7e0(%rbp),%rdi
mov    -0x7e4(%rbp),%esi
lea    -0x7e8(%rbp),%rdx
lea    -0x7ec(%rbp),%rcx
call   1050 <minmax@plt>
mov    -0x7ec(%rbp),%eax
add    -0x7e8(%rbp),%eax
mov    %eax,-0x7f4(%rbp)
mov    -0x7f4(%rbp),%esi
lea    0xdfc(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x7e0,%rsp
lea    0xebd(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
lea    -0x1(%rsi),%eax
cmp    $0x1f2,%eax
ja     118d <main+0x5d>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xe97(%rip),%r14
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rsi
add    $0x4,%r15
cmp    %rsi,%rbx
jl     1170 <main+0x40>
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1050 <minmax@plt>
mov    0xc(%rsp),%esi
add    0x8(%rsp),%esi
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7e0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [500 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%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, 0
br i1 %10, label %11, label %28
11: ; preds = %0
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 500
br i1 %13, label %14, label %28
14: ; preds = %11
store i32 0, i32* %6
br label %15
15: ; preds = %24, %14
%16 = load i32, i32* %6
%17 = load i32, i32* %3
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %27
19: ; preds = %15
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [500 x i32], [500 x i32]* %2, i64 0, i64 %21
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %22)
br label %24
24: ; preds = %19
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %15
27: ; preds = %15
br label %28
28: ; preds = %27, %11, %0
%29 = getelementptr inbounds [500 x i32], [500 x i32]* %2, i64 0, i64 0
%30 = load i32, i32* %3
%31 = call i32 @minmax(i32* %29, i32 %30, i32* %4, i32* %5)
%32 = load i32, i32* %5
%33 = load i32, i32* %4
%34 = add nsw i32 %32, %33
store i32 %34, i32* %7
%35 = load i32, i32* %7
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %35)
ret i32 0
}

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