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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0x7e0(%rbp),%rdi
xor    %esi,%esi
mov    $0x7d0,%edx
call   1040 <memset@plt>
lea    0xe7f(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    11a0 <main+0x60>
movl   $0x29a,-0x4(%rbp)
jmp    121e <main+0xde>
movl   $0x0,-0x7e4(%rbp)
mov    -0x7e4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ee <main+0xae>
movslq -0x7e4(%rbp),%rax
lea    -0x7e0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe2b(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x7e4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7e4(%rbp)
jmp    11aa <main+0x6a>
lea    -0x7e0(%rbp),%rdi
mov    -0x8(%rbp),%esi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1060 <minmax@plt>
mov    -0xc(%rbp),%esi
add    -0x10(%rbp),%esi
lea    0xdee(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x7f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x7e0,%rsp
movl   $0x0,0x4(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0x10(%rsp),%r15
mov    $0x7d0,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
lea    0xe81(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
je     11e9 <main+0xa9>
jle    11bd <main+0x7d>
xor    %ebx,%ebx
lea    0xe64(%rip),%r14
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rsi
add    $0x4,%r15
cmp    %rsi,%rbx
jl     11a0 <main+0x60>
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1060 <minmax@plt>
mov    0x8(%rsp),%esi
add    0xc(%rsp),%esi
lea    0xe20(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
jmp    11ee <main+0xae>
mov    $0x29a,%eax
add    $0x7e0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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