#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);
void findPrime() {
  int a[3000] = {0};
  int n = 3000;
  int i, j = 0;
  int k = 1;
  a[0] = 1;
  for (i = 1; i < n; i++) {
    for (j = i; j < n; j++) {
      k = (i + 1) * (j + 1);
      if (k <= n)
        a[k] = 1;
      else
        break;
    }
    k = 1;
  }
  for (i = 0; i < n; i++)
    if (a[i] == 0)
      printf("%d ", i);
}


x86 assembly (clang, -O0):
<findPrime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2ef0,%rsp
lea    -0x2ee0(%rbp),%rdi
xor    %esi,%esi
mov    $0x2ee0,%edx
call   1040 <memset@plt>
movl   $0xbb8,-0x2ee4(%rbp)
movl   $0x0,-0x2eec(%rbp)
movl   $0x1,-0x2ef0(%rbp)
movl   $0x1,-0x2ee0(%rbp)
movl   $0x1,-0x2ee8(%rbp)
mov    -0x2ee8(%rbp),%eax
cmp    -0x2ee4(%rbp),%eax
jge    1220 <findPrime+0x100>
mov    -0x2ee8(%rbp),%eax
mov    %eax,-0x2eec(%rbp)
mov    -0x2eec(%rbp),%eax
cmp    -0x2ee4(%rbp),%eax
jge    1202 <findPrime+0xe2>
mov    -0x2ee8(%rbp),%eax
add    $0x1,%eax
mov    -0x2eec(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    %eax,-0x2ef0(%rbp)
mov    -0x2ef0(%rbp),%eax
cmp    -0x2ee4(%rbp),%eax
jg     11e4 <findPrime+0xc4>
movslq -0x2ef0(%rbp),%rax
movl   $0x1,-0x2ee0(%rbp,%rax,4)
jmp    11e9 <findPrime+0xc9>
jmp    1202 <findPrime+0xe2>
jmp    11ee <findPrime+0xce>
mov    -0x2eec(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2eec(%rbp)
jmp    118e <findPrime+0x6e>
movl   $0x1,-0x2ef0(%rbp)
mov    -0x2ee8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2ee8(%rbp)
jmp    1170 <findPrime+0x50>
movl   $0x0,-0x2ee8(%rbp)
mov    -0x2ee8(%rbp),%eax
cmp    -0x2ee4(%rbp),%eax
jge    127c <findPrime+0x15c>
movslq -0x2ee8(%rbp),%rax
cmpl   $0x0,-0x2ee0(%rbp,%rax,4)
jne    1263 <findPrime+0x143>
mov    -0x2ee8(%rbp),%esi
lea    0xda2(%rip),%rdi
call   1030 <printf@plt>
jmp    1268 <findPrime+0x148>
mov    -0x2ee8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2ee8(%rbp)
jmp    122a <findPrime+0x10a>
add    $0x2ef0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findPrime>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2f08,%rsp
lea    0x20(%rsp),%rdi
mov    $0x2ee0,%edx
xor    %esi,%esi
call   1040 <memset@plt>
movl   $0x1,0x20(%rsp)
mov    $0x1,%r15d
mov    $0xbb7,%r11d
mov    $0x4,%ebp
mov    $0x8,%esi
movl   $0xa,0x10(%rsp)
mov    $0x2,%ebx
mov    $0xbb6,%eax
mov    %rax,0x18(%rsp)
movl   $0x10,0xc(%rsp)
mov    $0x9,%ecx
mov    $0xc,%edi
mov    $0xe,%r13d
mov    $0x6,%r10d
mov    $0x3,%edx
mov    $0x2,%r9d
jmp    11fa <findPrime+0xda>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x2,%r15
mov    %r14,%r11
add    $0xfffffffffffffffe,%r11
mov    %r12d,%ebp
add    %edi,%ebp
add    $0x8,%rdi
add    $0x8,%rsi
mov    0x10(%rsp),%eax
add    %eax,%r9d
add    $0x8,%eax
mov    %eax,0x10(%rsp)
add    $0x2,%ebx
addq   $0xfffffffffffffffe,0x18(%rsp)
mov    0xc(%rsp),%eax
mov    0x14(%rsp),%ecx
add    %eax,%ecx
add    $0x8,%eax
mov    %eax,0xc(%rsp)
add    %r13d,%r10d
add    $0x8,%r13d
add    $0x2,%edx
mov    %ecx,0x14(%rsp)
mov    %ecx,%eax
lea    (%rsp,%rax,4),%rcx
add    $0x20,%rcx
mov    %ebp,%r12d
mov    %ebp,%eax
lea    (%rsp,%rax,4),%r8
add    $0x20,%r8
mov    %r9d,%eax
mov    %r11,%r14
nopl   0x0(%rax,%rax,1)
add    %ebx,%eax
cmp    $0xbb8,%eax
ja     123c <findPrime+0x11c>
add    $0xffffffffffffffff,%r11
movl   $0x1,(%r8)
add    %rsi,%r8
test   %r11,%r11
jne    1220 <findPrime+0x100>
cmp    $0xbb7,%r15
je     1274 <findPrime+0x154>
mov    %r10d,%eax
mov    0x18(%rsp),%rbp
nopl   (%rax)
add    %edx,%eax
cmp    $0xbb8,%eax
ja     11b0 <findPrime+0x90>
add    $0xffffffffffffffff,%rbp
movl   $0x1,(%rcx)
add    %rdi,%rcx
test   %rbp,%rbp
jne    1250 <findPrime+0x130>
jmp    11b0 <findPrime+0x90>
xor    %ebx,%ebx
lea    0xd83(%rip),%r14
jmp    128d <findPrime+0x16d>
nop
add    $0x1,%rbx
cmp    $0xbb8,%rbx
je     12a0 <findPrime+0x180>
cmpl   $0x0,0x20(%rsp,%rbx,4)
jne    1280 <findPrime+0x160>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
jmp    1280 <findPrime+0x160>
add    $0x2f08,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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