#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 IsPrime, input, i;
  IsPrime = 1;
  printf("Please Enter a number to find out whether its prime or not : ");
  scanf("%d", &input);
  for (i = 2; i <= input / 2; i++)
    if (input % i == 0) {
      IsPrime = 0;
      break;
    }
  if ((IsPrime == 1) && (input != 1))
    printf("%d is prime!", input);
  else
    printf("%d is not prime It can be devided by %d\n", input,
           input == 1 ? 1 : i);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef3(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jg     11a8 <main+0x88>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    1195 <main+0x75>
movl   $0x0,-0x8(%rbp)
jmp    11a8 <main+0x88>
jmp    119a <main+0x7a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115b <main+0x3b>
cmpl   $0x1,-0x8(%rbp)
jne    11d2 <main+0xb2>
cmpl   $0x1,-0xc(%rbp)
je     11d2 <main+0xb2>
mov    -0xc(%rbp),%esi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1209 <main+0xe9>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    11ef <main+0xcf>
mov    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f5 <main+0xd5>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf08(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
mov    $0x2,%r8d
cmp    $0x4,%esi
jl     1177 <main+0x57>
mov    %esi,%edi
shr    %edi
lea    0x1(%rdi),%r8d
neg    %edi
mov    $0x2,%ecx
xchg   %ax,%ax
mov    %esi,%eax
cltd
idiv   %ecx
test   %edx,%edx
je     117f <main+0x5f>
lea    (%rdi,%rcx,1),%eax
add    $0x1,%eax
add    $0x1,%ecx
cmp    $0x1,%eax
jne    1160 <main+0x40>
mov    %r8d,%ecx
cmp    $0x1,%esi
jne    1197 <main+0x77>
cmp    $0x1,%esi
cmove  %esi,%ecx
lea    0xec2(%rip),%rdi
mov    %ecx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11a5 <main+0x85>
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [62 x i8] c"Please Enter a number to find out whether its prime or not : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"%d is prime!\00"
@.str.3 = [41 x i8] c"%d is not prime It can be devided by %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 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 = %19, %0
%8 = load i32, i32* %4
%9 = load i32, i32* %3
%10 = sdiv i32 %9, 2
%11 = icmp sle i32 %8, %10
br i1 %11, label %12, label %22
12: ; preds = %7
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = srem i32 %13, %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 0, i32* %2
br label %22
18: ; preds = %12
br label %19
19: ; preds = %18
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %7
22: ; preds = %17, %7
%23 = load i32, i32* %2
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %31
25: ; preds = %22
%26 = load i32, i32* %3
%27 = icmp ne i32 %26, 1
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i32, i32* %3
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %29)
br label %41
31: ; preds = %25, %22
%32 = load i32, i32* %3
%33 = load i32, i32* %3
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %36
35: ; preds = %31
br label %38
36: ; preds = %31
%37 = load i32, i32* %4
br label %38
38: ; preds = %36, %35
%39 = phi i32 [ 1, %35 ], [ %37, %36 ]
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i32 %32, i32 %39)
br label %41
41: ; preds = %38, %28
ret i32 0
}

LLVM IR (-O2):
@.str = [62 x i8] c"Please Enter a number to find out whether its prime or not : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"%d is prime!\00"
@.str.3 = [41 x i8] c"%d is not prime It can be devided by %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 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 slt i32 %5, 4
br i1 %6, label %17, label %7
7: ; preds = %0
%8 = lshr i32 %5, 1
%9 = add nuw nsw i32 %8, 1
br label %10
10: ; preds = %7, %14
%11 = phi i32 [ %15, %14 ], [ 2, %7 ]
%12 = srem i32 %5, %11
%13 = icmp eq i32 %12, 0
br i1 %13, label %22, label %14
14: ; preds = %10
%15 = add nuw nsw i32 %11, 1
%16 = icmp eq i32 %11, %8
br i1 %16, label %17, label %10
17: ; preds = %14, %0
%18 = phi i32 [ 2, %0 ], [ %9, %14 ]
%19 = icmp eq i32 %5, 1
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %5)
br label %27
22: ; preds = %10, %17
%23 = phi i32 [ %18, %17 ], [ %11, %10 ]
%24 = icmp eq i32 %5, 1
%25 = select i1 %24, i32 1, i32 %23
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i32 %5, i32 %25)
br label %27
27: ; preds = %22, %20
ret i32 0
}