#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*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, res = 0;
  int i = 5;
  int w = 2;
  printf("Hello..............!\n Enter a number to check if Prime\n");
  scanf("%d", &n);
  if (n == 2) {
    res = 1;
    printf("True\n");
  } else if (n == 3) {
    res = 1;
    printf("True\n");
  } else if ((n % 2) == 0) {
    res = 1;
    printf("False\n");
  } else if ((n % 3) == 0) {
    res = 1;
    printf("False\n");
  } else {
    while ((i * i) <= n) {
      if ((n % i) == 0) {
        res = 1;
        printf("False\n");
        break;
      }
      i += w;
      w = 6 - w;
    }
  }
  if (res == 0) {
    printf("True");
  }
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x5,-0x10(%rbp)
movl   $0x2,-0x14(%rbp)
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x2,-0x8(%rbp)
jne    1192 <main+0x62>
movl   $0x1,-0xc(%rbp)
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
jmp    1276 <main+0x146>
cmpl   $0x3,-0x8(%rbp)
jne    11b4 <main+0x84>
movl   $0x1,-0xc(%rbp)
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
jmp    1271 <main+0x141>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11e0 <main+0xb0>
movl   $0x1,-0xc(%rbp)
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
jmp    126c <main+0x13c>
mov    -0x8(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    120c <main+0xdc>
movl   $0x1,-0xc(%rbp)
lea    0xe3f(%rip),%rdi
call   1030 <printf@plt>
jmp    1267 <main+0x137>
jmp    1211 <main+0xe1>
mov    -0x10(%rbp),%eax
imul   -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1262 <main+0x132>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    1249 <main+0x119>
movl   $0x1,-0xc(%rbp)
lea    0xe02(%rip),%rdi
call   1030 <printf@plt>
jmp    1262 <main+0x132>
mov    -0x14(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x6,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1211 <main+0xe1>
jmp    1267 <main+0x137>
jmp    126c <main+0x13c>
jmp    1271 <main+0x141>
jmp    1276 <main+0x146>
cmpl   $0x0,-0xc(%rbp)
jne    128c <main+0x15c>
lea    0xdc1(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%ecx
cmp    $0x3,%ecx
je     116c <main+0x2c>
cmp    $0x2,%ecx
jne    1175 <main+0x35>
lea    0xecd(%rip),%rdi
jmp    11d2 <main+0x92>
test   $0x1,%cl
je     11cb <main+0x8b>
imul   $0xaaaaaaab,%ecx,%eax
add    $0x2aaaaaaa,%eax
cmp    $0x55555555,%eax
jb     11cb <main+0x8b>
cmp    $0x19,%ecx
jl     11bd <main+0x7d>
mov    $0x5,%esi
mov    $0x2,%edi
nopl   0x0(%rax,%rax,1)
mov    %ecx,%eax
cltd
idiv   %esi
test   %edx,%edx
je     11cb <main+0x8b>
add    %edi,%esi
mov    $0x6,%eax
sub    %edi,%eax
mov    %esi,%edx
imul   %esi,%edx
mov    %eax,%edi
cmp    %ecx,%edx
jle    11a0 <main+0x60>
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
jmp    11d7 <main+0x97>
lea    0xe68(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [56 x i8] c"Hello..............!\0A Enter a number to check if Prime\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [6 x i8] c"True\0A\00"
@.str.3 = [7 x i8] c"False\0A\00"
@.str.4 = [5 x i8] c"True\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 5, i32* %4
store i32 2, i32* %5
%6 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %0
store i32 1, i32* %3
%11 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %53
12: ; preds = %0
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 3
br i1 %14, label %15, label %17
15: ; preds = %12
store i32 1, i32* %3
%16 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %52
17: ; preds = %12
%18 = load i32, i32* %2
%19 = srem i32 %18, 2
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
store i32 1, i32* %3
%22 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %51
23: ; preds = %17
%24 = load i32, i32* %2
%25 = srem i32 %24, 3
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %23
store i32 1, i32* %3
%28 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %50
29: ; preds = %23
br label %30
30: ; preds = %43, %29
%31 = load i32, i32* %4
%32 = load i32, i32* %4
%33 = mul nsw i32 %31, %32
%34 = load i32, i32* %2
%35 = icmp sle i32 %33, %34
br i1 %35, label %36, label %49
36: ; preds = %30
%37 = load i32, i32* %2
%38 = load i32, i32* %4
%39 = srem i32 %37, %38
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %36
store i32 1, i32* %3
%42 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %49
43: ; preds = %36
%44 = load i32, i32* %5
%45 = load i32, i32* %4
%46 = add nsw i32 %45, %44
store i32 %46, i32* %4
%47 = load i32, i32* %5
%48 = sub nsw i32 6, %47
store i32 %48, i32* %5
br label %30
49: ; preds = %41, %30
br label %50
50: ; preds = %49, %27
br label %51
51: ; preds = %50, %21
br label %52
52: ; preds = %51, %15
br label %53
53: ; preds = %52, %10
%54 = load i32, i32* %3
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %58
58: ; preds = %56, %53
%59 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [55 x i8] c"Hello..............!\0A Enter a number to check if Prime\00"
@str.7 = [6 x i8] c"False\00"
@str.9 = [5 x i8] c"True\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 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
switch i32 %5, label %10 [
i32 2, label %6
i32 3, label %8
]
6: ; preds = %0
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.9, i64 0, i64 0))
br label %36
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.9, i64 0, i64 0))
br label %36
10: ; preds = %0
%11 = and i32 %5, 1
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.7, i64 0, i64 0))
br label %36
15: ; preds = %10
%16 = srem i32 %5, 3
%17 = icmp eq i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = icmp slt i32 %5, 25
br i1 %19, label %34, label %22
20: ; preds = %15
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.7, i64 0, i64 0))
br label %36
22: ; preds = %18, %29
%23 = phi i32 [ %31, %29 ], [ 2, %18 ]
%24 = phi i32 [ %30, %29 ], [ 5, %18 ]
%25 = srem i32 %5, %24
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.7, i64 0, i64 0))
br label %36
29: ; preds = %22
%30 = add nsw i32 %23, %24
%31 = sub nsw i32 6, %23
%32 = mul nsw i32 %30, %30
%33 = icmp sgt i32 %32, %5
br i1 %33, label %34, label %22
34: ; preds = %29, %18
%35 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.9, i64 0, i64 0))
br label %36
36: ; preds = %6, %13, %27, %20, %8, %34
%37 = call i32 (...) @getchar()
ret i32 0
}