#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int flag = 0, n, i;
  printf("Enter the number:");
  scanf("%d", &n);
  for (i = 2; i < n; i++) {
    if ((n % i) == 0) {
      flag = 1;
      break;
    }
  }
  if (flag == 1)
    printf("NOT PRIME NUMBER");
  else
    printf("PRIME NUMBER");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
lea    0xec9(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1194 <main+0x74>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    1181 <main+0x61>
movl   $0x1,-0x8(%rbp)
jmp    1194 <main+0x74>
jmp    1186 <main+0x66>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1159 <main+0x39>
cmpl   $0x1,-0x8(%rbp)
jne    11af <main+0x8f>
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
jmp    11bb <main+0x9b>
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <printf@plt>
lea    0xede(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%ecx
lea    0xed0(%rip),%rdi
cmp    $0x3,%ecx
jl     1175 <main+0x55>
mov    $0x2,%esi
lea    0xebb(%rip),%r8
nopw   0x0(%rax,%rax,1)
mov    %ecx,%eax
cltd
idiv   %esi
test   %edx,%edx
je     1172 <main+0x52>
add    $0x1,%esi
cmp    %esi,%ecx
jne    1160 <main+0x40>
jmp    1175 <main+0x55>
mov    %r8,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Enter the number:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"NOT PRIME NUMBER\00"
@.str.3 = [13 x i8] c"PRIME NUMBER\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%5 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 2, i32* %4
br label %7
7: ; preds = %18, %0
%8 = load i32, i32* %4
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %21
11: ; preds = %7
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = srem i32 %12, %13
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %11
store i32 1, i32* %2
br label %21
17: ; preds = %11
br label %18
18: ; preds = %17
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %7
21: ; preds = %16, %7
%22 = load i32, i32* %2
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %28
26: ; preds = %21
%27 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %26, %24
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"Enter the number:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"NOT PRIME NUMBER\00"
@.str.3 = [13 x i8] c"PRIME NUMBER\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 2
br i1 %6, label %9, label %14
7: ; preds = %9
%8 = icmp eq i32 %13, %5
br i1 %8, label %14, label %9
9: ; preds = %0, %7
%10 = phi i32 [ %13, %7 ], [ 2, %0 ]
%11 = srem i32 %5, %10
%12 = icmp eq i32 %11, 0
%13 = add nuw nsw i32 %10, 1
br i1 %12, label %14, label %7
14: ; preds = %7, %9, %0
%15 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), %0 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %9 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), %7 ]
%16 = call i32 @printf(i8* dereferenceable(1) %15)
ret i32 0
}