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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x800,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x7e4(%rbp)
movl   $0x0,-0x7e8(%rbp)
movl   $0x0,-0x7ec(%rbp)
movl   $0x0,-0x7f0(%rbp)
movl   $0x0,-0x7f4(%rbp)
cmpl   $0x1f4,-0x7f4(%rbp)
jge    11aa <main+0x7a>
movslq -0x7f4(%rbp),%rax
movl   $0x0,-0x7e0(%rbp,%rax,4)
mov    -0x7f4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7f4(%rbp)
jmp    1174 <main+0x44>
jmp    11af <main+0x7f>
lea    0xe4a(%rip),%rdi
lea    -0x7e4(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x1,-0x7e4(%rbp)
mov    %al,-0x7f5(%rbp)
jl     11ea <main+0xba>
cmpl   $0x1f4,-0x7e4(%rbp)
setg   %al
mov    %al,-0x7f5(%rbp)
mov    -0x7f5(%rbp),%al
test   $0x1,%al
jne    11af <main+0x7f>
jmp    11fd <main+0xcd>
movslq -0x7f0(%rbp),%rax
lea    -0x7e0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xde7(%rip),%rdi
call   1040 <scanf@plt>
cmp    $0x0,%rax
je     1237 <main+0x107>
mov    -0x7f0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7f0(%rbp)
jmp    123c <main+0x10c>
mov    -0x7f0(%rbp),%eax
cmp    -0x7e4(%rbp),%eax
jl     11fd <main+0xcd>
lea    -0x7e0(%rbp),%rdi
mov    -0x7e4(%rbp),%esi
lea    -0x7e8(%rbp),%rdx
lea    -0x7ec(%rbp),%rcx
call   1050 <minmax@plt>
mov    -0x7e8(%rbp),%esi
add    -0x7ec(%rbp),%esi
lea    0xd7f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x7e0,%rsp
movl   $0x0,0x4(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x7d0,%edx
xor    %esi,%esi
call   1040 <memset@plt>
lea    0xe85(%rip),%r14
lea    0x4(%rsp),%rbx
mov    $0xfffffe0b,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
add    %ebp,%eax
cmp    $0xfffffe0c,%eax
jb     1190 <main+0x50>
xor    %ebp,%ebp
lea    0xe4f(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%eax
lea    (%rsp,%rax,4),%rsi
add    $0x10,%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
mov    0x4(%rsp),%esi
cmp    %esi,%ebp
jl     11c0 <main+0x80>
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    0xdfc(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x7e0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\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
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %15, %0
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 500
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = load i32, i32* %7
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [500 x i32], [500 x i32]* %2, i64 0, i64 %13
store i32 0, i32* %14
br label %15
15: ; preds = %11
%16 = load i32, i32* %7
%17 = add nsw i32 %16, 1
store i32 %17, i32* %7
br label %8
18: ; preds = %8
br label %19
19: ; preds = %27, %18
%20 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
br label %21
21: ; preds = %19
%22 = load i32, i32* %3
%23 = icmp slt i32 %22, 1
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = load i32, i32* %3
%26 = icmp sgt i32 %25, 500
br label %27
27: ; preds = %24, %21
%28 = phi i1 [ true, %21 ], [ %26, %24 ]
br i1 %28, label %19, label %29
29: ; preds = %27
br label %30
30: ; preds = %40, %29
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [500 x i32], [500 x i32]* %2, i64 0, i64 %32
%34 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %30
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %39
39: ; preds = %36, %30
br label %40
40: ; preds = %39
%41 = load i32, i32* %6
%42 = load i32, i32* %3
%43 = icmp slt i32 %41, %42
br i1 %43, label %30, label %44
44: ; preds = %40
%45 = getelementptr inbounds [500 x i32], [500 x i32]* %2, i64 0, i64 0
%46 = load i32, i32* %3
%47 = call i32 @minmax(i32* %45, i32 %46, i32* %4, i32* %5)
%48 = load i32, i32* %4
%49 = load i32, i32* %5
%50 = add nsw i32 %48, %49
%51 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %50)
ret i32 0
}

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