#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__ is_prime(unsigned long);
int /*<<< orphan*/ printf(char *, unsigned long, char *);
int /*<<< orphan*/ scanf(char *, unsigned long *);
int main(int argc, char **argv) {
  unsigned long n = 0UL;
  while (!scanf("%lu", &n))
    ;
  printf("%lu is %s prime \n", n, is_prime(n) ? "" : "not");
  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)
movq   $0x0,-0x18(%rbp)
lea    0xeab(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1173 <main+0x43>
jmp    1178 <main+0x48>
jmp    114e <main+0x1e>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <is_prime@plt>
mov    -0x20(%rbp),%rsi
mov    %rax,%rcx
lea    0xe7f(%rip),%rdx
lea    0xe77(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdx
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movq   $0x0,(%rsp)
lea    0xebd(%rip),%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
test   %eax,%eax
je     1150 <main+0x20>
mov    (%rsp),%rbx
mov    %rbx,%rdi
call   1040 <is_prime@plt>
test   %rax,%rax
lea    0xea1(%rip),%rax
lea    0xe99(%rip),%rdx
cmove  %rax,%rdx
lea    0xe7d(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lu\00"
@.str.1 = [18 x i8] c"%lu is %s prime \0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [4 x i8] c"not\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %6
br label %7
7: ; preds = %11, %2
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %6)
%9 = icmp ne i32 %8, 0
%10 = xor i1 %9, true
br i1 %10, label %11, label %12
11: ; preds = %7
br label %7
12: ; preds = %7
%13 = load i64, i64* %6
%14 = load i64, i64* %6
%15 = call i64 @is_prime(i64 %14)
%16 = icmp ne i64 %15, 0
%17 = zext i1 %16 to i64
%18 = select i1 %16, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0)
%19 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i64 %13, i8* %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lu\00"
@.str.1 = [18 x i8] c"%lu is %s prime \0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [4 x i8] c"not\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
store i64 0, i64* %3
br label %5
5: ; preds = %5, %2
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %5, label %8
8: ; preds = %5
%9 = load i64, i64* %3
%10 = call i64 @is_prime(i64 %9)
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%13 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i64 %9, i8* %12)
ret i32 0
}