#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, m, num[1000], query[100], i, j;
  printf("Please input the number of integers:");
  scanf("%d", &n);
  printf("Please input the integers:");
  for (i = 0; i < n; i++)
    scanf("%d", &num[i]);
  printf("Please input the times of query:");
  scanf("%d", &m);
  printf("Please input the integers you want to query:");
  for (i = 0; i < m; i++)
    scanf("%d", &query[i]);
  printf("The result is:\n");
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++)
      if (query[i] == num[j]) {
        if (j == 0)
          printf("%d\n", num[1]);
        else if (j == n - 1)
          printf("%d\n", num[n - 2]);
        else
          printf("%d %d\n", num[j - 1], num[j + 1]);
        break;
      }
    if (j == n)
      printf("NULL\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1150,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xede(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1144(%rbp)
mov    -0x1144(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ac <main+0x8c>
movslq -0x1144(%rbp),%rax
lea    -0xfb0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe92(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x1144(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1144(%rbp)
jmp    1168 <main+0x48>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe64(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1144(%rbp)
mov    -0x1144(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1226 <main+0x106>
movslq -0x1144(%rbp),%rax
lea    -0x1140(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe18(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x1144(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1144(%rbp)
jmp    11e2 <main+0xc2>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1144(%rbp)
mov    -0x1144(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    136f <main+0x24f>
movl   $0x0,-0x1148(%rbp)
mov    -0x1148(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1339 <main+0x219>
movslq -0x1144(%rbp),%rax
mov    -0x1140(%rbp,%rax,4),%eax
movslq -0x1148(%rbp),%rcx
cmp    -0xfb0(%rbp,%rcx,4),%eax
jne    1320 <main+0x200>
cmpl   $0x0,-0x1148(%rbp)
jne    12ae <main+0x18e>
mov    -0xfac(%rbp),%esi
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    131b <main+0x1fb>
mov    -0x1148(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    12e4 <main+0x1c4>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
cltq
mov    -0xfb0(%rbp,%rax,4),%esi
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1316 <main+0x1f6>
mov    -0x1148(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0xfb0(%rbp,%rax,4),%esi
mov    -0x1148(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0xfb0(%rbp,%rax,4),%edx
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    131b <main+0x1fb>
jmp    1339 <main+0x219>
jmp    1325 <main+0x205>
mov    -0x1148(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1148(%rbp)
jmp    1257 <main+0x137>
mov    -0x1148(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1356 <main+0x236>
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    135b <main+0x23b>
mov    -0x1144(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1144(%rbp)
jmp    123e <main+0x11e>
xor    %eax,%eax
add    $0x1150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1148,%rsp
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecf(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11ad <main+0x7d>
lea    0x1a0(%rsp),%rbx
xor    %ebp,%ebp
lea    0xe9f(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbp
movslq 0xc(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     1190 <main+0x60>
lea    0xe8f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe63(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xe91(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0x8(%rsp)
jle    120d <main+0xdd>
lea    0x10(%rsp),%rbx
xor    %ebp,%ebp
lea    0xe36(%rip),%r14
nop
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbp
movslq 0x8(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     11f0 <main+0xc0>
lea    0xe84(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0x8(%rsp)
jle    1337 <main+0x207>
movabs $0xffffffff00000000,%r13
ff ff ff
movabs $0x100000000,%rbx
lea    0xe68(%rip),%r12
xor    %ebp,%ebp
jmp    1262 <main+0x132>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbp
movslq 0x8(%rsp),%rax
cmp    %rax,%rbp
jge    1337 <main+0x207>
movslq 0xc(%rsp),%rax
mov    $0x0,%r14d
test   %rax,%rax
jle    12ee <main+0x1be>
mov    %eax,%edx
mov    0x10(%rsp,%rbp,4),%esi
lea    -0x1(%rax),%r14d
mov    %r13,%rcx
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    0x1a0(%rsp,%r15,4),%esi
je     12c0 <main+0x190>
add    $0x1,%r15
add    %rbx,%rcx
cmp    %r15,%rdx
jne    1290 <main+0x160>
mov    %edx,%r14d
cmp    0xc(%rsp),%r14d
jne    1250 <main+0x120>
jmp    12f9 <main+0x1c9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %r15d,%r15d
je     12d6 <main+0x1a6>
mov    %r14d,%edx
cmp    %r15d,%edx
jne    1306 <main+0x1d6>
mov    0x198(%rsp,%rax,4),%esi
jmp    12e0 <main+0x1b0>
mov    0x1a4(%rsp),%esi
xor    %r14d,%r14d
lea    0xdad(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    0xc(%rsp),%r14d
jne    1250 <main+0x120>
mov    %r12,%rdi
call   1030 <puts@plt>
jmp    1250 <main+0x120>
sar    $0x1e,%rcx
mov    0x1a0(%rsp,%rcx,1),%esi
mov    0x1a4(%rsp,%r15,4),%edx
lea    0xd71(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15d,%r14d
cmp    0xc(%rsp),%r14d
jne    1250 <main+0x120>
jmp    12f9 <main+0x1c9>
xor    %eax,%eax
add    $0x1148,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Please input the number of integers:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"Please input the integers:\00"
@.str.3 = [33 x i8] c"Please input the times of query:\00"
@.str.4 = [45 x i8] c"Please input the integers you want to query:\00"
@.str.5 = [16 x i8] c"The result is:\0A\00"
@.str.6 = [4 x i8] c"%d\0A\00"
@.str.7 = [7 x i8] c"%d %d\0A\00"
@.str.8 = [6 x i8] c"NULL\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1000 x i32]
%5 = alloca [100 x i32]
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %6
br label %11
11: ; preds = %20, %0
%12 = load i32, i32* %6
%13 = load i32, i32* %2
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [1000 x i32], [1000 x i32]* %4, i64 0, i64 %17
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %18)
br label %20
20: ; preds = %15
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %11
23: ; preds = %11
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %6
br label %27
27: ; preds = %36, %23
%28 = load i32, i32* %6
%29 = load i32, i32* %3
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %39
31: ; preds = %27
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %33
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %34)
br label %36
36: ; preds = %31
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %27
39: ; preds = %27
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %6
br label %41
41: ; preds = %104, %39
%42 = load i32, i32* %6
%43 = load i32, i32* %3
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %107
45: ; preds = %41
store i32 0, i32* %7
br label %46
46: ; preds = %94, %45
%47 = load i32, i32* %7
%48 = load i32, i32* %2
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %97
50: ; preds = %46
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %52
%54 = load i32, i32* %53
%55 = load i32, i32* %7
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [1000 x i32], [1000 x i32]* %4, i64 0, i64 %56
%58 = load i32, i32* %57
%59 = icmp eq i32 %54, %58
br i1 %59, label %60, label %93
60: ; preds = %50
%61 = load i32, i32* %7
%62 = icmp eq i32 %61, 0
br i1 %62, label %63, label %67
63: ; preds = %60
%64 = getelementptr inbounds [1000 x i32], [1000 x i32]* %4, i64 0, i64 1
%65 = load i32, i32* %64
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %65)
br label %92
67: ; preds = %60
%68 = load i32, i32* %7
%69 = load i32, i32* %2
%70 = sub nsw i32 %69, 1
%71 = icmp eq i32 %68, %70
br i1 %71, label %72, label %79
72: ; preds = %67
%73 = load i32, i32* %2
%74 = sub nsw i32 %73, 2
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [1000 x i32], [1000 x i32]* %4, i64 0, i64 %75
%77 = load i32, i32* %76
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %77)
br label %91
79: ; preds = %67
%80 = load i32, i32* %7
%81 = sub nsw i32 %80, 1
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [1000 x i32], [1000 x i32]* %4, i64 0, i64 %82
%84 = load i32, i32* %83
%85 = load i32, i32* %7
%86 = add nsw i32 %85, 1
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [1000 x i32], [1000 x i32]* %4, i64 0, i64 %87
%89 = load i32, i32* %88
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 %84, i32 %89)
br label %91
91: ; preds = %79, %72
br label %92
92: ; preds = %91, %63
br label %97
93: ; preds = %50
br label %94
94: ; preds = %93
%95 = load i32, i32* %7
%96 = add nsw i32 %95, 1
store i32 %96, i32* %7
br label %46
97: ; preds = %92, %46
%98 = load i32, i32* %7
%99 = load i32, i32* %2
%100 = icmp eq i32 %98, %99
br i1 %100, label %101, label %103
101: ; preds = %97
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
br label %103
103: ; preds = %101, %97
br label %104
104: ; preds = %103
%105 = load i32, i32* %6
%106 = add nsw i32 %105, 1
store i32 %106, i32* %6
br label %41
107: ; preds = %41
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"Please input the number of integers:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"Please input the integers:\00"
@.str.3 = [33 x i8] c"Please input the times of query:\00"
@.str.4 = [45 x i8] c"Please input the integers you want to query:\00"
@.str.6 = [4 x i8] c"%d\0A\00"
@.str.7 = [7 x i8] c"%d %d\0A\00"
@str = [15 x i8] c"The result is:\00"
@str.9 = [5 x i8] c"NULL\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1000 x i32]
%4 = alloca [100 x i32]
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast [1000 x i32]* %3 to i8*
%8 = bitcast [100 x i32]* %4 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%12 = load i32, i32* %1
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %0, %14
%15 = phi i64 [ %18, %14 ], [ 0, %0 ]
%16 = getelementptr inbounds [1000 x i32], [1000 x i32]* %3, i64 0, i64 %15
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
%18 = add nuw nsw i64 %15, 1
%19 = load i32, i32* %1
%20 = sext i32 %19 to i64
%21 = icmp slt i64 %18, %20
br i1 %21, label %14, label %22
22: ; preds = %14, %0
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
%26 = load i32, i32* %2
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %36
28: ; preds = %22, %28
%29 = phi i64 [ %32, %28 ], [ 0, %22 ]
%30 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %29
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %30)
%32 = add nuw nsw i64 %29, 1
%33 = load i32, i32* %2
%34 = sext i32 %33 to i64
%35 = icmp slt i64 %32, %34
br i1 %35, label %28, label %36
36: ; preds = %28, %22
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%38 = load i32, i32* %2
%39 = icmp sgt i32 %38, 0
br i1 %39, label %40, label %95
40: ; preds = %36
%41 = getelementptr inbounds [1000 x i32], [1000 x i32]* %3, i64 0, i64 1
br label %42
42: ; preds = %40, %90
%43 = phi i64 [ 0, %40 ], [ %91, %90 ]
%44 = load i32, i32* %1
%45 = icmp sgt i32 %44, 0
br i1 %45, label %46, label %84
46: ; preds = %42
%47 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %43
%48 = load i32, i32* %47
%49 = add nsw i32 %44, -1
%50 = zext i32 %44 to i64
br label %51
51: ; preds = %46, %81
%52 = phi i64 [ 0, %46 ], [ %82, %81 ]
%53 = getelementptr inbounds [1000 x i32], [1000 x i32]* %3, i64 0, i64 %52
%54 = load i32, i32* %53
%55 = icmp eq i32 %48, %54
br i1 %55, label %56, label %81
56: ; preds = %51
%57 = trunc i64 %52 to i32
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = load i32, i32* %41
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %60)
br label %84
62: ; preds = %56
%63 = icmp eq i32 %49, %57
br i1 %63, label %64, label %70
64: ; preds = %62
%65 = add nsw i32 %44, -2
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [1000 x i32], [1000 x i32]* %3, i64 0, i64 %66
%68 = load i32, i32* %67
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %68)
br label %84
70: ; preds = %62
%71 = shl i64 %52, 32
%72 = add i64 %71, -4294967296
%73 = ashr exact i64 %72, 32
%74 = getelementptr inbounds [1000 x i32], [1000 x i32]* %3, i64 0, i64 %73
%75 = load i32, i32* %74
%76 = add nuw i64 %52, 1
%77 = and i64 %76, 4294967295
%78 = getelementptr inbounds [1000 x i32], [1000 x i32]* %3, i64 0, i64 %77
%79 = load i32, i32* %78
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 %75, i32 %79)
br label %84
81: ; preds = %51
%82 = add nuw nsw i64 %52, 1
%83 = icmp eq i64 %82, %50
br i1 %83, label %84, label %51
84: ; preds = %81, %42, %59, %70, %64
%85 = phi i32 [ 0, %59 ], [ %57, %70 ], [ %49, %64 ], [ 0, %42 ], [ %44, %81 ]
%86 = load i32, i32* %1
%87 = icmp eq i32 %85, %86
br i1 %87, label %88, label %90
88: ; preds = %84
%89 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.9, i64 0, i64 0))
br label %90
90: ; preds = %84, %88
%91 = add nuw nsw i64 %43, 1
%92 = load i32, i32* %2
%93 = sext i32 %92 to i64
%94 = icmp slt i64 %91, %93
br i1 %94, label %42, label %95
95: ; preds = %90, %36
ret i32 0
}