#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*/ free(long *);
int /*<<< orphan*/ printf(char *, long);
long *seive(long);
long strtol(char *, char **, int);
int main(int argc, char *argv[]) {
  char *ptr;
  long n = strtol(argv[1], &ptr, 10);
  long *p = seive(n);
  for (size_t i = 0; i < n; i++) {
    if (p[i]) {
      printf("%li\n", p[i]);
    }
  }
  free(p);
  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
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <seive@plt>
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11d4 <main+0x94>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11be <main+0x7e>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
jmp    11c3 <main+0x83>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1185 <main+0x45>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1050 <seive@plt>
mov    %rax,%r12
test   %r14,%r14
je     119c <main+0x5c>
xor    %ebx,%ebx
lea    0xe8b(%rip),%r15
jmp    1189 <main+0x49>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r14
je     119c <main+0x5c>
mov    (%r12,%rbx,8),%rsi
test   %rsi,%rsi
je     1180 <main+0x40>
mov    %r15,%rdi
call   1040 <printf@plt>
jmp    1180 <main+0x40>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%li\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64*
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i64 @strtol(i8* %12, i8** %6, i32 10)
store i64 %13, i64* %7
%14 = load i64, i64* %7
%15 = call i64* @seive(i64 %14)
store i64* %15, i64** %8
store i64 0, i64* %9
br label %16
16: ; preds = %33, %2
%17 = load i64, i64* %9
%18 = load i64, i64* %7
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %36
20: ; preds = %16
%21 = load i64*, i64** %8
%22 = load i64, i64* %9
%23 = getelementptr inbounds i64, i64* %21, i64 %22
%24 = load i64, i64* %23
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %20
%27 = load i64*, i64** %8
%28 = load i64, i64* %9
%29 = getelementptr inbounds i64, i64* %27, i64 %28
%30 = load i64, i64* %29
%31 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %30)
br label %32
32: ; preds = %26, %20
br label %33
33: ; preds = %32
%34 = load i64, i64* %9
%35 = add i64 %34, 1
store i64 %35, i64* %9
br label %16
36: ; preds = %16
%37 = load i64*, i64** %8
%38 = call i32 @free(i64* %37)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%li\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = call i64 @strtol(i8* %6, i8** %3, i32 10)
%8 = tail call i64* @seive(i64 %7)
%9 = icmp eq i64 %7, 0
br i1 %9, label %10, label %12
10: ; preds = %19, %2
%11 = tail call i32 @free(i64* %8)
ret i32 0
12: ; preds = %2, %19
%13 = phi i64 [ %20, %19 ], [ 0, %2 ]
%14 = getelementptr inbounds i64, i64* %8, i64 %13
%15 = load i64, i64* %14
%16 = icmp eq i64 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %12
%18 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %15)
br label %19
19: ; preds = %12, %17
%20 = add nuw i64 %13, 1
%21 = icmp eq i64 %20, %7
br i1 %21, label %10, label %12
}