#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*/ sieveOfEratosthenes(int, int *);
int main() {
  int n, k;
  n = 100;
  bool primes[n + 1];
  sieveOfEratosthenes(n, primes);
  for (k = 2; k < n; k++) {
    if (primes[k]) {
      printf("%d ", k);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x64,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%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    -0x8(%rbp),%edi
call   1040 <sieveOfEratosthenes@plt>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11af <main+0x8f>
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     119c <main+0x7c>
mov    -0xc(%rbp),%esi
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
jmp    11a1 <main+0x81>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116f <main+0x4f>
movl   $0x0,-0x4(%rbp)
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    $0x198,%rsp
mov    %rsp,%rsi
mov    $0x64,%edi
call   1040 <sieveOfEratosthenes@plt>
mov    $0x2,%ebx
lea    0xebd(%rip),%r14
jmp    115a <main+0x3a>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
cmp    $0x64,%rbx
je     116c <main+0x4c>
cmpl   $0x0,(%rsp,%rbx,4)
je     1150 <main+0x30>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
jmp    1150 <main+0x30>
xor    %eax,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca [101 x i32]
%2 = getelementptr inbounds [101 x i32], [101 x i32]* %1, i64 0, i64 0
%3 = call i32 @sieveOfEratosthenes(i32 100, i32* %2)
br label %4
4: ; preds = %0, %12
%5 = phi i64 [ 2, %0 ], [ %13, %12 ]
%6 = getelementptr inbounds [101 x i32], [101 x i32]* %1, i64 0, i64 %5
%7 = load i32, i32* %6
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
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, 100
br i1 %14, label %15, label %4
15: ; preds = %12
ret i32 0
}