#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 */
unsigned int atol(char *);
scalar_t__ isPrime(unsigned int);
unsigned int *malloc(int);
int /*<<< orphan*/ printf(char *, unsigned int);
int main(int argc, char **argv) {
  unsigned int max = atol(argv[1]);
  unsigned int *a = malloc(sizeof(unsigned int) * max);
  unsigned int x = 2;
  for (unsigned int i = 0; i < max; x++)
    if (isPrime(x))
      a[i++] = x;
  for (unsigned int i = 0; i < max; i++)
    printf("%u\n", (unsigned int)a[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x2,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11ce <main+0x8e>
mov    -0x24(%rbp),%edi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     11bb <main+0x7b>
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x28(%rbp)
mov    %ecx,%ecx
mov    %edx,(%rax,%rcx,4)
jmp    11c0 <main+0x80>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1186 <main+0x46>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1205 <main+0xc5>
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    (%rax,%rcx,4),%esi
lea    0xe0e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11d5 <main+0x95>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
call   1060 <atol@plt>
mov    %eax,%r14d
lea    0x0(,%r14,4),%edi
call   1050 <malloc@plt>
test   %r14d,%r14d
je     11c5 <main+0x85>
mov    %rax,%r15
mov    $0x2,%ebp
xor    %ebx,%ebx
jmp    1188 <main+0x48>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    %r14d,%ebx
jae    119f <main+0x5f>
mov    %ebp,%edi
call   1040 <isPrime@plt>
test   %rax,%rax
je     1180 <main+0x40>
mov    %ebx,%eax
add    $0x1,%ebx
mov    %ebp,(%r15,%rax,4)
jmp    1180 <main+0x40>
mov    %r14d,%ebx
xor    %ebp,%ebp
lea    0xe55(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbp,4),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11b0 <main+0x70>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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