#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*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ is_prime(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int *sieve_of_eratosthenes(int);
int main() {
  int n, *primes;
  printf("%s", "How many data? ");
  scanf("%d", &n);
  primes = sieve_of_eratosthenes(n);
  for (int i = 0; i < n; i++) {
    if (primes[i]) {
      printf("%d ", i);
      assert(is_prime(i));
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe96(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe98(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1050 <sieve_of_eratosthenes@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e8 <main+0x98>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     11d5 <main+0x85>
mov    -0x14(%rbp),%esi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
call   1060 <is_prime@plt>
mov    %eax,%edi
call   1040 <assert@plt>
jmp    11da <main+0x8a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1197 <main+0x47>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xea0(%rip),%rdi
lea    0xe9c(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%edi
call   1050 <sieve_of_eratosthenes@plt>
mov    %rax,%r15
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    11d3 <main+0x83>
lea    0xe7c(%rip),%r14
xor    %ebx,%ebx
jmp    11ac <main+0x5c>
xchg   %ax,%ax
add    $0x1,%rbx
movslq %eax,%rcx
cmp    %rcx,%rbx
jge    11d3 <main+0x83>
cmpl   $0x0,(%r15,%rbx,4)
je     11a0 <main+0x50>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%edi
call   1060 <is_prime@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    0xc(%rsp),%eax
jmp    11a0 <main+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [16 x i8] c"How many data? \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = call i32* @sieve_of_eratosthenes(i32 %5)
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %22, %0
ret i32 0
10: ; preds = %0, %22
%11 = phi i32 [ %23, %22 ], [ %7, %0 ]
%12 = phi i64 [ %24, %22 ], [ 0, %0 ]
%13 = getelementptr inbounds i32, i32* %6, i64 %12
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %10
%17 = trunc i64 %12 to i32
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = call i32 @is_prime(i32 %17)
%20 = call i32 @assert(i32 %19)
%21 = load i32, i32* %1
br label %22
22: ; preds = %10, %16
%23 = phi i32 [ %11, %10 ], [ %21, %16 ]
%24 = add nuw nsw i64 %12, 1
%25 = sext i32 %23 to i64
%26 = icmp slt i64 %24, %25
br i1 %26, label %10, label %9
}