#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 *, long long);
int main() {
  long long int i, j, num;
  int arr[2000001] = {0};
  for (i = 2; i * i < 2000001; i++) {
    if (arr[i] == 0) {
      for (j = 2; j * i < 2000001; j++)
        arr[j * i] = 1;
    }
  }
  for (i = 2; i < 2000001; i++)
    if (!arr[i])
      printf("%d ", i);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7a1230,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x7a1230(%rbp),%rdi
xor    %esi,%esi
mov    $0x7a1204,%edx
call   1040 <memset@plt>
movq   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%rax
imul   -0x10(%rbp),%rax
cmp    $0x1e8481,%rax
jge    11d1 <main+0xb1>
mov    -0x10(%rbp),%rax
cmpl   $0x0,-0x7a1230(%rbp,%rax,4)
jne    11bb <main+0x9b>
movq   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%rax
imul   -0x10(%rbp),%rax
cmp    $0x1e8481,%rax
jge    11b6 <main+0x96>
mov    -0x18(%rbp),%rax
imul   -0x10(%rbp),%rax
movl   $0x1,-0x7a1230(%rbp,%rax,4)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    117c <main+0x5c>
jmp    11bb <main+0x9b>
jmp    11c0 <main+0xa0>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    114d <main+0x2d>
movq   $0x2,-0x10(%rbp)
cmpq   $0x1e8481,-0x10(%rbp)
jge    121f <main+0xff>
mov    -0x10(%rbp),%rax
cmpl   $0x0,-0x7a1230(%rbp,%rax,4)
jne    1209 <main+0xe9>
mov    -0x10(%rbp),%rsi
lea    0xdfc(%rip),%rdi
call   1030 <printf@plt>
jmp    120e <main+0xee>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11d9 <main+0xb9>
xor    %eax,%eax
add    $0x7a1230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x7a1208,%rsp
mov    %rsp,%rdi
mov    $0x7a1204,%edx
xor    %esi,%esi
call   1040 <memset@plt>
lea    0x10(%rsp),%r8
lea    0x18(%rsp),%r9
mov    $0x2,%edx
mov    $0x8,%esi
mov    $0x4,%r10d
mov    $0xc,%ebx
mov    $0x6,%r11d
mov    $0x3,%ecx
jmp    1190 <main+0x70>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x2,%rdx
add    $0x10,%r8
add    $0x8,%rsi
add    $0x4,%r10
add    $0x10,%r9
add    $0x8,%rbx
add    $0x4,%r11
add    $0x2,%rcx
cmpl   $0x0,(%rsp,%rdx,4)
jne    11b5 <main+0x95>
mov    %r10,%rdi
mov    %r8,%rax
nopl   0x0(%rax)
movl   $0x1,(%rax)
add    %rsi,%rax
add    %rdx,%rdi
cmp    $0x1e8481,%rdi
jb     11a0 <main+0x80>
mov    %rdx,%rax
or     $0x1,%rax
cmp    $0x587,%rax
je     11e7 <main+0xc7>
cmpl   $0x0,(%rsp,%rax,4)
jne    1170 <main+0x50>
mov    %r11,%rdi
mov    %r9,%rax
movl   $0x1,(%rax)
add    %rbx,%rax
add    %rcx,%rdi
cmp    $0x1e8481,%rdi
jb     11d0 <main+0xb0>
jmp    1170 <main+0x50>
mov    $0x2,%ebx
lea    0xe0d(%rip),%r14
jmp    120d <main+0xed>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
cmp    $0x1e8481,%rbx
je     1220 <main+0x100>
cmpl   $0x0,(%rsp,%rbx,4)
jne    1200 <main+0xe0>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
jmp    1200 <main+0xe0>
xor    %eax,%eax
add    $0x7a1208,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca [2000001 x i32]
%2 = bitcast [2000001 x i32]* %1 to i8*
br label %3
3: ; preds = %33, %0
%4 = phi i64 [ 2, %0 ], [ %34, %33 ]
%5 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 %4
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %17
8: ; preds = %3
%9 = shl nuw nsw i64 %4, 1
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ %15, %10 ], [ %9, %8 ]
%12 = phi i64 [ %14, %10 ], [ 2, %8 ]
%13 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 %11
store i32 1, i32* %13
%14 = add nuw nsw i64 %12, 1
%15 = mul nuw nsw i64 %14, %4
%16 = icmp ult i64 %15, 2000001
br i1 %16, label %10, label %17
17: ; preds = %10, %3
%18 = or i64 %4, 1
%19 = icmp eq i64 %18, 1415
br i1 %19, label %35, label %20
20: ; preds = %17
%21 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 %18
%22 = load i32, i32* %21
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %33
24: ; preds = %20
%25 = shl nuw nsw i64 %18, 1
br label %26
26: ; preds = %26, %24
%27 = phi i64 [ %31, %26 ], [ %25, %24 ]
%28 = phi i64 [ %30, %26 ], [ 2, %24 ]
%29 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 %27
store i32 1, i32* %29
%30 = add nuw nsw i64 %28, 1
%31 = mul nuw nsw i64 %30, %18
%32 = icmp ult i64 %31, 2000001
br i1 %32, label %26, label %33
33: ; preds = %26, %20
%34 = add nuw nsw i64 %4, 2
br label %3
35: ; preds = %17, %42
%36 = phi i64 [ %43, %42 ], [ 2, %17 ]
%37 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %36)
br label %42
42: ; preds = %35, %40
%43 = add nuw nsw i64 %36, 1
%44 = icmp eq i64 %43, 2000001
br i1 %44, label %45, label %35
45: ; preds = %42
ret i32 0
}