#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, int);
int main() {
  int list[10001] = {};
  int n, i, j;
  list[0] = 2;
  for (n = 3, i = 1; i < 10001; n++) {
    for (j = 0; j < i; j++) {
      if (!(n % list[j])) {
        break;
      }
    }
    if (j == i) {
      list[i] = n;
      i++;
    }
  }
  printf("The prime number %d is %d\n\n", 10001, list[10001 - 1]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9c60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x9c50(%rbp),%rdi
xor    %esi,%esi
mov    $0x9c44,%edx
call   1040 <memset@plt>
movl   $0x2,-0x9c50(%rbp)
movl   $0x3,-0x9c54(%rbp)
movl   $0x1,-0x9c58(%rbp)
cmpl   $0x2711,-0x9c58(%rbp)
jge    1219 <main+0xf9>
movl   $0x0,-0x9c5c(%rbp)
mov    -0x9c5c(%rbp),%eax
cmp    -0x9c58(%rbp),%eax
jge    11cb <main+0xab>
mov    -0x9c54(%rbp),%eax
movslq -0x9c5c(%rbp),%rcx
cltd
idivl  -0x9c50(%rbp,%rcx,4)
cmp    $0x0,%edx
jne    11b2 <main+0x92>
jmp    11cb <main+0xab>
jmp    11b7 <main+0x97>
mov    -0x9c5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c5c(%rbp)
jmp    117d <main+0x5d>
mov    -0x9c5c(%rbp),%eax
cmp    -0x9c58(%rbp),%eax
jne    1200 <main+0xe0>
mov    -0x9c54(%rbp),%ecx
movslq -0x9c58(%rbp),%rax
mov    %ecx,-0x9c50(%rbp,%rax,4)
mov    -0x9c58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c58(%rbp)
jmp    1205 <main+0xe5>
mov    -0x9c54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c54(%rbp)
jmp    1163 <main+0x43>
mov    -0x10(%rbp),%edx
lea    0xddd(%rip),%rdi
mov    $0x2711,%esi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x9c60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x9c48,%rsp
mov    %rsp,%rdi
mov    $0x9c44,%edx
xor    %esi,%esi
call   1040 <memset@plt>
movl   $0x2,(%rsp)
mov    $0x3,%ecx
mov    $0x1,%r8d
jmp    1166 <main+0x46>
nopw   0x0(%rax,%rax,1)
movslq %r8d,%rax
mov    %ecx,(%rsp,%rax,4)
add    $0x1,%r8d
add    $0x1,%ecx
cmp    $0x2711,%r8d
jge    11a7 <main+0x87>
mov    $0x0,%edi
test   %r8d,%r8d
jle    11a0 <main+0x80>
mov    %r8d,%esi
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ecx,%eax
cltd
idivl  (%rsp,%rdi,4)
test   %edx,%edx
je     11a0 <main+0x80>
add    $0x1,%rdi
cmp    %rdi,%rsi
jne    1180 <main+0x60>
jmp    1150 <main+0x30>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    %r8d,%edi
je     1150 <main+0x30>
jmp    115a <main+0x3a>
mov    0x9c40(%rsp),%edx
lea    0xe4b(%rip),%rdi
mov    $0x2711,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x9c48,%rsp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"The prime number %d is %d\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10001 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [10001 x i32]* %2 to i8*
%7 = getelementptr inbounds [10001 x i32], [10001 x i32]* %2, i64 0, i64 0
store i32 2, i32* %7
store i32 3, i32* %3
store i32 1, i32* %4
br label %8
8: ; preds = %41, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 10001
br i1 %10, label %11, label %44
11: ; preds = %8
store i32 0, i32* %5
br label %12
12: ; preds = %26, %11
%13 = load i32, i32* %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %29
16: ; preds = %12
%17 = load i32, i32* %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [10001 x i32], [10001 x i32]* %2, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = srem i32 %17, %21
%23 = icmp ne i32 %22, 0
br i1 %23, label %25, label %24
24: ; preds = %16
br label %29
25: ; preds = %16
br label %26
26: ; preds = %25
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %12
29: ; preds = %24, %12
%30 = load i32, i32* %5
%31 = load i32, i32* %4
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %40
33: ; preds = %29
%34 = load i32, i32* %3
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [10001 x i32], [10001 x i32]* %2, i64 0, i64 %36
store i32 %34, i32* %37
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %40
40: ; preds = %33, %29
br label %41
41: ; preds = %40
%42 = load i32, i32* %3
%43 = add nsw i32 %42, 1
store i32 %43, i32* %3
br label %8
44: ; preds = %8
%45 = getelementptr inbounds [10001 x i32], [10001 x i32]* %2, i64 0, i64 10000
%46 = load i32, i32* %45
%47 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 10001, i32 %46)
%48 = load i32, i32* %1
ret i32 %48
}

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