#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 input();
int /*<<< orphan*/ printf(char *, int);
int main() {
  int num, i, flag = 0;
  num = input();
  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);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <input@plt>
mov    %eax,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jg     1194 <main+0x74>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1181 <main+0x61>
movl   $0x1,-0x10(%rbp)
jmp    1194 <main+0x74>
jmp    1186 <main+0x66>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1147 <main+0x27>
cmpl   $0x1,-0x10(%rbp)
jne    11b2 <main+0x92>
mov    -0x8(%rbp),%esi
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
jmp    11c1 <main+0xa1>
mov    -0x8(%rbp),%esi
lea    0xe54(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1030 <input@plt>
mov    %eax,%r9d
lea    0xede(%rip),%rdi
cmp    $0x4,%eax
jl     1171 <main+0x51>
mov    %r9d,%ecx
shr    %ecx
neg    %ecx
mov    $0x2,%esi
lea    0xeb6(%rip),%r8
nopw   0x0(%rax,%rax,1)
mov    %r9d,%eax
cltd
idiv   %esi
test   %edx,%edx
je     116e <main+0x4e>
lea    (%rcx,%rsi,1),%eax
add    $0x1,%eax
mov    %esi,%edx
add    $0x1,%edx
mov    %edx,%esi
cmp    $0x1,%eax
jne    1150 <main+0x30>
jmp    1171 <main+0x51>
mov    %r8,%rdi
mov    %r9d,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [16 x i8] c"%d is not prime\00"
@.str.1 = [12 x i8] c"%d is prime\00"
define i32 @main() {
%1 = tail call i32 (...) @input()
%2 = icmp slt i32 %1, 4
br i1 %2, label %12, label %3
3: ; preds = %0
%4 = lshr i32 %1, 1
br label %8
5: ; preds = %8
%6 = add nuw nsw i32 %9, 1
%7 = icmp eq i32 %9, %4
br i1 %7, label %12, label %8
8: ; preds = %3, %5
%9 = phi i32 [ %6, %5 ], [ 2, %3 ]
%10 = srem i32 %1, %9
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %5
12: ; preds = %5, %8, %0
%13 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), %0 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), %8 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), %5 ]
%14 = tail call i32 @printf(i8* %13, i32 %1)
ret i32 0
}