#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(unsigned int *);
unsigned int *primelist(unsigned int);
int /*<<< orphan*/ print_primes(unsigned int *, unsigned int);
long strtol(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  unsigned int max = (1 << 16);
  unsigned int *p = NULL;
  if (argc == 2) {
    long int tmp = strtol(argv[1], NULL, 10);
    max = (unsigned int)tmp;
  }
  p = primelist(max);
  print_primes(p, max);
  free(p);
  p = NULL;
  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)
movl   $0x10000,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1190 <main+0x50>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <primelist@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <print_primes@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x20(%rbp)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x10000,%r14d
cmp    $0x2,%edi
jne    1162 <main+0x22>
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,%r14
mov    %r14d,%edi
call   1030 <primelist@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14d,%esi
call   1050 <print_primes@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 65536, i32* %6
store i32* null, i32** %7
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @strtol(i8* %14, i32* null, i32 10)
store i64 %15, i64* %8
%16 = load i64, i64* %8
%17 = trunc i64 %16 to i32
store i32 %17, i32* %6
br label %18
18: ; preds = %11, %2
%19 = load i32, i32* %6
%20 = call i32* @primelist(i32 %19)
store i32* %20, i32** %7
%21 = load i32*, i32** %7
%22 = load i32, i32* %6
%23 = call i32 @print_primes(i32* %21, i32 %22)
%24 = load i32*, i32** %7
%25 = call i32 @free(i32* %24)
store i32* null, i32** %7
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strtol(i8* nocapture %6, i32* null, i32 10)
%8 = trunc i64 %7 to i32
br label %9
9: ; preds = %4, %2
%10 = phi i32 [ %8, %4 ], [ 65536, %2 ]
%11 = tail call i32* @primelist(i32 %10)
%12 = tail call i32 @print_primes(i32* %11, i32 %10)
%13 = tail call i32 @free(i32* %11)
ret i32 0
}