#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char sieve[1000];
  char *sp;
  int number;
  for (sp = sieve; sp < &sieve[1000];)
    *sp++ = 1;
  for (number = 3;; number += 2) {
    sp = &sieve[0] + (number - 3) / 2;
    if (sp >= &sieve[1000])
      break;
    while (sp += number, sp < &sieve[1000])
      *sp = 0;
  }
  printf("2\n");
  for (number = 3, sp = &sieve[0]; sp < &sieve[1000]; number += 2, sp++) {
    if (*sp)
      printf("%d\n", number);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x3f0(%rbp),%rax
mov    %rax,-0x3f8(%rbp)
mov    -0x3f8(%rbp),%rax
lea    -0x3f0(%rbp),%rcx
add    $0x3e8,%rcx
cmp    %rcx,%rax
jae    116b <main+0x5b>
mov    -0x3f8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x3f8(%rbp)
movb   $0x1,(%rax)
jmp    1130 <main+0x20>
movl   $0x3,-0x3fc(%rbp)
lea    -0x3f0(%rbp),%rax
mov    %rax,-0x408(%rbp)
mov    -0x3fc(%rbp),%eax
sub    $0x3,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x408(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x3f8(%rbp)
mov    -0x3f8(%rbp),%rax
lea    -0x3f0(%rbp),%rcx
add    $0x3e8,%rcx
cmp    %rcx,%rax
jb     11cd <main+0xbd>
jmp    1232 <main+0x122>
jmp    11d2 <main+0xc2>
mov    -0x3fc(%rbp),%ecx
mov    -0x3f8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x3f8(%rbp)
mov    -0x3f8(%rbp),%rax
lea    -0x3f0(%rbp),%rcx
add    $0x3e8,%rcx
cmp    %rcx,%rax
jae    1219 <main+0x109>
mov    -0x3f8(%rbp),%rax
movb   $0x0,(%rax)
jmp    11d2 <main+0xc2>
jmp    121e <main+0x10e>
mov    -0x3fc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x3fc(%rbp)
jmp    1175 <main+0x65>
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x3,-0x3fc(%rbp)
lea    -0x3f0(%rbp),%rax
mov    %rax,-0x3f8(%rbp)
mov    -0x3f8(%rbp),%rax
lea    -0x3f0(%rbp),%rcx
add    $0x3e8,%rcx
cmp    %rcx,%rax
jae    12c5 <main+0x1b5>
mov    -0x3f8(%rbp),%rax
cmpb   $0x0,(%rax)
je     129a <main+0x18a>
mov    -0x3fc(%rbp),%esi
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    129f <main+0x18f>
mov    -0x3fc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x3fc(%rbp)
mov    -0x3f8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x3f8(%rbp)
jmp    1258 <main+0x148>
mov    0x2d14(%rip),%rax
mov    (%rax),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x3e8,%rsp
lea    0x3e8(%rsp),%rbx
lea    0x1(%rsp),%rdx
cmp    %rdx,%rbx
cmova  %rbx,%rdx
mov    %rsp,%r15
sub    %r15,%rdx
mov    %r15,%rdi
mov    $0x1,%esi
call   1050 <memset@plt>
mov    $0x3,%eax
xor    %ecx,%ecx
jmp    1182 <main+0x52>
nopl   (%rax)
lea    0x4(%rax),%rdx
shr    %rcx
cmp    $0x7cf,%rax
mov    %rdx,%rax
jae    11cd <main+0x9d>
add    %rsp,%rcx
cs nopw 0x0(%rax,%rax,1)
nop
add    %rax,%rcx
cmp    %rbx,%rcx
jae    11a0 <main+0x70>
movb   $0x0,(%rcx)
jmp    1190 <main+0x60>
nopl   (%rax)
lea    0x2(%rax),%rcx
mov    %rax,%rdx
shr    %rdx
add    %rsp,%rdx
add    %rax,%rdx
add    $0x2,%rdx
cmp    %rbx,%rdx
jae    1170 <main+0x40>
nopl   0x0(%rax)
movb   $0x0,(%rdx)
add    %rcx,%rdx
cmp    %rbx,%rdx
jb     11c0 <main+0x90>
jmp    1170 <main+0x40>
lea    0xe30(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%ebp
lea    0xe1b(%rip),%r14
jmp    11fc <main+0xcc>
nopw   0x0(%rax,%rax,1)
add    $0x2,%ebp
add    $0x1,%r15
cmp    %rbx,%r15
jae    1210 <main+0xe0>
cmpb   $0x0,(%r15)
je     11f0 <main+0xc0>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11f0 <main+0xc0>
mov    0x2dc9(%rip),%rax
mov    (%rax),%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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