#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 main() {
  int p[1000000];
  int i, j;
  for (i = 2; i < 1000000; i++) {
    p[i] = 1;
  }
  for (i = 2; i * i < 1000000; i++) {
    if (p[i]) {
      for (j = 2; i * j < 1000000; j++) {
        p[i * j] = 0;
      }
    }
  }
  p[0] = 0;
  p[1] = 0;
  for (i = 2; i < 1000000; i++) {
    if (p[i])
      printf("%d ", i);
  }
  printf("\b\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3d0920,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x3d0914(%rbp)
cmpl   $0xf4240,-0x3d0914(%rbp)
jge    1162 <main+0x52>
movslq -0x3d0914(%rbp),%rax
movl   $0x1,-0x3d0910(%rbp,%rax,4)
mov    -0x3d0914(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3d0914(%rbp)
jmp    112c <main+0x1c>
movl   $0x2,-0x3d0914(%rbp)
mov    -0x3d0914(%rbp),%eax
imul   -0x3d0914(%rbp),%eax
cmp    $0xf4240,%eax
jge    1207 <main+0xf7>
movslq -0x3d0914(%rbp),%rax
cmpl   $0x0,-0x3d0910(%rbp,%rax,4)
je     11ee <main+0xde>
movl   $0x2,-0x3d0918(%rbp)
mov    -0x3d0914(%rbp),%eax
imul   -0x3d0918(%rbp),%eax
cmp    $0xf4240,%eax
jge    11e9 <main+0xd9>
mov    -0x3d0914(%rbp),%eax
imul   -0x3d0918(%rbp),%eax
cltq
movl   $0x0,-0x3d0910(%rbp,%rax,4)
mov    -0x3d0918(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3d0918(%rbp)
jmp    11a3 <main+0x93>
jmp    11ee <main+0xde>
jmp    11f3 <main+0xe3>
mov    -0x3d0914(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3d0914(%rbp)
jmp    116c <main+0x5c>
movl   $0x0,-0x3d0910(%rbp)
movl   $0x0,-0x3d090c(%rbp)
movl   $0x2,-0x3d0914(%rbp)
cmpl   $0xf4240,-0x3d0914(%rbp)
jge    1277 <main+0x167>
movslq -0x3d0914(%rbp),%rax
cmpl   $0x0,-0x3d0910(%rbp,%rax,4)
je     125e <main+0x14e>
mov    -0x3d0914(%rbp),%esi
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1263 <main+0x153>
mov    -0x3d0914(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3d0914(%rbp)
jmp    1225 <main+0x115>
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x3d0920,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x3d0908,%rsp
mov    $0x1e,%eax
movaps 0xeca(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
movups %xmm0,-0x70(%rsp,%rax,4)
movups %xmm0,-0x60(%rsp,%rax,4)
movups %xmm0,-0x50(%rsp,%rax,4)
movups %xmm0,-0x40(%rsp,%rax,4)
movups %xmm0,-0x30(%rsp,%rax,4)
movups %xmm0,-0x20(%rsp,%rax,4)
cmp    $0xf423e,%rax
je     1175 <main+0x55>
movups %xmm0,-0x10(%rsp,%rax,4)
movups %xmm0,(%rsp,%rax,4)
add    $0x20,%rax
jmp    1140 <main+0x20>
movups %xmm0,0x3d08e8(%rsp)
movabs $0x100000001,%rax
mov    %rax,0x3d08f8(%rsp)
lea    0x10(%rsp),%rax
mov    $0x4,%ebx
mov    $0x2,%edx
mov    $0x8,%esi
jmp    11c9 <main+0xa9>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rdx
add    $0x2,%rbx
add    $0x8,%rax
add    $0x4,%rsi
cmp    $0x3e8,%rdx
je     11f7 <main+0xd7>
cmpl   $0x0,(%rsp,%rdx,4)
je     11b0 <main+0x90>
mov    %rax,%rdi
mov    %rbx,%rcx
cs nopw 0x0(%rax,%rax,1)
nop
movl   $0x0,(%rdi)
add    %rdx,%rcx
add    %rsi,%rdi
cmp    $0xf4240,%rcx
jb     11e0 <main+0xc0>
jmp    11b0 <main+0x90>
movq   $0x0,(%rsp)
mov    $0x2,%ebx
lea    0xe05(%rip),%r14
jmp    121d <main+0xfd>
nopl   (%rax)
add    $0x1,%rbx
cmp    $0xf4240,%rbx
je     1231 <main+0x111>
cmpl   $0x0,(%rsp,%rbx,4)
je     1210 <main+0xf0>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1210 <main+0xf0>
lea    0xddc(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x3d0908,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
@str = [2 x i8] c"\08\00"
define i32 @main() {
%1 = alloca [1000000 x i32]
%2 = bitcast [1000000 x i32]* %1 to i8*
br label %3
3: ; preds = %21, %0
%4 = phi i64 [ 0, %0 ], [ %27, %21 ]
%5 = or i64 %4, 2
%6 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %5
%7 = bitcast i32* %6 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %7
%8 = getelementptr inbounds i32, i32* %6, i64 4
%9 = bitcast i32* %8 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %9
%10 = or i64 %4, 10
%11 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %10
%12 = bitcast i32* %11 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %12
%13 = getelementptr inbounds i32, i32* %11, i64 4
%14 = bitcast i32* %13 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %14
%15 = or i64 %4, 18
%16 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %15
%17 = bitcast i32* %16 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %17
%18 = getelementptr inbounds i32, i32* %16, i64 4
%19 = bitcast i32* %18 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %19
%20 = icmp eq i64 %4, 999968
br i1 %20, label %28, label %21
21: ; preds = %3
%22 = or i64 %4, 26
%23 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %22
%24 = bitcast i32* %23 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %24
%25 = getelementptr inbounds i32, i32* %23, i64 4
%26 = bitcast i32* %25 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %26
%27 = add nuw nsw i64 %4, 32
br label %3
28: ; preds = %3
%29 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 999994
store i32 1, i32* %29
%30 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 999995
store i32 1, i32* %30
%31 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 999996
store i32 1, i32* %31
%32 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 999997
store i32 1, i32* %32
%33 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 999998
store i32 1, i32* %33
%34 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 999999
store i32 1, i32* %34
br label %35
35: ; preds = %28, %49
%36 = phi i64 [ %50, %49 ], [ 2, %28 ]
%37 = phi i64 [ %51, %49 ], [ 4, %28 ]
%38 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %36
%39 = load i32, i32* %38
%40 = icmp eq i32 %39, 0
br i1 %40, label %49, label %41
41: ; preds = %35, %41
%42 = phi i64 [ %45, %41 ], [ 2, %35 ]
%43 = phi i64 [ %47, %41 ], [ %37, %35 ]
%44 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %43
store i32 0, i32* %44
%45 = add nuw nsw i64 %42, 1
%46 = mul nuw nsw i64 %45, %36
%47 = add nuw nsw i64 %43, %36
%48 = icmp ult i64 %46, 1000000
br i1 %48, label %41, label %49
49: ; preds = %41, %35
%50 = add nuw nsw i64 %36, 1
%51 = add nuw nsw i64 %37, 2
%52 = icmp eq i64 %50, 1000
br i1 %52, label %53, label %35
53: ; preds = %49
%54 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 0
store i32 0, i32* %54
%55 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 1
store i32 0, i32* %55
br label %56
56: ; preds = %53, %64
%57 = phi i64 [ 2, %53 ], [ %65, %64 ]
%58 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %57
%59 = load i32, i32* %58
%60 = icmp eq i32 %59, 0
br i1 %60, label %64, label %61
61: ; preds = %56
%62 = trunc i64 %57 to i32
%63 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %62)
br label %64
64: ; preds = %56, %61
%65 = add nuw nsw i64 %57, 1
%66 = icmp eq i64 %65, 1000000
br i1 %66, label %67, label %56
67: ; preds = %64
%68 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret i32 0
}