#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*/ calculateFirstNPrimes(int, int *);
int /*<<< orphan*/ printf(char *, int);
int readArgs(int *, int *);
int main(int argc, char *argv[]) {
  int n, maxIndex, loop;
  int indexes[15001];
  int primes[15001];
  n = readArgs(indexes, &maxIndex);
  calculateFirstNPrimes(maxIndex, primes);
  for (loop = 0; loop < n; loop++) {
    printf("%d\n", primes[indexes[loop]]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d4f0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0xea80(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <readArgs@plt>
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x1d4f0(%rbp),%rsi
call   1040 <calculateFirstNPrimes@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ab <main+0x7b>
movslq -0x1c(%rbp),%rax
movslq -0xea80(%rbp,%rax,4),%rax
ff
mov    -0x1d4f0(%rbp,%rax,4),%esi
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1172 <main+0x42>
xor    %eax,%eax
add    $0x1d4f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1d4f0,%rsp
lea    0xea80(%rsp),%rdi
lea    0xc(%rsp),%rsi
call   1050 <readArgs@plt>
mov    %eax,%ebx
mov    0xc(%rsp),%edi
lea    0x10(%rsp),%rsi
call   1040 <calculateFirstNPrimes@plt>
test   %ebx,%ebx
jle    118d <main+0x5d>
mov    %ebx,%r15d
xor    %ebx,%ebx
lea    0xe92(%rip),%r14
xchg   %ax,%ax
movslq 0xea80(%rsp,%rbx,4),%rax
mov    0x10(%rsp,%rax,4),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1170 <main+0x40>
xor    %eax,%eax
add    $0x1d4f0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [15001 x i32]
%5 = alloca [15001 x i32]
%6 = bitcast i32* %3 to i8*
%7 = bitcast [15001 x i32]* %4 to i8*
%8 = bitcast [15001 x i32]* %5 to i8*
%9 = getelementptr inbounds [15001 x i32], [15001 x i32]* %4, i64 0, i64 0
%10 = call i32 @readArgs(i32* %9, i32* %3)
%11 = load i32, i32* %3
%12 = getelementptr inbounds [15001 x i32], [15001 x i32]* %5, i64 0, i64 0
%13 = call i32 @calculateFirstNPrimes(i32 %11, i32* %12)
%14 = icmp sgt i32 %10, 0
br i1 %14, label %15, label %27
15: ; preds = %2
%16 = zext i32 %10 to i64
br label %17
17: ; preds = %15, %17
%18 = phi i64 [ 0, %15 ], [ %25, %17 ]
%19 = getelementptr inbounds [15001 x i32], [15001 x i32]* %4, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [15001 x i32], [15001 x i32]* %5, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = add nuw nsw i64 %18, 1
%26 = icmp eq i64 %25, %16
br i1 %26, label %27, label %17
27: ; preds = %17, %2
ret i32 0
}