#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 *);
void prime() {
  int num, i, flag = 0;
  printf("\033[1mEnter positive integer enter to check: \033[0m\n");
  scanf("%d", &num);
  for (i = 2; i <= num / 2; ++i) {
    if (num % i == 0) {
      flag = 1;
      break;
    }
  }
  if (flag == 1) {
    printf("%d is not prime", num);
  } else
    printf("%d is prime", num);
}


x86 assembly (clang, -O0):
<prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0xc(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x2,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jg     11a1 <prime+0x81>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    118e <prime+0x6e>
movl   $0x1,-0xc(%rbp)
jmp    11a1 <prime+0x81>
jmp    1193 <prime+0x73>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1154 <prime+0x34>
cmpl   $0x1,-0xc(%rbp)
jne    11c1 <prime+0xa1>
mov    -0x4(%rbp),%esi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d2 <prime+0xb2>
mov    -0x4(%rbp),%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prime>:
push   %rax
lea    0xee7(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%r9d
lea    0xeb9(%rip),%rdi
cmp    $0x4,%r9d
jl     11a1 <prime+0x71>
mov    %r9d,%ecx
shr    %ecx
neg    %ecx
mov    $0x2,%esi
lea    0xe90(%rip),%r8
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r9d,%eax
cltd
idiv   %esi
test   %edx,%edx
je     119e <prime+0x6e>
lea    (%rcx,%rsi,1),%eax
add    $0x1,%eax
mov    %esi,%edx
add    $0x1,%edx
mov    %edx,%esi
cmp    $0x1,%eax
jne    1180 <prime+0x50>
jmp    11a1 <prime+0x71>
mov    %r8,%rdi
mov    %r9d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [49 x i8] c"\1B[1mEnter positive integer enter to check: \1B[0m\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"%d is not prime\00"
@.str.3 = [12 x i8] c"%d is prime\00"
define void @prime() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 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* %1)
store i32 2, i32* %2
br label %6
6: ; preds = %18, %0
%7 = load i32, i32* %2
%8 = load i32, i32* %1
%9 = sdiv i32 %8, 2
%10 = icmp sle i32 %7, %9
br i1 %10, label %11, label %21
11: ; preds = %6
%12 = load i32, i32* %1
%13 = load i32, i32* %2
%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* %3
br label %21
17: ; preds = %11
br label %18
18: ; preds = %17
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
store i32 %20, i32* %2
br label %6
21: ; preds = %16, %6
%22 = load i32, i32* %3
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i32, i32* %1
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %25)
br label %30
27: ; preds = %21
%28 = load i32, i32* %1
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %27, %24
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"%d is not prime\00"
@.str.3 = [12 x i8] c"%d is prime\00"
@str = [48 x i8] c"\1B[1mEnter positive integer enter to check: \1B[0m\00"
define void @prime() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 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 %16, label %7
7: ; preds = %0
%8 = lshr i32 %5, 1
br label %12
9: ; preds = %12
%10 = add nuw nsw i32 %13, 1
%11 = icmp eq i32 %13, %8
br i1 %11, label %16, label %12
12: ; preds = %7, %9
%13 = phi i32 [ %10, %9 ], [ 2, %7 ]
%14 = srem i32 %5, %13
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %9
16: ; preds = %9, %12, %0
%17 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), %0 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), %12 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), %9 ]
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %17, i32 %5)
ret void
}