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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7e0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1030 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    %eax,-0x8(%rbp)
movslq -0xc(%rbp),%rax
lea    -0x7e0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe99(%rip),%rdi
call   1030 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    114e <main+0x2e>
movslq -0x8(%rbp),%rax
mov    -0x7e0(%rbp,%rax,4),%eax
mov    %eax,0x2ea4(%rip)
movslq -0x8(%rbp),%rax
mov    -0x7e0(%rbp,%rax,4),%eax
mov    %eax,0x2e97(%rip)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11ea <main+0xca>
movslq -0xc(%rbp),%rax
lea    -0x7e0(%rbp),%rdi
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%esi
lea    0x2e64(%rip),%rdx
lea    0x2e61(%rip),%rcx
call   1040 <minmax@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a8 <main+0x88>
xor    %eax,%eax
add    $0x7e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x7e8,%rsp
lea    0xecc(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <scanf@plt>
movslq 0xc(%rsp),%r15
lea    -0x1(%r15),%ebp
mov    %ebp,0xc(%rsp)
mov    %ebp,%eax
cltq
lea    (%rsp,%rax,4),%rsi
add    $0x10,%rsi
mov    %rbx,%rdi
call   1030 <scanf@plt>
mov    0xc(%rsp),%ecx
lea    -0x1(%rcx),%eax
mov    %eax,0xc(%rsp)
test   %ecx,%ecx
jg     1150 <main+0x30>
mov    0xc(%rsp,%r15,4),%eax
mov    %eax,0x2eb8(%rip)
mov    %eax,0x2eb6(%rip)
movl   $0x0,0xc(%rsp)
test   %r15d,%r15d
jle    11c7 <main+0xa7>
xor    %eax,%eax
lea    0x2e9c(%rip),%r14
lea    0x2e99(%rip),%rbx
nop
cltq
lea    (%rsp,%rax,4),%rdi
add    $0x10,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1040 <minmax@plt>
mov    0xc(%rsp),%eax
add    $0x1,%eax
mov    %eax,0xc(%rsp)
cmp    %r15d,%eax
jl     11a0 <main+0x80>
xor    %eax,%eax
add    $0x7e8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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