#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*/ findNearest(int *, int, int, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int t;
  int *a;
  int n, c;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    a = (int *)malloc(n * sizeof(int));
    int i;
    for (i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    int k;
    scanf("%d", &c);
    scanf("%d", &k);
    findNearest(a, n, k, c);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     11f9 <main+0xc9>
lea    0xe96(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c2 <main+0x92>
mov    -0x10(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe51(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118d <main+0x5d>
lea    0xe37(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe27(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1040 <findNearest@plt>
jmp    114f <main+0x1f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebb(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
subl   $0x1,0xc(%rsp)
jae    1167 <main+0x37>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe92(%rip),%rbx
lea    0x14(%rsp),%r15
lea    0x10(%rsp),%r12
jmp    11b1 <main+0x81>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0x14(%rsp),%ecx
mov    %r13,%rdi
call   1040 <findNearest@plt>
subl   $0x1,0xc(%rsp)
jb     1156 <main+0x26>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%edi
shl    $0x2,%edi
call   1030 <malloc@plt>
mov    %rax,%r13
cmpl   $0x0,0x8(%rsp)
jle    1180 <main+0x50>
mov    %r13,%rbp
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
add    $0x1,%r14
movslq 0x8(%rsp),%rax
add    $0x4,%rbp
cmp    %rax,%r14
jl     11e0 <main+0xb0>
jmp    1180 <main+0x50>

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

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