#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("Enter positive integer enter to check:\n");
  scanf("%d", &num);
  for (i = 2; i <= num / 2; ++i) {
    if (num % i == 0) {
      flag = 1;
    }
  }
  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    0xee4(%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     119c <prime+0x7c>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    1189 <prime+0x69>
movl   $0x1,-0xc(%rbp)
jmp    118e <prime+0x6e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1154 <prime+0x34>
cmpl   $0x1,-0xc(%rbp)
jne    11bc <prime+0x9c>
mov    -0x4(%rbp),%esi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cd <prime+0xad>
mov    -0x4(%rbp),%esi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prime>:
push   %rbx
sub    $0x10,%rsp
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%r11d
cmp    $0x4,%r11d
jl     11db <prime+0xab>
mov    %r11d,%eax
shr    %eax
lea    -0x1(%rax),%r8d
cmp    $0x2,%eax
jne    1174 <prime+0x44>
mov    $0x2,%ecx
xor    %edi,%edi
jmp    11b7 <prime+0x87>
mov    %r8d,%r9d
and    $0xfffffffe,%r9d
mov    $0x2,%ecx
xor    %edi,%edi
mov    $0x1,%r10d
nopl   0x0(%rax,%rax,1)
mov    %ecx,%esi
mov    %r11d,%eax
cltd
idiv   %ecx
mov    %edx,%ecx
lea    0x1(%rsi),%ebx
mov    %r11d,%eax
cltd
idiv   %ebx
test   %ecx,%ecx
cmove  %r10d,%edi
test   %edx,%edx
cmove  %r10d,%edi
lea    0x2(%rsi),%ecx
cmp    %r9d,%esi
jne    1190 <prime+0x60>
test   $0x1,%r8b
je     11cd <prime+0x9d>
mov    %r11d,%eax
cltd
idiv   %ecx
test   %edx,%edx
mov    $0x1,%eax
cmove  %eax,%edi
cmp    $0x1,%edi
jne    11db <prime+0xab>
lea    0xe2a(%rip),%rdi
jmp    11e2 <prime+0xb2>
lea    0xe31(%rip),%rdi
mov    %r11d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [40 x i8] c"Enter positive integer enter to check:\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 ([40 x i8], [40 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 %17
17: ; preds = %16, %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 = %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 = [39 x i8] c"Enter positive integer enter to check:\00"
define void @prime() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 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 %40, label %7
7: ; preds = %0
%8 = lshr i32 %5, 1
%9 = add nsw i32 %8, -1
%10 = and i32 %9, 1
%11 = icmp eq i32 %8, 2
br i1 %11, label %28, label %12
12: ; preds = %7
%13 = and i32 %9, -2
br label %14
14: ; preds = %14, %12
%15 = phi i32 [ 0, %12 ], [ %24, %14 ]
%16 = phi i32 [ 2, %12 ], [ %25, %14 ]
%17 = phi i32 [ 0, %12 ], [ %26, %14 ]
%18 = srem i32 %5, %16
%19 = icmp eq i32 %18, 0
%20 = or i32 %16, 1
%21 = srem i32 %5, %20
%22 = icmp eq i32 %21, 0
%23 = select i1 %22, i1 true, i1 %19
%24 = select i1 %23, i32 1, i32 %15
%25 = add nuw nsw i32 %16, 2
%26 = add i32 %17, 2
%27 = icmp eq i32 %26, %13
br i1 %27, label %28, label %14
28: ; preds = %14, %7
%29 = phi i32 [ undef, %7 ], [ %24, %14 ]
%30 = phi i32 [ 0, %7 ], [ %24, %14 ]
%31 = phi i32 [ 2, %7 ], [ %25, %14 ]
%32 = icmp eq i32 %10, 0
br i1 %32, label %37, label %33
33: ; preds = %28
%34 = srem i32 %5, %31
%35 = icmp eq i32 %34, 0
%36 = select i1 %35, i32 1, i32 %30
br label %37
37: ; preds = %28, %33
%38 = phi i32 [ %29, %28 ], [ %36, %33 ]
%39 = icmp eq i32 %38, 1
br i1 %39, label %41, label %40
40: ; preds = %0, %37
br label %41
41: ; preds = %37, %40
%42 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), %40 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), %37 ]
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %42, i32 %5)
ret void
}