#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 */
scalar_t__ isPrime(long);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, long *);
int main() {
  long num;
  printf("Enter a number and I'll check if it is a prime number. ");
  scanf(" %ld", &num);
  printf("\n");
  if (num > 1 && isPrime(num)) {
    printf("This number is a prime number. \n");
  } else
    printf("This number is not a prime number. \n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xefa(%rip),%rdi
call   1030 <printf@plt>
cmpq   $0x1,-0x10(%rbp)
jle    1196 <main+0x66>
mov    -0x10(%rbp),%rdi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     1196 <main+0x66>
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
jmp    11a2 <main+0x72>
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xea8(%rip),%rdi
call   1050 <printf@plt>
lea    0xed4(%rip),%rdi
mov    %rsp,%rsi
call   1070 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%rsp),%rdi
cmp    $0x2,%rdi
jl     1193 <main+0x43>
call   1060 <isPrime@plt>
test   %rax,%rax
je     1193 <main+0x43>
lea    0xed0(%rip),%rdi
jmp    119a <main+0x4a>
lea    0xea3(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [56 x i8] c"Enter a number and I'll check if it is a prime number. \00"
@.str.1 = [5 x i8] c" %ld\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [33 x i8] c"This number is a prime number. \0A\00"
@.str.4 = [37 x i8] c"This number is not a prime number. \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%5 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%6 = load i64, i64* %2
%7 = icmp sgt i64 %6, 1
br i1 %7, label %8, label %14
8: ; preds = %0
%9 = load i64, i64* %2
%10 = call i64 @isPrime(i64 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
br label %16
14: ; preds = %8, %0
%15 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
br label %16
16: ; preds = %14, %12
ret i32 0
}

LLVM IR (-O2):
@.str = [56 x i8] c"Enter a number and I'll check if it is a prime number. \00"
@.str.1 = [5 x i8] c" %ld\00"
@str = [36 x i8] c"This number is not a prime number. \00"
@str.5 = [32 x i8] c"This number is a prime number. \00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%5 = call i32 @putchar(i32 10)
%6 = load i64, i64* %1
%7 = icmp sgt i64 %6, 1
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i64 @isPrime(i64 %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %8, %0
br label %12
12: ; preds = %8, %11
%13 = phi i8* [ getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0), %11 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @str.5, i64 0, i64 0), %8 ]
%14 = call i32 @puts(i8* dereferenceable(1) %13)
ret i32 0
}