#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(void) {
  printf("Input number to be checked : ");
  int num;
  scanf("%d", &num);
  int i;
  for (i = 2; i <= num / 2; i++) {
    if (num % i == 0) {
      printf("\n Not Prime Number ");
      break;
    }
  }
  if (i > num / 2) {
    printf("Prime number");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jg     11a4 <main+0x84>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1191 <main+0x71>
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
jmp    11a4 <main+0x84>
jmp    1196 <main+0x76>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1152 <main+0x32>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jle    11ce <main+0xae>
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%ecx
mov    %ecx,%esi
shr    $0x1f,%esi
add    %ecx,%esi
sar    %esi
mov    $0x2,%ebx
cmp    $0x4,%ecx
jl     118e <main+0x6e>
cmp    $0x3,%esi
mov    $0x2,%ebx
mov    $0x2,%edi
cmovge %esi,%edi
lea    0x1(%rdi),%r8d
neg    %edi
nop
mov    %ecx,%eax
cltd
idiv   %ebx
test   %edx,%edx
je     11a6 <main+0x86>
lea    (%rdi,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%edx
add    $0x1,%edx
mov    %edx,%ebx
cmp    $0x1,%eax
jne    1170 <main+0x50>
mov    %r8d,%ebx
cmp    %esi,%ebx
jle    119e <main+0x7e>
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
mov    0xc(%rsp),%eax
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
cmp    %esi,%ebx
jg     1192 <main+0x72>
jmp    119e <main+0x7e>

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

LLVM IR (-O2):
@.str = [30 x i8] c"Input number to be checked : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"\0A Not Prime Number \00"
@.str.3 = [13 x i8] c"Prime number\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%3 = bitcast i32* %1 to i8*
%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 = sdiv i32 %5, 2
%7 = icmp slt i32 %5, 4
br i1 %7, label %22, label %8
8: ; preds = %0
%9 = call i32 @llvm.smax.i32(i32 %6, i32 2)
%10 = add nuw nsw i32 %9, 1
br label %11
11: ; preds = %8, %19
%12 = phi i32 [ %20, %19 ], [ 2, %8 ]
%13 = srem i32 %5, %12
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%17 = load i32, i32* %1
%18 = sdiv i32 %17, 2
br label %22
19: ; preds = %11
%20 = add nuw nsw i32 %12, 1
%21 = icmp eq i32 %12, %9
br i1 %21, label %22, label %11
22: ; preds = %19, %0, %15
%23 = phi i32 [ %6, %0 ], [ %18, %15 ], [ %6, %19 ]
%24 = phi i32 [ 2, %0 ], [ %12, %15 ], [ %10, %19 ]
%25 = icmp sgt i32 %24, %23
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %26, %22
ret i32 0
}