#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 atoi(char *);
scalar_t__ is_prime(int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ puts(char *);
int main(int argc, char *argv[]) {
  if (argc == 1) {
    puts("./prime_list [max_num(>2)]");
    return 0;
  }
  int max_num = atoi(argv[1]);
  if (max_num <= 2) {
    puts("max_num must be greater than 2");
    return 0;
  }
  puts("2");
  for (int i = 3; i <= max_num; i = i + 2) {
    if (is_prime(i)) {
      printf("%d%c", i, 0xa);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1178 <main+0x38>
lea    0xe99(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    1202 <main+0xc2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jg     11aa <main+0x6a>
lea    0xe82(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    1202 <main+0xc2>
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
movl   $0x3,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1202 <main+0xc2>
mov    -0x18(%rbp),%edi
call   1050 <is_prime@plt>
cmp    $0x0,%rax
je     11ef <main+0xaf>
mov    -0x18(%rbp),%esi
lea    0xe55(%rip),%rdi
mov    $0xa,%edx
call   1040 <printf@plt>
jmp    11f4 <main+0xb4>
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x18(%rbp)
jmp    11bd <main+0x7d>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x1,%edi
jne    1152 <main+0x12>
lea    0xeb0(%rip),%rdi
jmp    1167 <main+0x27>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
cmp    $0x3,%eax
jge    1173 <main+0x33>
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %eax,%ebx
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%ebp
lea    0xead(%rip),%r14
jmp    1197 <main+0x57>
nop
add    $0x2,%ebp
cmp    %ebx,%ebp
jg     116c <main+0x2c>
mov    %ebp,%edi
call   1050 <is_prime@plt>
test   %rax,%rax
je     1190 <main+0x50>
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0xa,%edx
call   1040 <printf@plt>
jmp    1190 <main+0x50>

LLVM IR (-O0):
@.str = [27 x i8] c"./prime_list [max_num(>2)]\00"
@.str.1 = [31 x i8] c"max_num must be greater than 2\00"
@.str.2 = [2 x i8] c"2\00"
@.str.3 = [5 x i8] c"%d%c\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %38
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = icmp sle i32 %17, 2
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %38
21: ; preds = %12
%22 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 3, i32* %7
br label %23
23: ; preds = %35, %21
%24 = load i32, i32* %7
%25 = load i32, i32* %6
%26 = icmp sle i32 %24, %25
br i1 %26, label %27, label %38
27: ; preds = %23
%28 = load i32, i32* %7
%29 = call i64 @is_prime(i32 %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i32, i32* %7
%33 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %32, i32 10)
br label %34
34: ; preds = %31, %27
br label %35
35: ; preds = %34
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 2
store i32 %37, i32* %7
br label %23
38: ; preds = %10, %19, %23
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [27 x i8] c"./prime_list [max_num(>2)]\00"
@.str.1 = [31 x i8] c"max_num must be greater than 2\00"
@.str.2 = [2 x i8] c"2\00"
@.str.3 = [5 x i8] c"%d%c\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %20, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = icmp slt i32 %7, 3
br i1 %8, label %20, label %9
9: ; preds = %4
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %9, %17
%12 = phi i32 [ 3, %9 ], [ %18, %17 ]
%13 = tail call i64 @is_prime(i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %12, i32 10)
br label %17
17: ; preds = %11, %15
%18 = add nuw nsw i32 %12, 2
%19 = icmp sgt i32 %18, %7
br i1 %19, label %23, label %11
20: ; preds = %4, %2
%21 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), %4 ]
%22 = tail call i32 @puts(i8* dereferenceable(1) %21)
br label %23
23: ; preds = %17, %20
ret i32 0
}