#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*/ isPrime(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a[15000];
  a[0] = 0;
  a[1] = 2;
  a[2] = 3;
  a[3] = 5;
  a[4] = 7;
  a[5] = 11;
  int n = 13;
  for (int i = 6; i <= 15000; i++) {
    while (!isPrime(n)) {
      n += 2;
    }
    a[i] = n;
    n += 2;
  }
  for (int i = 0; i < 21; i++) {
    printf(" %d", a[i]);
  }
  printf(" %d ", a[15000]);
  printf("\n");
  int x = 0;
  scanf("%d", &x);
  for (int i = 0; i < x; i++) {
    int k;
    scanf("%d", &k);
    printf("%d\n", a[k]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xea90,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xea70(%rbp)
movl   $0x2,-0xea6c(%rbp)
movl   $0x3,-0xea68(%rbp)
movl   $0x5,-0xea64(%rbp)
movl   $0x7,-0xea60(%rbp)
movl   $0xb,-0xea5c(%rbp)
movl   $0xd,-0xea74(%rbp)
movl   $0x6,-0xea78(%rbp)
cmpl   $0x3a98,-0xea78(%rbp)
jg     1212 <main+0xe2>
jmp    11a7 <main+0x77>
mov    -0xea74(%rbp),%edi
call   1040 <isPrime@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11c7 <main+0x97>
jmp    11db <main+0xab>
mov    -0xea74(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xea74(%rbp)
jmp    11a7 <main+0x77>
mov    -0xea74(%rbp),%ecx
movslq -0xea78(%rbp),%rax
mov    %ecx,-0xea70(%rbp,%rax,4)
mov    -0xea74(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xea74(%rbp)
mov    -0xea78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xea78(%rbp)
jmp    1192 <main+0x62>
movl   $0x0,-0xea7c(%rbp)
cmpl   $0x15,-0xea7c(%rbp)
jge    1259 <main+0x129>
movslq -0xea7c(%rbp),%rax
mov    -0xea70(%rbp,%rax,4),%esi
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xea7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xea7c(%rbp)
jmp    121c <main+0xec>
mov    -0x10(%rbp),%esi
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xea80(%rbp)
lea    0xd78(%rip),%rdi
lea    -0xea80(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0xea84(%rbp)
mov    -0xea84(%rbp),%eax
cmp    -0xea80(%rbp),%eax
jge    12f4 <main+0x1c4>
lea    0xd49(%rip),%rdi
lea    -0xea88(%rbp),%rsi
call   1050 <scanf@plt>
movslq -0xea88(%rbp),%rax
mov    -0xea70(%rbp,%rax,4),%esi
lea    0xd30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xea84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xea84(%rbp)
jmp    129f <main+0x16f>
xor    %eax,%eax
add    $0xea90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xea78,%rsp
movaps 0xeac(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0xb00000007,%rax
mov    %rax,0x20(%rsp)
mov    $0xd,%ebx
mov    $0x6,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%edi
call   1050 <isPrime@plt>
add    $0x2,%ebx
test   %eax,%eax
je     1180 <main+0x40>
lea    -0x2(%rbx),%eax
mov    %eax,0x10(%rsp,%r14,4)
add    $0x1,%r14
cmp    $0x3a99,%r14
jne    1180 <main+0x40>
lea    0xe66(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x30(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x34(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x38(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x3c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x40(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x44(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x48(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x50(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x54(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x58(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x5c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x60(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xea70(%rsp),%esi
lea    0xd38(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,0x8(%rsp)
lea    0xd15(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    1357 <main+0x217>
lea    0xcfd(%rip),%r14
lea    0xc(%rsp),%r15
lea    0xcf9(%rip),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
movslq 0xc(%rsp),%rax
mov    0x10(%rsp,%rax,4),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    0x8(%rsp),%ebp
jl     1330 <main+0x1f0>
xor    %eax,%eax
add    $0xea78,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c" %d\00"
@.str.1 = [5 x i8] c" %d \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [15000 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = getelementptr inbounds [15000 x i32], [15000 x i32]* %2, i64 0, i64 0
store i32 0, i32* %9
%10 = getelementptr inbounds [15000 x i32], [15000 x i32]* %2, i64 0, i64 1
store i32 2, i32* %10
%11 = getelementptr inbounds [15000 x i32], [15000 x i32]* %2, i64 0, i64 2
store i32 3, i32* %11
%12 = getelementptr inbounds [15000 x i32], [15000 x i32]* %2, i64 0, i64 3
store i32 5, i32* %12
%13 = getelementptr inbounds [15000 x i32], [15000 x i32]* %2, i64 0, i64 4
store i32 7, i32* %13
%14 = getelementptr inbounds [15000 x i32], [15000 x i32]* %2, i64 0, i64 5
store i32 11, i32* %14
store i32 13, i32* %3
store i32 6, i32* %4
br label %15
15: ; preds = %34, %0
%16 = load i32, i32* %4
%17 = icmp sle i32 %16, 15000
br i1 %17, label %18, label %37
18: ; preds = %15
br label %19
19: ; preds = %24, %18
%20 = load i32, i32* %3
%21 = call i32 @isPrime(i32 %20)
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 2
store i32 %26, i32* %3
br label %19
27: ; preds = %19
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [15000 x i32], [15000 x i32]* %2, i64 0, i64 %30
store i32 %28, i32* %31
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 2
store i32 %33, i32* %3
br label %34
34: ; preds = %27
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %15
37: ; preds = %15
store i32 0, i32* %5
br label %38
38: ; preds = %47, %37
%39 = load i32, i32* %5
%40 = icmp slt i32 %39, 21
br i1 %40, label %41, label %50
41: ; preds = %38
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [15000 x i32], [15000 x i32]* %2, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %41
%48 = load i32, i32* %5
%49 = add nsw i32 %48, 1
store i32 %49, i32* %5
br label %38
50: ; preds = %38
%51 = getelementptr inbounds [15000 x i32], [15000 x i32]* %2, i64 0, i64 15000
%52 = load i32, i32* %51
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %52)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %6
%55 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
store i32 0, i32* %7
br label %56
56: ; preds = %67, %50
%57 = load i32, i32* %7
%58 = load i32, i32* %6
%59 = icmp slt i32 %57, %58
br i1 %59, label %60, label %70
60: ; preds = %56
%61 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %8)
%62 = load i32, i32* %8
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [15000 x i32], [15000 x i32]* %2, i64 0, i64 %63
%65 = load i32, i32* %64
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %65)
br label %67
67: ; preds = %60
%68 = load i32, i32* %7
%69 = add nsw i32 %68, 1
store i32 %69, i32* %7
br label %56
70: ; preds = %56
ret i32 0
}

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