#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++) {
    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)
mov    -0x3d0914(%rbp),%eax
imul   -0x3d0914(%rbp),%eax
cmp    $0xf4240,%eax
jge    1207 <main+0xf7>
movl   $0x2,-0x3d0918(%rbp)
mov    -0x3d0914(%rbp),%eax
imul   -0x3d0918(%rbp),%eax
cmp    $0xf4240,%eax
jge    11ee <main+0xde>
movslq -0x3d0914(%rbp),%rax
cmpl   $0x0,-0x3d0910(%rbp,%rax,4)
je     11d5 <main+0xc5>
mov    -0x3d0914(%rbp),%eax
imul   -0x3d0918(%rbp),%eax
cltq
movl   $0x0,-0x3d0910(%rbp,%rax,4)
jmp    11da <main+0xca>
mov    -0x3d0918(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3d0918(%rbp)
jmp    118e <main+0x7e>
jmp    11f3 <main+0xe3>
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    126d <main+0x15d>
movslq -0x3d0914(%rbp),%rax
cmpl   $0x0,-0x3d0910(%rbp,%rax,4)
je     1254 <main+0x144>
mov    -0x3d0914(%rbp),%esi
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1259 <main+0x149>
mov    -0x3d0914(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3d0914(%rbp)
jmp    121b <main+0x10b>
lea    0xd90(%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     11fd <main+0xdd>
mov    %rax,%rdi
mov    %rbx,%rcx
jmp    11ef <main+0xcf>
cs nopw 0x0(%rax,%rax,1)
nopl   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 = %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
store i32 2, i32* %4
br label %22
22: ; preds = %40, %21
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = mul nsw i32 %23, %24
%26 = icmp slt i32 %25, 1000000
br i1 %26, label %27, label %43
27: ; preds = %22
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %2, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %27
%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, %27
br label %40
40: ; preds = %39
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
br label %22
43: ; preds = %22
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 1
store i32 0, i32* %48
store i32 2, i32* %3
br label %49
49: ; preds = %62, %47
%50 = load i32, i32* %3
%51 = icmp slt i32 %50, 1000000
br i1 %51, label %52, label %65
52: ; preds = %49
%53 = load i32, i32* %3
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %2, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %61
58: ; preds = %52
%59 = load i32, i32* %3
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %59)
br label %61
61: ; preds = %58, %52
br label %62
62: ; preds = %61
%63 = load i32, i32* %3
%64 = add nsw i32 %63, 1
store i32 %64, i32* %3
br label %49
65: ; preds = %49
%66 = 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, %51
%36 = phi i64 [ %52, %51 ], [ 2, %28 ]
%37 = phi i64 [ %53, %51 ], [ 4, %28 ]
%38 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %36
br label %39
39: ; preds = %35, %46
%40 = phi i64 [ 2, %35 ], [ %47, %46 ]
%41 = phi i64 [ %37, %35 ], [ %49, %46 ]
%42 = load i32, i32* %38
%43 = icmp eq i32 %42, 0
br i1 %43, label %46, label %44
44: ; preds = %39
%45 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %41
store i32 0, i32* %45
br label %46
46: ; preds = %39, %44
%47 = add nuw nsw i64 %40, 1
%48 = mul nuw nsw i64 %47, %36
%49 = add nuw nsw i64 %41, %36
%50 = icmp ult i64 %48, 1000000
br i1 %50, label %39, label %51
51: ; preds = %46
%52 = add nuw nsw i64 %36, 1
%53 = add nuw nsw i64 %37, 2
%54 = icmp eq i64 %52, 1000
br i1 %54, label %55, label %35
55: ; preds = %51
%56 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 1
store i32 0, i32* %56
br label %57
57: ; preds = %55, %65
%58 = phi i64 [ 2, %55 ], [ %66, %65 ]
%59 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %58
%60 = load i32, i32* %59
%61 = icmp eq i32 %60, 0
br i1 %61, label %65, label %62
62: ; preds = %57
%63 = trunc i64 %58 to i32
%64 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %63)
br label %65
65: ; preds = %57, %62
%66 = add nuw nsw i64 %58, 1
%67 = icmp eq i64 %66, 1000000
br i1 %67, label %68, label %57
68: ; preds = %65
%69 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret i32 0
}