#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 fnisPrime(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int iVal, iFlag;
  printf("\n******************************************************");
  printf("\n*\tPROGRAM TO IMPLEMENT TEST OF PRIMALITY\t     *\n");
  printf("******************************************************");
  printf("\nEnter the value to be checked\n");
  scanf("%d", &iVal);
  iFlag = fnisPrime(iVal);
  if (1 == iFlag) {
    printf("\nThe entered value %d is a prime number\n", iVal);
  } else if (0 == iFlag) {
    printf("\nThe entered value %d is not a prime number\n", iVal);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xefa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf0c(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1030 <fnisPrime@plt>
mov    %eax,-0xc(%rbp)
mov    $0x1,%eax
cmp    -0xc(%rbp),%eax
jne    11b6 <main+0x86>
mov    -0x8(%rbp),%esi
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11d7 <main+0xa7>
xor    %eax,%eax
cmp    -0xc(%rbp),%eax
jne    11d2 <main+0xa2>
mov    -0x8(%rbp),%esi
lea    0xeeb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11d7 <main+0xa7>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf3b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf52(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%edi
call   1040 <fnisPrime@plt>
test   %eax,%eax
je     11a5 <main+0x65>
cmp    $0x1,%eax
jne    11b7 <main+0x77>
mov    0x4(%rsp),%esi
lea    0xe98(%rip),%rdi
jmp    11b0 <main+0x70>
mov    0x4(%rsp),%esi
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [56 x i8] c"\0A******************************************************\00"
@.str.1 = [50 x i8] c"\0A*\09PROGRAM TO IMPLEMENT TEST OF PRIMALITY\09 *\0A\00"
@.str.2 = [55 x i8] c"******************************************************\00"
@.str.3 = [32 x i8] c"\0AEnter the value to be checked\0A\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [41 x i8] c"\0AThe entered value %d is a prime number\0A\00"
@.str.6 = [45 x i8] c"\0AThe entered value %d is not a prime number\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = call i32 @fnisPrime(i32 %9)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = icmp eq i32 1, %11
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = load i32, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i32 %14)
br label %23
16: ; preds = %0
%17 = load i32, i32* %3
%18 = icmp eq i32 0, %17
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %19, %16
br label %23
23: ; preds = %22, %13
ret i32 0
}

LLVM IR (-O2):
@.str = [56 x i8] c"\0A******************************************************\00"
@.str.2 = [55 x i8] c"******************************************************\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [41 x i8] c"\0AThe entered value %d is a prime number\0A\00"
@.str.6 = [45 x i8] c"\0AThe entered value %d is not a prime number\0A\00"
@str = [49 x i8] c"\0A*\09PROGRAM TO IMPLEMENT TEST OF PRIMALITY\09 *\00"
@str.7 = [31 x i8] c"\0AEnter the value to be checked\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.7, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = call i32 @fnisPrime(i32 %8)
switch i32 %9, label %16 [
i32 1, label %10
i32 0, label %13
]
10: ; preds = %0
%11 = load i32, i32* %1
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i32 %11)
br label %16
13: ; preds = %0
%14 = load i32, i32* %1
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %0, %13, %10
ret i32 0
}