#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__ EOF;
scalar_t__ PrimeNum(int);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, int *);
int main() {
  int num[10000];
  int index, i, n;
  index = 0;
  for (i = 2;; i++) {
    if (index <= 10000) {
      if (PrimeNum(i)) {
        num[index] = i;
        index++;
      }
    } else
      break;
  }
  while (scanf("%d", &n) != EOF) {
    printf("%d\n", num[n - 1]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9c60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x9c54(%rbp)
movl   $0x2,-0x9c58(%rbp)
cmpl   $0x2710,-0x9c54(%rbp)
jg     11a3 <main+0x73>
mov    -0x9c58(%rbp),%edi
call   1050 <PrimeNum@plt>
cmp    $0x0,%rax
je     119e <main+0x6e>
mov    -0x9c58(%rbp),%ecx
movslq -0x9c54(%rbp),%rax
mov    %ecx,-0x9c50(%rbp,%rax,4)
mov    -0x9c54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c54(%rbp)
jmp    11a8 <main+0x78>
jmp    11c1 <main+0x91>
jmp    11ad <main+0x7d>
mov    -0x9c58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c58(%rbp)
jmp    1156 <main+0x26>
jmp    11c6 <main+0x96>
lea    0xe33(%rip),%rdi
lea    -0x9c5c(%rbp),%rsi
call   1040 <scanf@plt>
mov    0x2e08(%rip),%rcx
cmp    (%rcx),%rax
je     120c <main+0xdc>
mov    -0x9c5c(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x9c50(%rbp,%rax,4),%esi
lea    0xe01(%rip),%rdi
call   1030 <printf@plt>
jmp    11c6 <main+0x96>
xor    %eax,%eax
add    $0x9c60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x9c58,%rsp
xor    %r14d,%r14d
mov    $0x2,%ebx
jmp    115c <main+0x2c>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    $0x2711,%r14d
jge    1176 <main+0x46>
mov    %ebx,%edi
call   1050 <PrimeNum@plt>
test   %rax,%rax
je     1150 <main+0x20>
movslq %r14d,%r14
mov    %ebx,0x10(%rsp,%r14,4)
add    $0x1,%r14d
jmp    1150 <main+0x20>
lea    0xe83(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x2e5a(%rip),%r12
cmp    (%r12),%rax
je     11d2 <main+0xa2>
lea    0xe68(%rip),%r14
lea    0xe5e(%rip),%r15
lea    0xc(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
movslq 0xc(%rsp),%rax
mov    0xc(%rsp,%rax,4),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
cmp    (%r12),%rax
jne    11b0 <main+0x80>
xor    %eax,%eax
add    $0x9c58,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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