#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);
int /*<<< orphan*/ sieve(int, int *);
main() {
  int i, n = 1000000;
  int v[n];
  sieve(n, v);
  for (i = 0; i < n; i++)
    if (v[i] == 1)
      printf("%d\n", i);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xf4240,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x28(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <sieve@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ac <main+0x8c>
mov    -0x28(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    1199 <main+0x79>
mov    -0x8(%rbp),%esi
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
jmp    119e <main+0x7e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116c <main+0x4c>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x3d0908,%rsp
mov    %rsp,%rsi
mov    $0xf4240,%edi
call   1040 <sieve@plt>
xor    %ebx,%ebx
lea    0xec0(%rip),%r14
jmp    115d <main+0x3d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    $0xf4240,%rbx
je     116f <main+0x4f>
cmpl   $0x1,(%rsp,%rbx,4)
jne    1150 <main+0x30>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
jmp    1150 <main+0x30>
xor    %eax,%eax
add    $0x3d0908,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
store i32 0, i32* %1
store i32 1000000, i32* %3
%6 = load i32, i32* %3
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
store i8* %8, i8** %4
%9 = alloca i32, i64 %7
store i64 %7, i64* %5
%10 = load i32, i32* %3
%11 = call i32 @sieve(i32 %10, i32* %9)
store i32 0, i32* %2
br label %12
12: ; preds = %26, %0
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %29
16: ; preds = %12
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %9, i64 %18
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = load i32, i32* %2
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %22, %16
br label %26
26: ; preds = %25
%27 = load i32, i32* %2
%28 = add nsw i32 %27, 1
store i32 %28, i32* %2
br label %12
29: ; preds = %12
%30 = load i8*, i8** %4
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [1000000 x i32]
%2 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 0
%3 = call i32 @sieve(i32 1000000, i32* %2)
br label %4
4: ; preds = %0, %12
%5 = phi i64 [ 0, %0 ], [ %13, %12 ]
%6 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %5
%7 = load i32, i32* %6
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = trunc i64 %5 to i32
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %4, %9
%13 = add nuw nsw i64 %5, 1
%14 = icmp eq i64 %13, 1000000
br i1 %14, label %15, label %4
15: ; preds = %12
ret i32 0
}