#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 */
double DBL_MAX;
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *, double);
scalar_t__ scanf(char *, ...);
int main() {
  int n, i;
  double average, hi_score, lo_score, score;
  while (EOF != scanf("%d", &n)) {
    hi_score = -DBL_MAX;
    lo_score = DBL_MAX;
    average = 0.0;
    i = 0;
    while (i++ < n) {
      scanf("%lf", &score);
      average += score;
      if (score < lo_score)
        lo_score = score;
      if (score > hi_score)
        hi_score = score;
    }
    average -= lo_score + hi_score;
    printf("%.2lf\n", average / (n - 2));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eb2(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
lea    0xebc(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
je     1253 <main+0x133>
mov    0x2e72(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    0x2e4b(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
cmp    -0x8(%rbp),%eax
jge    1217 <main+0xf7>
lea    0xe43(%rip),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsd  -0x30(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11f8 <main+0xd8>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1212 <main+0xf2>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11a5 <main+0x85>
movsd  -0x28(%rbp),%xmm1
addsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
lea    0xdbe(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x2eb3(%rip),%rax
mov    (%rax),%rbx
lea    0xed1(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmp    %rax,%rbx
jne    1161 <main+0x41>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xeab(%rip),%r14
lea    0x20(%rsp),%rbx
lea    0xea3(%rip),%r15
lea    0xe95(%rip),%r12
lea    0x4(%rsp),%r13
jmp    11ce <main+0xae>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xorpd  %xmm0,%xmm0
addsd  %xmm1,%xmm2
subsd  %xmm2,%xmm0
add    $0xfffffffe,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
mov    %r15,%rdi
call   1030 <printf@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%rbp
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmp    %rax,%rbp
je     1150 <main+0x30>
mov    0x2e03(%rip),%rax
movsd  (%rax),%xmm1
movapd %xmm1,%xmm2
xorpd  0xe1b(%rip),%xmm2
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    1190 <main+0x70>
xor    %ebp,%ebp
xorps  %xmm0,%xmm0
movapd %xmm1,%xmm3
movapd %xmm2,%xmm4
nopw   0x0(%rax,%rax,1)
movsd  %xmm3,0x8(%rsp)
movsd  %xmm4,0x10(%rsp)
movsd  %xmm0,0x18(%rsp)
add    $0x1,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x20(%rsp),%xmm2
addsd  %xmm2,%xmm0
movapd %xmm2,%xmm1
minsd  0x8(%rsp),%xmm1
maxsd  0x10(%rsp),%xmm2
mov    0x4(%rsp),%eax
movapd %xmm1,%xmm3
movapd %xmm2,%xmm4
cmp    %eax,%ebp
jl     1200 <main+0xe0>
jmp    1194 <main+0x74>

LLVM IR (-O0):
@EOF = global i64 0
@.str = [3 x i8] c"%d\00"
@DBL_MAX = global double 0.000000e+00
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [7 x i8] c"%.2lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i32 0, i32* %1
br label %8
8: ; preds = %38, %0
%9 = load i64, i64* @EOF
%10 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%11 = icmp ne i64 %9, %10
br i1 %11, label %12, label %50
12: ; preds = %8
%13 = load double, double* @DBL_MAX
%14 = fneg double %13
store double %14, double* %5
%15 = load double, double* @DBL_MAX
store double %15, double* %6
store double 0.000000e+00, double* %4
store i32 0, i32* %3
br label %16
16: ; preds = %37, %12
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
%19 = load i32, i32* %2
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %38
21: ; preds = %16
%22 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %7)
%23 = load double, double* %7
%24 = load double, double* %4
%25 = fadd double %24, %23
store double %25, double* %4
%26 = load double, double* %7
%27 = load double, double* %6
%28 = fcmp olt double %26, %27
br i1 %28, label %29, label %31
29: ; preds = %21
%30 = load double, double* %7
store double %30, double* %6
br label %31
31: ; preds = %29, %21
%32 = load double, double* %7
%33 = load double, double* %5
%34 = fcmp ogt double %32, %33
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = load double, double* %7
store double %36, double* %5
br label %37
37: ; preds = %35, %31
br label %16
38: ; preds = %16
%39 = load double, double* %6
%40 = load double, double* %5
%41 = fadd double %39, %40
%42 = load double, double* %4
%43 = fsub double %42, %41
store double %43, double* %4
%44 = load double, double* %4
%45 = load i32, i32* %2
%46 = sub nsw i32 %45, 2
%47 = sitofp i32 %46 to double
%48 = fdiv double %44, %47
%49 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %48)
br label %8
50: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@EOF = global i64 0
@.str = [3 x i8] c"%d\00"
@DBL_MAX = global double 0.000000e+00
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [7 x i8] c"%.2lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = bitcast i32* %1 to i8*
%4 = bitcast double* %2 to i8*
%5 = load i64, i64* @EOF
%6 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%7 = icmp eq i64 %5, %6
br i1 %7, label %42, label %8
8: ; preds = %0, %28
%9 = load double, double* @DBL_MAX
%10 = fneg double %9
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %28
13: ; preds = %8, %13
%14 = phi double [ %23, %13 ], [ %9, %8 ]
%15 = phi double [ %25, %13 ], [ %10, %8 ]
%16 = phi double [ %21, %13 ], [ 0.000000e+00, %8 ]
%17 = phi i32 [ %18, %13 ], [ 0, %8 ]
%18 = add nuw nsw i32 %17, 1
%19 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%20 = load double, double* %2
%21 = fadd double %16, %20
%22 = fcmp olt double %20, %14
%23 = select i1 %22, double %20, double %14
%24 = fcmp ogt double %20, %15
%25 = select i1 %24, double %20, double %15
%26 = load i32, i32* %1
%27 = icmp slt i32 %18, %26
br i1 %27, label %13, label %28
28: ; preds = %13, %8
%29 = phi double [ 0.000000e+00, %8 ], [ %21, %13 ]
%30 = phi double [ %10, %8 ], [ %25, %13 ]
%31 = phi double [ %9, %8 ], [ %23, %13 ]
%32 = phi i32 [ %11, %8 ], [ %26, %13 ]
%33 = fadd double %30, %31
%34 = fsub double %29, %33
%35 = add nsw i32 %32, -2
%36 = sitofp i32 %35 to double
%37 = fdiv double %34, %36
%38 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %37)
%39 = load i64, i64* @EOF
%40 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%41 = icmp eq i64 %39, %40
br i1 %41, label %42, label %8
42: ; preds = %28, %0
ret i32 0
}