#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 *eratosthenes(int);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  int number = 100;
  int *result;
  result = eratosthenes(number);
  int c = 0;
  while (1) {
    if (result[c] < 2 || result[c] > number) {
      break;
    }
    printf("Prime number is %d\n", result[c]);
    c++;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x64,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <eratosthenes@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x2,(%rax,%rcx,4)
jl     116f <main+0x4f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x8(%rbp),%eax
jle    1174 <main+0x54>
jmp    1199 <main+0x79>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1149 <main+0x29>
mov    0x2e40(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x64,%edi
call   1030 <eratosthenes@plt>
mov    %rax,%rbx
mov    (%rax),%esi
lea    -0x65(%rsi),%eax
cmp    $0xffffff9d,%eax
jb     1166 <main+0x46>
add    $0x4,%rbx
lea    0xeba(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    (%rbx),%esi
lea    -0x65(%rsi),%eax
add    $0x4,%rbx
cmp    $0xffffff9c,%eax
ja     1150 <main+0x30>
mov    0x2e73(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [20 x i8] c"Prime number is %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32* @eratosthenes(i32 100)
%2 = load i32, i32* %1
%3 = add i32 %2, -101
%4 = icmp ult i32 %3, -99
br i1 %4, label %14, label %5
5: ; preds = %0, %5
%6 = phi i64 [ %9, %5 ], [ 0, %0 ]
%7 = phi i32 [ %11, %5 ], [ %2, %0 ]
%8 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = add nuw i64 %6, 1
%10 = getelementptr inbounds i32, i32* %1, i64 %9
%11 = load i32, i32* %10
%12 = add i32 %11, -101
%13 = icmp ult i32 %12, -99
br i1 %13, label %14, label %5
14: ; preds = %5, %0
%15 = load i32, i32* @EXIT_SUCCESS
ret i32 %15
}