#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*/ computeAccumulateMin(int *, int *, int);
int getMaxDiffBetwenSeniorAndJunior(int *, int *, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int markArr[100000], accumulateMin[100000], T, numStudent, i;
  scanf("%d", &T);
  while (T) {
    scanf("%d", &numStudent);
    for (i = 0; i < numStudent; i++)
      scanf("%d", &markArr[i]);
    computeAccumulateMin(markArr, accumulateMin, numStudent);
    printf("%d\n",
           getMaxDiffBetwenSeniorAndJunior(markArr, accumulateMin, numStudent));
    T--;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc3520,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    -0xc3514(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0xc3514(%rbp)
je     122a <main+0xea>
lea    0xe87(%rip),%rdi
lea    -0xc3518(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0xc351c(%rbp)
mov    -0xc351c(%rbp),%eax
cmp    -0xc3518(%rbp),%eax
jge    11d6 <main+0x96>
movslq -0xc351c(%rbp),%rax
lea    -0x61a90(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe43(%rip),%rdi
call   1050 <scanf@plt>
mov    -0xc351c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc351c(%rbp)
jmp    118f <main+0x4f>
lea    -0x61a90(%rbp),%rdi
lea    -0xc3510(%rbp),%rsi
mov    -0xc3518(%rbp),%edx
call   1040 <computeAccumulateMin@plt>
lea    -0x61a90(%rbp),%rdi
lea    -0xc3510(%rbp),%rsi
mov    -0xc3518(%rbp),%edx
call   1060 <getMaxDiffBetwenSeniorAndJunior@plt>
mov    %eax,%esi
lea    0xdf2(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc3514(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc3514(%rbp)
jmp    1165 <main+0x25>
xor    %eax,%eax
add    $0xc3520,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc3518,%rsp
lea    0xea8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
je     11ff <main+0xbf>
lea    0xe8c(%rip),%rbx
lea    0x61a90(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xe7b(%rip),%r13
jmp    11bb <main+0x7b>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <computeAccumulateMin@plt>
mov    0x8(%rsp),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <getMaxDiffBetwenSeniorAndJunior@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
addl   $0xffffffff,0xc(%rsp)
je     11ff <main+0xbf>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%edx
test   %edx,%edx
jle    1190 <main+0x50>
mov    %r15,%rbp
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
add    $0x1,%r14
movslq 0x8(%rsp),%rdx
add    $0x4,%rbp
cmp    %rdx,%r14
jl     11e0 <main+0xa0>
jmp    1190 <main+0x50>
xor    %eax,%eax
add    $0xc3518,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100000 x i32]
%3 = alloca [100000 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
br label %8
8: ; preds = %25, %0
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %37
11: ; preds = %8
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
store i32 0, i32* %6
br label %13
13: ; preds = %22, %11
%14 = load i32, i32* %6
%15 = load i32, i32* %5
%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 [100000 x i32], [100000 x i32]* %2, 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 [100000 x i32], [100000 x i32]* %2, i64 0, i64 0
%27 = getelementptr inbounds [100000 x i32], [100000 x i32]* %3, i64 0, i64 0
%28 = load i32, i32* %5
%29 = call i32 @computeAccumulateMin(i32* %26, i32* %27, i32 %28)
%30 = getelementptr inbounds [100000 x i32], [100000 x i32]* %2, i64 0, i64 0
%31 = getelementptr inbounds [100000 x i32], [100000 x i32]* %3, i64 0, i64 0
%32 = load i32, i32* %5
%33 = call i32 @getMaxDiffBetwenSeniorAndJunior(i32* %30, i32* %31, i32 %32)
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %4
%36 = add nsw i32 %35, -1
store i32 %36, i32* %4
br label %8
37: ; preds = %8
ret i32 0
}

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