#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 counter = 0, array[500], min, max, elem = 0;
  do {
    scanf("%d", &elem);
  } while (elem < 0);
  for (; counter < elem; counter++) {
    scanf("%d", &array[counter]);
  }
  minmax(array, counter, &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,-0x7ec(%rbp)
lea    0xea6(%rip),%rdi
lea    -0x7ec(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x7ec(%rbp)
jl     1153 <main+0x23>
jmp    1178 <main+0x48>
mov    -0x8(%rbp),%eax
cmp    -0x7ec(%rbp),%eax
jge    11b3 <main+0x83>
movslq -0x8(%rbp),%rax
lea    -0x7e0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe60(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1178 <main+0x48>
lea    -0x7e0(%rbp),%rdi
mov    -0x8(%rbp),%esi
lea    -0x7e4(%rbp),%rdx
lea    -0x7e8(%rbp),%rcx
call   1050 <minmax@plt>
mov    -0x7e4(%rbp),%esi
add    -0x7e8(%rbp),%esi
lea    0xe1d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%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)
lea    0xeb5(%rip),%r14
lea    0x4(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
js     1150 <main+0x20>
je     119f <main+0x6f>
lea    0x10(%rsp),%rbx
xor    %r14d,%r14d
lea    0xe8c(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
add    $0x1,%r14
movslq 0x4(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%r14
jl     1180 <main+0x50>
jmp    11a2 <main+0x72>
xor    %r14d,%r14d
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %r14d,%esi
call   1050 <minmax@plt>
mov    0x8(%rsp),%esi
add    0xc(%rsp),%esi
lea    0xe38(%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"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [500 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %6
br label %7
7: ; preds = %9, %0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
br label %9
9: ; preds = %7
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 0
br i1 %11, label %7, label %12
12: ; preds = %9
br label %13
13: ; preds = %22, %12
%14 = load i32, i32* %2
%15 = load i32, i32* %6
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = load i32, i32* %2
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [500 x i32], [500 x i32]* %3, 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* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
br label %13
25: ; preds = %13
%26 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 0
%27 = load i32, i32* %2
%28 = call i32 @minmax(i32* %26, i32 %27, i32* %4, i32* %5)
%29 = load i32, i32* %4
%30 = load i32, i32* %5
%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)
ret i32 0
}

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