#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 main(void) {
  int i, j;
  const int n = 150;
  int sieve[150] = {};
  for (i = 2; i < n; ++i) {
    for (j = i; j * i <= n; ++j)
      sieve[i * j] = 1;
    if (!sieve[i])
      printf("%i ", i);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x270,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x96,-0x10(%rbp)
lea    -0x270(%rbp),%rdi
xor    %esi,%esi
mov    $0x258,%edx
call   1040 <memset@plt>
movl   $0x2,-0x8(%rbp)
cmpl   $0x96,-0x8(%rbp)
jge    11d0 <main+0xb0>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x8(%rbp),%eax
cmp    $0x96,%eax
jg     119a <main+0x7a>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
cltq
movl   $0x1,-0x270(%rbp,%rax,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1166 <main+0x46>
movslq -0x8(%rbp),%rax
cmpl   $0x0,-0x270(%rbp,%rax,4)
jne    11bd <main+0x9d>
mov    -0x8(%rbp),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c2 <main+0xa2>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1153 <main+0x33>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x270,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x260,%rsp
mov    %rsp,%rdi
mov    $0x258,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    $0x2,%ebx
mov    $0x5,%r12d
mov    $0x4,%r15d
mov    $0x8,%ebp
lea    0xe95(%rip),%r14
jmp    118e <main+0x5e>
nopl   (%rax)
cmpl   $0x0,(%rsp,%rbx,4)
je     11d0 <main+0xa0>
add    $0x1,%rbx
add    %r12d,%r15d
add    $0x2,%r12
add    $0x4,%rbp
cmp    $0x96,%rbx
je     11de <main+0xae>
mov    %ebx,%eax
imul   %ebx,%eax
cmp    $0x96,%eax
ja     1170 <main+0x40>
mov    %r15d,%eax
lea    (%rsp,%rax,4),%rax
mov    %r15d,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movl   $0x1,(%rax)
add    %rbp,%rax
add    %ebx,%ecx
cmp    $0x97,%ecx
jb     11b0 <main+0x80>
jmp    1170 <main+0x40>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1176 <main+0x46>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x260,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%i \00"
define i32 @main() {
%1 = alloca [150 x i32]
%2 = bitcast [150 x i32]* %1 to i8*
br label %3
3: ; preds = %0, %24
%4 = phi i64 [ 5, %0 ], [ %26, %24 ]
%5 = phi i64 [ 2, %0 ], [ %25, %24 ]
%6 = phi i32 [ 4, %0 ], [ %28, %24 ]
%7 = trunc i64 %5 to i32
%8 = mul nsw i32 %7, %7
%9 = icmp ult i32 %8, 151
br i1 %9, label %10, label %18
10: ; preds = %3
%11 = zext i32 %6 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ %11, %10 ], [ %15, %12 ]
%14 = getelementptr inbounds [150 x i32], [150 x i32]* %1, i64 0, i64 %13
store i32 1, i32* %14
%15 = add nuw nsw i64 %13, %5
%16 = trunc i64 %15 to i32
%17 = icmp ult i32 %16, 151
br i1 %17, label %12, label %18
18: ; preds = %12, %3
%19 = getelementptr inbounds [150 x i32], [150 x i32]* %1, i64 0, i64 %5
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %24
24: ; preds = %18, %22
%25 = add nuw nsw i64 %5, 1
%26 = add nuw nsw i64 %4, 2
%27 = trunc i64 %4 to i32
%28 = add i32 %6, %27
%29 = icmp eq i64 %25, 150
br i1 %29, label %30, label %3
30: ; preds = %24
%31 = tail call i32 @putchar(i32 10)
ret i32 0
}