#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);
scalar_t__ sqrt(int);
int main(void) {
  bool prime[2000000 + 1];
  long n;
  long s;
  prime[0] = false;
  prime[1] = false;
  for (n = 2; n <= 2000000; n++) {
    prime[n] = true;
  }
  for (n = 2; n <= ((long)sqrt(2000000)); n++) {
    if (prime[n]) {
      for (s = 2; s <= (2000000 / n); s++) {
        prime[s * n] = false;
      }
    }
  }
  for (n = 2; n <= 2000000; n++) {
    if (prime[n]) {
      printf("%7ld\n", n);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7a1230,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x7a1210(%rbp)
movl   $0x0,-0x7a120c(%rbp)
movq   $0x2,-0x7a1218(%rbp)
cmpq   $0x1e8480,-0x7a1218(%rbp)
jg     118b <main+0x6b>
mov    -0x7a1218(%rbp),%rax
movl   $0x1,-0x7a1210(%rbp,%rax,4)
mov    -0x7a1218(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x7a1218(%rbp)
jmp    1151 <main+0x31>
movq   $0x2,-0x7a1218(%rbp)
mov    -0x7a1218(%rbp),%rax
mov    %rax,-0x7a1228(%rbp)
mov    $0x1e8480,%edi
call   1040 <sqrt@plt>
mov    %rax,%rcx
mov    -0x7a1228(%rbp),%rax
cmp    %rcx,%rax
jg     1262 <main+0x142>
mov    -0x7a1218(%rbp),%rax
cmpl   $0x0,-0x7a1210(%rbp,%rax,4)
je     1246 <main+0x126>
movq   $0x2,-0x7a1220(%rbp)
mov    -0x7a1220(%rbp),%rax
mov    %rax,-0x7a1230(%rbp)
mov    $0x1e8480,%eax
cqto
idivq  -0x7a1218(%rbp)
mov    %rax,%rcx
mov    -0x7a1230(%rbp),%rax
cmp    %rcx,%rax
jg     1241 <main+0x121>
mov    -0x7a1220(%rbp),%rax
imul   -0x7a1218(%rbp),%rax
ff
movl   $0x0,-0x7a1210(%rbp,%rax,4)
mov    -0x7a1220(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x7a1220(%rbp)
jmp    11e1 <main+0xc1>
jmp    1246 <main+0x126>
jmp    124b <main+0x12b>
mov    -0x7a1218(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x7a1218(%rbp)
jmp    1196 <main+0x76>
movq   $0x2,-0x7a1218(%rbp)
cmpq   $0x1e8480,-0x7a1218(%rbp)
jg     12c2 <main+0x1a2>
mov    -0x7a1218(%rbp),%rax
cmpl   $0x0,-0x7a1210(%rbp,%rax,4)
je     12a6 <main+0x186>
mov    -0x7a1218(%rbp),%rsi
lea    0xd5f(%rip),%rdi
call   1030 <printf@plt>
jmp    12ab <main+0x18b>
mov    -0x7a1218(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x7a1218(%rbp)
jmp    126d <main+0x14d>
xor    %eax,%eax
add    $0x7a1230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7a1218,%rsp
movq   $0x0,0x10(%rsp)
mov    $0x16,%eax
movaps 0xeba(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
movups %xmm0,-0x40(%rsp,%rax,4)
movups %xmm0,-0x30(%rsp,%rax,4)
movups %xmm0,-0x20(%rsp,%rax,4)
movups %xmm0,-0x10(%rsp,%rax,4)
movups %xmm0,(%rsp,%rax,4)
movups %xmm0,0x10(%rsp,%rax,4)
add    $0x18,%rax
cmp    $0x1e848e,%rax
jne    1150 <main+0x30>
movups %xmm0,0x7a11f8(%rsp)
movabs $0x100000001,%rax
mov    %rax,0x7a1208(%rsp)
movl   $0x1,0x7a1210(%rsp)
mov    $0x1e8480,%edi
call   1040 <sqrt@plt>
cmp    $0x2,%rax
jge    11f5 <main+0xd5>
mov    $0x2,%ebx
lea    0xe56(%rip),%r14
jmp    11cd <main+0xad>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    $0x1e8481,%rbx
je     11e1 <main+0xc1>
cmpl   $0x0,0x10(%rsp,%rbx,4)
je     11c0 <main+0xa0>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
jmp    11c0 <main+0xa0>
xor    %eax,%eax
add    $0x7a1218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x2,%ebp
mov    $0x18,%r14d
mov    $0x20,%ebx
mov    $0x28,%r15d
mov    $0x10,%r12d
mov    $0x8,%r13d
jmp    1255 <main+0x135>
nopl   0x0(%rax)
lea    0x1(%rbp),%rax
mov    %rax,0x8(%rsp)
mov    $0x1e8480,%edi
call   1040 <sqrt@plt>
add    $0xc,%r14
add    $0x10,%rbx
add    $0x14,%r15
add    $0x8,%r12
add    $0x4,%r13
cmp    %rax,%rbp
mov    0x8(%rsp),%rbp
jge    11ae <main+0x8e>
cmpl   $0x0,0x10(%rsp,%rbp,4)
je     1220 <main+0x100>
cmp    $0xf4240,%rbp
ja     1220 <main+0x100>
mov    $0x1e8480,%eax
xor    %edx,%edx
div    %ebp
cmp    $0x3,%eax
mov    $0x2,%ecx
cmovb  %ecx,%eax
lea    -0x1(%rax),%rdx
add    $0xfffffffffffffffe,%rax
mov    %edx,%ecx
and    $0x3,%ecx
mov    $0x2,%esi
cmp    $0x3,%rax
jb     12d2 <main+0x1b2>
and    $0xfffffffffffffffc,%rdx
mov    $0x2,%eax
lea    0x10(%rsp),%rdi
nop
movl   $0x0,(%rdi,%r12,1)
movl   $0x0,(%rdi,%r14,1)
movl   $0x0,(%rdi,%rbx,1)
movl   $0x0,(%rdi,%r15,1)
add    %rbx,%rdi
lea    0x4(%rax),%rsi
add    $0x2,%rax
cmp    %rdx,%rax
mov    %rsi,%rax
jne    12a0 <main+0x180>
test   %rcx,%rcx
je     1220 <main+0x100>
imul   %r13,%rsi
lea    (%rsp,%rsi,1),%rax
add    $0x10,%rax
xor    %edx,%edx
nopl   0x0(%rax)
movl   $0x0,(%rax)
add    $0x1,%rdx
add    %r13,%rax
cmp    %rcx,%rdx
jne    12f0 <main+0x1d0>
jmp    1220 <main+0x100>

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

LLVM IR (-O2):
@.str = [6 x i8] c"%7ld\0A\00"
define i32 @main() {
%1 = alloca [2000001 x i32]
%2 = bitcast [2000001 x i32]* %1 to i8*
%3 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 0
store i32 0, i32* %3
%4 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 1
store i32 0, i32* %4
br label %5
5: ; preds = %5, %0
%6 = phi i64 [ 0, %0 ], [ %24, %5 ]
%7 = or i64 %6, 2
%8 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 %7
%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 = getelementptr inbounds i32, i32* %8, i64 4
%11 = bitcast i32* %10 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %11
%12 = add nuw nsw i64 %6, 8
%13 = or i64 %12, 2
%14 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 %13
%15 = bitcast i32* %14 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %15
%16 = getelementptr inbounds i32, i32* %14, i64 4
%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 = add nuw nsw i64 %6, 16
%19 = or i64 %18, 2
%20 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 %19
%21 = bitcast i32* %20 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %21
%22 = getelementptr inbounds i32, i32* %20, i64 4
%23 = bitcast i32* %22 to <4 x i32>*
store <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32>* %23
%24 = add nuw nsw i64 %6, 24
%25 = icmp eq i64 %24, 1999992
br i1 %25, label %26, label %5
26: ; preds = %5
%27 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 1999994
store i32 1, i32* %27
%28 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 1999995
store i32 1, i32* %28
%29 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 1999996
store i32 1, i32* %29
%30 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 1999997
store i32 1, i32* %30
%31 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 1999998
store i32 1, i32* %31
%32 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 1999999
store i32 1, i32* %32
%33 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 2000000
store i32 1, i32* %33
%34 = tail call i64 @sqrt(i32 2000000)
%35 = icmp slt i64 %34, 2
br i1 %35, label %86, label %36
36: ; preds = %26, %82
%37 = phi i64 [ %83, %82 ], [ 2, %26 ]
%38 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = icmp eq i32 %39, 0
%41 = icmp ugt i64 %37, 1000000
%42 = select i1 %40, i1 true, i1 %41
br i1 %42, label %82, label %43
43: ; preds = %36
%44 = trunc i64 %37 to i32
%45 = udiv i32 2000000, %44
%46 = call i32 @llvm.umax.i32(i32 %45, i32 2)
%47 = zext i32 %46 to i64
%48 = add nsw i64 %47, -1
%49 = add nsw i64 %47, -2
%50 = and i64 %48, 3
%51 = icmp ult i64 %49, 3
br i1 %51, label %71, label %52
52: ; preds = %43
%53 = and i64 %48, -4
br label %54
54: ; preds = %54, %52
%55 = phi i64 [ 2, %52 ], [ %68, %54 ]
%56 = phi i64 [ 0, %52 ], [ %69, %54 ]
%57 = mul nuw nsw i64 %55, %37
%58 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 %57
store i32 0, i32* %58
%59 = or i64 %55, 1
%60 = mul nuw nsw i64 %59, %37
%61 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 %60
store i32 0, i32* %61
%62 = add nuw nsw i64 %55, 2
%63 = mul nuw nsw i64 %62, %37
%64 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 %63
store i32 0, i32* %64
%65 = add nuw nsw i64 %55, 3
%66 = mul nuw nsw i64 %65, %37
%67 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 %66
store i32 0, i32* %67
%68 = add nuw nsw i64 %55, 4
%69 = add i64 %56, 4
%70 = icmp eq i64 %69, %53
br i1 %70, label %71, label %54
71: ; preds = %54, %43
%72 = phi i64 [ 2, %43 ], [ %68, %54 ]
%73 = icmp eq i64 %50, 0
br i1 %73, label %82, label %74
74: ; preds = %71, %74
%75 = phi i64 [ %79, %74 ], [ %72, %71 ]
%76 = phi i64 [ %80, %74 ], [ 0, %71 ]
%77 = mul nuw nsw i64 %75, %37
%78 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 %77
store i32 0, i32* %78
%79 = add nuw nsw i64 %75, 1
%80 = add i64 %76, 1
%81 = icmp eq i64 %80, %50
br i1 %81, label %82, label %74
82: ; preds = %71, %74, %36
%83 = add nuw nsw i64 %37, 1
%84 = tail call i64 @sqrt(i32 2000000)
%85 = icmp slt i64 %37, %84
br i1 %85, label %36, label %86
86: ; preds = %82, %26
br label %87
87: ; preds = %86, %94
%88 = phi i64 [ %95, %94 ], [ 2, %86 ]
%89 = getelementptr inbounds [2000001 x i32], [2000001 x i32]* %1, i64 0, i64 %88
%90 = load i32, i32* %89
%91 = icmp eq i32 %90, 0
br i1 %91, label %94, label %92
92: ; preds = %87
%93 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %88)
br label %94
94: ; preds = %87, %92
%95 = add nuw nsw i64 %88, 1
%96 = icmp eq i64 %95, 2000001
br i1 %96, label %97, label %87
97: ; preds = %94
ret i32 0
}