#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 main() {
  int number_of_primes = 10000;
  int primes[number_of_primes];
  int prime_number_count = 0;
  int i, j, k, divisible;
  for (i = 2; prime_number_count < number_of_primes; ++i) {
    int divisible = 1;
    int k = 0;
    while (k < prime_number_count) {
      if (i % primes[k] == 0) {
        divisible = 0;
        break;
      } else {
        ++k;
      }
    }
    if (divisible != 0) {
      primes[prime_number_count] = i;
      prime_number_count++;
      printf("%i\n", i);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2710,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x2,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f6 <main+0xe6>
movl   $0x1,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11b3 <main+0xa3>
mov    -0x40(%rbp),%rcx
mov    -0x20(%rbp),%eax
movslq -0x34(%rbp),%rsi
cltd
idivl  (%rcx,%rsi,4)
cmp    $0x0,%edx
jne    11a5 <main+0x95>
movl   $0x0,-0x30(%rbp)
jmp    11b3 <main+0xa3>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1175 <main+0x65>
cmpl   $0x0,-0x30(%rbp)
je     11e3 <main+0xd3>
mov    -0x40(%rbp),%rax
mov    -0x20(%rbp),%edx
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe22(%rip),%rdi
call   1030 <printf@plt>
jmp    11e8 <main+0xd8>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115b <main+0x4b>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x9c40,%rsp
mov    $0x2,%ebx
xor    %r15d,%r15d
lea    0xed5(%rip),%r14
jmp    1150 <main+0x40>
nopl   (%rax)
movslq %r15d,%rax
mov    %ebx,(%rsp,%rax,4)
add    $0x1,%r15d
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0x1,%ebx
cmp    $0x2710,%r15d
jge    1175 <main+0x65>
test   %r15d,%r15d
jle    1130 <main+0x20>
mov    %r15d,%ecx
xor    %esi,%esi
nopw   0x0(%rax,%rax,1)
mov    %ebx,%eax
cltd
idivl  (%rsp,%rsi,4)
test   %edx,%edx
je     1144 <main+0x34>
add    $0x1,%rsi
cmp    %rsi,%rcx
jne    1160 <main+0x50>
jmp    1130 <main+0x20>
xor    %eax,%eax
add    $0x9c40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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