#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*/ get_primes(int, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, size;
  printf("Input amount:");
  scanf("%d", &size);
  int array_primes[size];
  for (i = 0; i < size; i++) {
    array_primes[i] = 0;
  }
  array_primes[0] = 2;
  get_primes(size, array_primes);
  for (i = 0; i < size; i++) {
    if (array_primes[i] == 0) {
      break;
    }
    printf("%d ", array_primes[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeba(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b4 <main+0x84>
mov    -0x28(%rbp),%rax
movslq -0x8(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    118b <main+0x5b>
mov    -0x28(%rbp),%rsi
movl   $0x2,(%rsi)
mov    -0xc(%rbp),%edi
call   1050 <get_primes@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1217 <main+0xe7>
mov    -0x28(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    11f0 <main+0xc0>
jmp    1217 <main+0xe7>
mov    -0x28(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11cd <main+0x9d>
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
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   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9a(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1060 <scanf@plt>
mov    %rsp,%r15
mov    -0x24(%rbp),%eax
mov    %rsp,%r12
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    -0x24(%rbp),%r14d
test   %r14d,%r14d
jle    11b3 <main+0x63>
lea    0x0(,%r14,4),%rdx
mov    %r12,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
movl   $0x2,(%r12)
mov    %r14d,%edi
mov    %r12,%rsi
call   1070 <get_primes@plt>
cmpl   $0x0,-0x24(%rbp)
jle    11ff <main+0xaf>
lea    0xe3e(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r12,%rbx,4),%esi
test   %esi,%esi
je     11ff <main+0xaf>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
movslq -0x24(%rbp),%rax
cmp    %rax,%rbx
jl     11e0 <main+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r15,%rsp
xor    %eax,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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