#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 */
scalar_t__ doesSumMidpointExist(int *, int);
int /*<<< orphan*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int sherlockandarray(void) {
  int numTestCases;
  scanf("%d", &numTestCases);
  while (numTestCases--) {
    int arrayLength;
    scanf("%d", &arrayLength);
    int *array = malloc(sizeof(int) * arrayLength);
    for (int i = 0; i < arrayLength; i++) {
      scanf("%d", array + i);
    }
    if (doesSumMidpointExist(array, arrayLength)) {
      printf("YES");
    } else {
      printf("NO");
    }
    printf("\n");
    free(array);
  }
  return 0;
}


x86 assembly (clang, -O0):
<sherlockandarray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xea1(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4(%rbp)
cmp    $0x0,%eax
je     1228 <sherlockandarray+0xd8>
lea    0xe7d(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11db <sherlockandarray+0x8b>
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe38(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a6 <sherlockandarray+0x56>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1070 <doesSumMidpointExist@plt>
cmp    $0x0,%rax
je     1202 <sherlockandarray+0xb2>
lea    0xe0b(%rip),%rdi
call   1040 <printf@plt>
jmp    120e <sherlockandarray+0xbe>
lea    0xdfe(%rip),%rdi
call   1040 <printf@plt>
lea    0xdf5(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
jmp    1168 <sherlockandarray+0x18>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sherlockandarray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe8e(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
subl   $0x1,0x4(%rsp)
jae    1194 <sherlockandarray+0x34>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe65(%rip),%r12
lea    0xe61(%rip),%r14
jmp    11ea <sherlockandarray+0x8a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    %r13d,%esi
call   1080 <doesSumMidpointExist@plt>
test   %rax,%rax
mov    %r14,%rdi
lea    0xe3f(%rip),%rax
cmove  %rax,%rdi
call   1050 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r15,%rdi
call   1030 <free@plt>
subl   $0x1,0x4(%rsp)
jb     1183 <sherlockandarray+0x23>
mov    %r12,%rdi
mov    %rsp,%rsi
call   1070 <scanf@plt>
mov    (%rsp),%r13d
lea    0x0(,%r13,4),%edi
call   1060 <malloc@plt>
mov    %rax,%r15
test   %r13d,%r13d
jle    11b0 <sherlockandarray+0x50>
mov    %r15,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
add    $0x1,%rbp
movslq (%rsp),%r13
add    $0x4,%rbx
cmp    %r13,%rbp
jl     1220 <sherlockandarray+0xc0>
jmp    11b0 <sherlockandarray+0x50>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"YES\00"
@.str.2 = [3 x i8] c"NO\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @sherlockandarray() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
br label %6
6: ; preds = %39, %0
%7 = load i32, i32* %1
%8 = add nsw i32 %7, -1
store i32 %8, i32* %1
%9 = icmp ne i32 %7, 0
br i1 %9, label %10, label %43
10: ; preds = %6
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = mul i64 4, %13
%15 = trunc i64 %14 to i32
%16 = call i32* @malloc(i32 %15)
store i32* %16, i32** %3
store i32 0, i32* %4
br label %17
17: ; preds = %27, %10
%18 = load i32, i32* %4
%19 = load i32, i32* %2
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = load i32*, i32** %3
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %25)
br label %27
27: ; preds = %21
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %17
30: ; preds = %17
%31 = load i32*, i32** %3
%32 = load i32, i32* %2
%33 = call i64 @doesSumMidpointExist(i32* %31, i32 %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %39
37: ; preds = %30
%38 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %39
39: ; preds = %37, %35
%40 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%41 = load i32*, i32** %3
%42 = call i32 @free(i32* %41)
br label %6
43: ; preds = %6
ret i32 0
}

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