#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*/ exit(int);
int /*<<< orphan*/ free(long *);
long *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int nap;
  long num, c, i;
  long *prime;
  prime = malloc((99999999 / 3) * sizeof(long));
  if (!prime) {
    printf("Memory Allocation Error.");
    exit(1);
  }
  prime[0] = 2;
  prime[1] = 3;
  c = 2;
  for (num = 5; num < 99999999; num = num + 2) {
    nap = 0;
    for (i = 0; i < c; i++) {
      if ((num % prime[i]) == 0) {
        nap = 1;
        break;
      }
      if ((prime[i] * prime[i]) > num) {
        break;
      }
    }
    if (nap != 1) {
      prime[c] = num;
      c++;
      printf("%d \n", num);
    }
  }
  free(prime);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xfe502a8,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1180 <main+0x40>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x28(%rbp),%rax
movq   $0x2,(%rax)
mov    -0x28(%rbp),%rax
movq   $0x3,0x8(%rax)
movq   $0x2,-0x18(%rbp)
movq   $0x5,-0x10(%rbp)
cmpq   $0x5f5e0ff,-0x10(%rbp)
05
jge    1286 <main+0x146>
movl   $0x0,-0x8(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    1238 <main+0xf8>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rsi
cqto
idivq  (%rcx,%rsi,8)
cmp    $0x0,%rdx
jne    11fa <main+0xba>
movl   $0x1,-0x8(%rbp)
jmp    1238 <main+0xf8>
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rdx
imul   (%rcx,%rdx,8),%rax
cmp    -0x10(%rbp),%rax
jle    1222 <main+0xe2>
jmp    1238 <main+0xf8>
jmp    1227 <main+0xe7>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11c4 <main+0x84>
cmpl   $0x1,-0x8(%rbp)
je     1270 <main+0x130>
mov    -0x10(%rbp),%rdx
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1275 <main+0x135>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
jmp    11a7 <main+0x67>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0xfe502a8,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     1208 <main+0xc8>
mov    %rax,%r14
movaps 0xe9b(%rip),%xmm0
movups %xmm0,(%rax)
mov    $0x5,%ebx
mov    $0x2,%r12d
lea    0xeaf(%rip),%r15
jmp    11a5 <main+0x65>
nopl   0x0(%rax)
mov    %rbx,(%r14,%r12,8)
add    $0x1,%r12
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x2(%rbx),%rax
cmp    $0x5f5e0fd,%rbx
mov    %rax,%rbx
jae    11f2 <main+0xb2>
test   %r12,%r12
jle    1180 <main+0x40>
mov    $0x1,%ecx
nop
mov    -0x8(%r14,%rcx,8),%rsi
mov    %rbx,%rax
or     %rsi,%rax
shr    $0x20,%rax
je     11d0 <main+0x90>
mov    %rbx,%rax
cqto
idiv   %rsi
test   %rdx,%rdx
jne    11db <main+0x9b>
jmp    1195 <main+0x55>
mov    %ebx,%eax
xor    %edx,%edx
div    %esi
test   %rdx,%rdx
je     1195 <main+0x55>
imul   %rsi,%rsi
cmp    %rbx,%rsi
ja     1180 <main+0x40>
lea    0x1(%rcx),%rax
cmp    %r12,%rcx
mov    %rax,%rcx
jl     11b0 <main+0x70>
jmp    1180 <main+0x40>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe01(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

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

LLVM IR (-O2):
@.str = [25 x i8] c"Memory Allocation Error.\00"
@.str.1 = [5 x i8] c"%d \0A\00"
define i32 @main() {
%1 = tail call i64* @malloc(i32 266666664)
%2 = icmp eq i64* %1, null
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %0
%7 = bitcast i64* %1 to <2 x i64>*
store <2 x i64> <i64 2, i64 3>, <2 x i64>* %7
br label %8
8: ; preds = %6, %28
%9 = phi i64 [ 2, %6 ], [ %29, %28 ]
%10 = phi i64 [ 5, %6 ], [ %30, %28 ]
%11 = icmp sgt i64 %9, 0
br i1 %11, label %12, label %24
12: ; preds = %8, %18
%13 = phi i64 [ %21, %18 ], [ 0, %8 ]
%14 = getelementptr inbounds i64, i64* %1, i64 %13
%15 = load i64, i64* %14
%16 = srem i64 %10, %15
%17 = icmp eq i64 %16, 0
br i1 %17, label %28, label %18
18: ; preds = %12
%19 = mul nsw i64 %15, %15
%20 = icmp ule i64 %19, %10
%21 = add nuw nsw i64 %13, 1
%22 = icmp slt i64 %21, %9
%23 = select i1 %20, i1 %22, i1 false
br i1 %23, label %12, label %24
24: ; preds = %18, %8
%25 = getelementptr inbounds i64, i64* %1, i64 %9
store i64 %10, i64* %25
%26 = add nsw i64 %9, 1
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %10)
br label %28
28: ; preds = %12, %24
%29 = phi i64 [ %26, %24 ], [ %9, %12 ]
%30 = add nuw nsw i64 %10, 2
%31 = icmp ult i64 %10, 99999997
br i1 %31, label %8, label %32
32: ; preds = %28
%33 = tail call i32 @free(i64* %1)
ret i32 0
}