#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 < 1000000; i++) {
    for (j = 2; i * j < 1000000; j++) {
      if (p[i])
        p[i * j] = 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)
cmpl   $0xf4240,-0x3d0914(%rbp)
jge    11ff <main+0xef>
movl   $0x2,-0x3d0918(%rbp)
mov    -0x3d0914(%rbp),%eax
imul   -0x3d0918(%rbp),%eax
cmp    $0xf4240,%eax
jge    11e6 <main+0xd6>
movslq -0x3d0914(%rbp),%rax
cmpl   $0x0,-0x3d0910(%rbp,%rax,4)
je     11cd <main+0xbd>
mov    -0x3d0914(%rbp),%eax
imul   -0x3d0918(%rbp),%eax
cltq
movl   $0x0,-0x3d0910(%rbp,%rax,4)
jmp    11d2 <main+0xc2>
mov    -0x3d0918(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3d0918(%rbp)
jmp    1186 <main+0x76>
jmp    11eb <main+0xdb>
mov    -0x3d0914(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3d0914(%rbp)
jmp    116c <main+0x5c>
movl   $0x0,-0x3d090c(%rbp)
movl   $0x2,-0x3d0914(%rbp)
cmpl   $0xf4240,-0x3d0914(%rbp)
jge    1265 <main+0x155>
movslq -0x3d0914(%rbp),%rax
cmpl   $0x0,-0x3d0910(%rbp,%rax,4)
je     124c <main+0x13c>
mov    -0x3d0914(%rbp),%esi
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1251 <main+0x141>
mov    -0x3d0914(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3d0914(%rbp)
jmp    1213 <main+0x103>
lea    0xd98(%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    $0xf4240,%rdx
je     11fd <main+0xdd>
cmp    $0x7a11f,%rdx
ja     11b0 <main+0x90>
mov    %rax,%rdi
mov    %rbx,%rcx
jmp    11ef <main+0xcf>
nopw   0x0(%rax,%rax,1)
add    %rdx,%rcx
add    %rsi,%rdi
cmp    $0xf4240,%rcx
jae    11b0 <main+0x90>
cmpl   $0x0,(%rsp,%rdx,4)
je     11e0 <main+0xc0>
movl   $0x0,(%rdi)
jmp    11e0 <main+0xc0>
movl   $0x0,0x4(%rsp)
mov    $0x2,%ebx
lea    0xdff(%rip),%r14
jmp    122d <main+0x10d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
cmp    $0xf4240,%rbx
je     1241 <main+0x121>
cmpl   $0x0,(%rsp,%rbx,4)
je     1220 <main+0x100>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1220 <main+0x100>
lea    0xdcc(%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 = %42, %15
%17 = load i32, i32* %3
%18 = icmp slt i32 %17, 1000000
br i1 %18, label %19, label %45
19: ; preds = %16
store i32 2, i32* %4
br label %20
20: ; preds = %38, %19
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = mul nsw i32 %21, %22
%24 = icmp slt i32 %23, 1000000
br i1 %24, label %25, label %41
25: ; preds = %20
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %2, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %37
31: ; preds = %25
%32 = load i32, i32* %3
%33 = load i32, i32* %4
%34 = mul nsw i32 %32, %33
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %2, i64 0, i64 %35
store i32 0, i32* %36
br label %37
37: ; preds = %31, %25
br label %38
38: ; preds = %37
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %20
41: ; preds = %20
br label %42
42: ; preds = %41
%43 = load i32, i32* %3
%44 = add nsw i32 %43, 1
store i32 %44, i32* %3
br label %16
45: ; preds = %16
%46 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %2, i64 0, i64 1
store i32 0, i32* %46
store i32 2, i32* %3
br label %47
47: ; preds = %60, %45
%48 = load i32, i32* %3
%49 = icmp slt i32 %48, 1000000
br i1 %49, label %50, label %63
50: ; preds = %47
%51 = load i32, i32* %3
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %2, i64 0, i64 %52
%54 = load i32, i32* %53
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %50
%57 = load i32, i32* %3
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %57)
br label %59
59: ; preds = %56, %50
br label %60
60: ; preds = %59
%61 = load i32, i32* %3
%62 = add nsw i32 %61, 1
store i32 %62, i32* %3
br label %47
63: ; preds = %47
%64 = 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, %53
%36 = phi i64 [ %54, %53 ], [ 2, %28 ]
%37 = phi i64 [ %55, %53 ], [ 4, %28 ]
%38 = icmp ult i64 %36, 500000
br i1 %38, label %39, label %53
39: ; preds = %35
%40 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %36
br label %41
41: ; preds = %39, %48
%42 = phi i64 [ 2, %39 ], [ %49, %48 ]
%43 = phi i64 [ %37, %39 ], [ %51, %48 ]
%44 = load i32, i32* %40
%45 = icmp eq i32 %44, 0
br i1 %45, label %48, label %46
46: ; preds = %41
%47 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %43
store i32 0, i32* %47
br label %48
48: ; preds = %41, %46
%49 = add nuw nsw i64 %42, 1
%50 = mul nuw nsw i64 %49, %36
%51 = add nuw nsw i64 %43, %36
%52 = icmp ult i64 %50, 1000000
br i1 %52, label %41, label %53
53: ; preds = %48, %35
%54 = add nuw nsw i64 %36, 1
%55 = add nuw nsw i64 %37, 2
%56 = icmp eq i64 %54, 1000000
br i1 %56, label %57, label %35
57: ; preds = %53
%58 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 1
store i32 0, i32* %58
br label %59
59: ; preds = %57, %67
%60 = phi i64 [ 2, %57 ], [ %68, %67 ]
%61 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %60
%62 = load i32, i32* %61
%63 = icmp eq i32 %62, 0
br i1 %63, label %67, label %64
64: ; preds = %59
%65 = trunc i64 %60 to i32
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %65)
br label %67
67: ; preds = %59, %64
%68 = add nuw nsw i64 %60, 1
%69 = icmp eq i64 %68, 1000000
br i1 %69, label %70, label %59
70: ; preds = %67
%71 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret i32 0
}