#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 = i; 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    1209 <main+0xf9>
movslq -0x3d0914(%rbp),%rax
cmpl   $0x0,-0x3d0910(%rbp,%rax,4)
je     11f0 <main+0xe0>
mov    -0x3d0914(%rbp),%eax
mov    %eax,-0x3d0918(%rbp)
mov    -0x3d0914(%rbp),%eax
imul   -0x3d0918(%rbp),%eax
cmp    $0xf4240,%eax
jge    11eb <main+0xdb>
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    11a5 <main+0x95>
jmp    11f0 <main+0xe0>
jmp    11f5 <main+0xe5>
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    1279 <main+0x169>
movslq -0x3d0914(%rbp),%rax
cmpl   $0x0,-0x3d0910(%rbp,%rax,4)
je     1260 <main+0x150>
mov    -0x3d0914(%rbp),%esi
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1265 <main+0x155>
mov    -0x3d0914(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3d0914(%rbp)
jmp    1227 <main+0x117>
lea    0xd84(%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)
mov    $0x2,%eax
mov    $0x4,%r9d
mov    $0x8,%edx
mov    $0x10,%r8d
mov    $0x9,%r10d
mov    $0x3,%ebx
mov    $0xc,%esi
jmp    11e1 <main+0xc1>
nopw   0x0(%rax,%rax,1)
add    $0x2,%rax
add    %esi,%r9d
add    $0x8,%rsi
add    $0x8,%rdx
add    %r8d,%r10d
add    $0x8,%r8d
add    $0x2,%ebx
cmp    $0x3e8,%rax
je     1248 <main+0x128>
cmpl   $0x0,(%rsp,%rax,4)
je     1213 <main+0xf3>
mov    %r9d,%ecx
lea    (%rsp,%rcx,4),%rcx
mov    %r9d,%edi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movl   $0x0,(%rcx)
add    %rdx,%rcx
add    %eax,%edi
cmp    $0xf4240,%edi
jb     1200 <main+0xe0>
lea    0x0(,%rax,4),%rcx
or     $0x4,%rcx
cmpl   $0x0,(%rsp,%rcx,1)
je     11c0 <main+0xa0>
mov    %r10d,%ecx
lea    (%rsp,%rcx,4),%rcx
mov    %r10d,%edi
nop
movl   $0x0,(%rcx)
add    %ebx,%edi
add    %rsi,%rcx
cmp    $0xf4240,%edi
jb     1230 <main+0x110>
jmp    11c0 <main+0xa0>
movq   $0x0,(%rsp)
mov    $0x2,%ebx
lea    0xdb4(%rip),%r14
jmp    126d <main+0x14d>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    $0xf4240,%rbx
je     1281 <main+0x161>
cmpl   $0x0,(%rsp,%rbx,4)
je     1260 <main+0x140>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1260 <main+0x140>
lea    0xd8c(%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 = %45, %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 %48
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 %44
27: ; preds = %21
%28 = load i32, i32* %3
store i32 %28, i32* %4
br label %29
29: ; preds = %40, %27
%30 = load i32, i32* %3
%31 = load i32, i32* %4
%32 = mul nsw i32 %30, %31
%33 = icmp slt i32 %32, 1000000
br i1 %33, label %34, label %43
34: ; preds = %29
%35 = load i32, i32* %3
%36 = load i32, i32* %4
%37 = mul nsw i32 %35, %36
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %2, i64 0, i64 %38
store i32 0, i32* %39
br label %40
40: ; preds = %34
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
br label %29
43: ; preds = %29
br label %44
44: ; preds = %43, %21
br label %45
45: ; preds = %44
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 1
store i32 %47, i32* %3
br label %16
48: ; preds = %16
%49 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %2, i64 0, i64 0
store i32 0, i32* %49
%50 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %2, i64 0, i64 1
store i32 0, i32* %50
store i32 2, i32* %3
br label %51
51: ; preds = %64, %48
%52 = load i32, i32* %3
%53 = icmp slt i32 %52, 1000000
br i1 %53, label %54, label %67
54: ; preds = %51
%55 = load i32, i32* %3
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %2, i64 0, i64 %56
%58 = load i32, i32* %57
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %54
%61 = load i32, i32* %3
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %61)
br label %63
63: ; preds = %60, %54
br label %64
64: ; preds = %63
%65 = load i32, i32* %3
%66 = add nsw i32 %65, 1
store i32 %66, i32* %3
br label %51
67: ; preds = %51
%68 = 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 = %65, %28
%36 = phi i64 [ 5, %28 ], [ %67, %65 ]
%37 = phi i64 [ 2, %28 ], [ %66, %65 ]
%38 = phi i32 [ 4, %28 ], [ %70, %65 ]
%39 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %37
%40 = load i32, i32* %39
%41 = icmp eq i32 %40, 0
br i1 %41, label %50, label %42
42: ; preds = %35
%43 = zext i32 %38 to i64
br label %44
44: ; preds = %42, %44
%45 = phi i64 [ %43, %42 ], [ %47, %44 ]
%46 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %45
store i32 0, i32* %46
%47 = add nuw nsw i64 %45, %37
%48 = trunc i64 %47 to i32
%49 = icmp ult i32 %48, 1000000
br i1 %49, label %44, label %50
50: ; preds = %44, %35
%51 = or i64 %37, 1
%52 = trunc i64 %36 to i32
%53 = add i32 %38, %52
%54 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %51
%55 = load i32, i32* %54
%56 = icmp eq i32 %55, 0
br i1 %56, label %65, label %57
57: ; preds = %50
%58 = zext i32 %53 to i64
br label %59
59: ; preds = %59, %57
%60 = phi i64 [ %58, %57 ], [ %62, %59 ]
%61 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %60
store i32 0, i32* %61
%62 = add nuw nsw i64 %60, %51
%63 = trunc i64 %62 to i32
%64 = icmp ult i32 %63, 1000000
br i1 %64, label %59, label %65
65: ; preds = %59, %50
%66 = add nuw nsw i64 %37, 2
%67 = add nuw nsw i64 %36, 4
%68 = trunc i64 %36 to i32
%69 = add i32 %68, 2
%70 = add i32 %53, %69
%71 = icmp eq i64 %66, 1000
br i1 %71, label %72, label %35
72: ; preds = %65
%73 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 0
store i32 0, i32* %73
%74 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 1
store i32 0, i32* %74
br label %75
75: ; preds = %72, %83
%76 = phi i64 [ 2, %72 ], [ %84, %83 ]
%77 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %76
%78 = load i32, i32* %77
%79 = icmp eq i32 %78, 0
br i1 %79, label %83, label %80
80: ; preds = %75
%81 = trunc i64 %76 to i32
%82 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %81)
br label %83
83: ; preds = %75, %80
%84 = add nuw nsw i64 %76, 1
%85 = icmp eq i64 %84, 1000000
br i1 %85, label %86, label %75
86: ; preds = %83
%87 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret i32 0
}