#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*/ getch();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
main() {
loop:;
  int num, i, j, prime;
  j = 2;
  prime = 1;
  scanf("%d", &num);
  for (j = 2; j < num && prime == 1; ++j) {
    if (num % j == 0) {
      prime = 0;
    }
  }
  if (prime == 1) {
    printf("its a prime");
  }
  getch();
  goto loop;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
lea    0xeac(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0x15(%rbp)
jge    117f <main+0x4f>
cmpl   $0x1,-0x14(%rbp)
sete   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    118f <main+0x5f>
jmp    11b9 <main+0x89>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    11a6 <main+0x76>
movl   $0x0,-0x14(%rbp)
jmp    11ab <main+0x7b>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1164 <main+0x34>
cmpl   $0x1,-0x14(%rbp)
jne    11cf <main+0x9f>
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getch@plt>
jmp    113f <main+0xf>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec0(%rip),%r14
lea    0xc(%rsp),%rbx
lea    0xeb7(%rip),%r15
jmp    115f <main+0x2f>
xchg   %ax,%ax
mov    %r15,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1050 <getch@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%ecx
cmp    $0x3,%ecx
jl     1150 <main+0x20>
mov    $0x3,%esi
nopl   0x0(%rax,%rax,1)
lea    -0x1(%rsi),%edi
mov    %ecx,%eax
cltd
idiv   %edi
test   %edx,%edx
je     1195 <main+0x65>
lea    0x1(%rsi),%eax
cmp    %ecx,%esi
mov    %eax,%esi
jl     1180 <main+0x50>
test   %edx,%edx
jne    1150 <main+0x20>
jmp    1158 <main+0x28>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [12 x i8] c"its a prime\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
br label %6
6: ; preds = %32, %0
store i32 2, i32* %4
store i32 1, i32* %5
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 2, i32* %4
br label %8
8: ; preds = %24, %6
%9 = load i32, i32* %4
%10 = load i32, i32* %2
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 1
br label %15
15: ; preds = %12, %8
%16 = phi i1 [ false, %8 ], [ %14, %12 ]
br i1 %16, label %17, label %27
17: ; preds = %15
%18 = load i32, i32* %2
%19 = load i32, i32* %4
%20 = srem i32 %18, %19
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %17
store i32 0, i32* %5
br label %23
23: ; preds = %22, %17
br label %24
24: ; preds = %23
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %8
27: ; preds = %15
%28 = load i32, i32* %5
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
%33 = call i32 (...) @getch()
br label %6
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [12 x i8] c"its a prime\00"
define i32 @main() {
%1 = alloca i32
br label %2
2: ; preds = %16, %0
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = icmp sgt i32 %4, 2
br i1 %5, label %6, label %14
6: ; preds = %2, %6
%7 = phi i32 [ %10, %6 ], [ 2, %2 ]
%8 = srem i32 %4, %7
%9 = icmp ne i32 %8, 0
%10 = add nuw nsw i32 %7, 1
%11 = icmp slt i32 %10, %4
%12 = and i1 %9, %11
br i1 %12, label %6, label %13
13: ; preds = %6
br i1 %9, label %14, label %16
14: ; preds = %2, %13
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %13
%17 = call i32 (...) @getch()
br label %2
}