#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__ isPrime(int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char **argv) {
  int n = atoi(argv[1]);
  int i = 0;
  for (i = 2; i <= n; i++)
    if (isPrime(i)) {
      printf("%d - prime\n", i);
    } else {
      printf("%d - not prime\n", i);
    }
  return 0;
}


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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11b8 <main+0x88>
mov    -0x18(%rbp),%edi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     1196 <main+0x66>
mov    -0x18(%rbp),%esi
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
jmp    11a5 <main+0x75>
mov    -0x18(%rbp),%esi
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
jmp    11aa <main+0x7a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1164 <main+0x34>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
cmp    $0x2,%eax
jl     118b <main+0x5b>
mov    %eax,%r14d
neg    %r14d
mov    $0x2,%ebx
lea    0xeb4(%rip),%r15
lea    0xea1(%rip),%r12
nop
mov    %ebx,%edi
call   1040 <isPrime@plt>
test   %rax,%rax
mov    %r12,%rdi
cmove  %r15,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
lea    (%r14,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1160 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%d - prime\0A\00"
@.str.1 = [16 x i8] c"%d - not prime\0A\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 i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @atoi(i8* %10)
store i32 %11, i32* %6
store i32 0, i32* %7
store i32 2, i32* %7
br label %12
12: ; preds = %27, %2
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %30
16: ; preds = %12
%17 = load i32, i32* %7
%18 = call i64 @isPrime(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i32, i32* %7
%22 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %21)
br label %26
23: ; preds = %16
%24 = load i32, i32* %7
%25 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %23, %20
br label %27
27: ; preds = %26
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %12
30: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"%d - prime\0A\00"
@.str.1 = [16 x i8] c"%d - not prime\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 @atoi(i8* %4)
%6 = icmp slt i32 %5, 2
br i1 %6, label %15, label %7
7: ; preds = %2, %7
%8 = phi i32 [ %13, %7 ], [ 2, %2 ]
%9 = tail call i64 @isPrime(i32 %8)
%10 = icmp eq i64 %9, 0
%11 = select i1 %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0)
%12 = tail call i32 @printf(i8* %11, i32 %8)
%13 = add nuw i32 %8, 1
%14 = icmp eq i32 %8, %5
br i1 %14, label %15, label %7
15: ; preds = %7, %2
ret i32 0
}