#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 *);
int main() {
  int n, c;
  printf("Enter an integer\n");
  scanf("%d", &n);
  if (n == 2) {
    printf("Prime number.\n");
  } else {
    for (c = 2; c <= n - 1; c++) {
      if (n % c == 0) {
        break;
      }
    }
    if (c != n) {
      printf("Not prime.\n");
    } else {
      printf("Prime number.\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x2,-0x8(%rbp)
jne    1166 <main+0x46>
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
jmp    11d4 <main+0xb4>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     11a6 <main+0x86>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1193 <main+0x73>
jmp    11a6 <main+0x86>
jmp    1198 <main+0x78>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116d <main+0x4d>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     11c3 <main+0xa3>
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
jmp    11cf <main+0xaf>
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
jmp    11d4 <main+0xb4>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xedb(%rip),%rdi
call   1030 <puts@plt>
lea    0xecc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%ecx
lea    0xed6(%rip),%rdi
cmp    $0x2,%ecx
je     117d <main+0x5d>
mov    $0x2,%esi
jle    1172 <main+0x52>
mov    $0x2,%esi
nopw   0x0(%rax,%rax,1)
mov    %ecx,%eax
cltd
idiv   %esi
test   %edx,%edx
je     1172 <main+0x52>
add    $0x1,%esi
cmp    %esi,%ecx
jne    1160 <main+0x40>
jmp    117d <main+0x5d>
cmp    %ecx,%esi
je     117d <main+0x5d>
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Enter an integer\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [15 x i8] c"Prime number.\0A\00"
@.str.3 = [12 x i8] c"Not prime.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 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* %2)
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %35
10: ; preds = %0
store i32 2, i32* %3
br label %11
11: ; preds = %23, %10
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = sub nsw i32 %13, 1
%15 = icmp sle i32 %12, %14
br i1 %15, label %16, label %26
16: ; preds = %11
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = srem i32 %17, %18
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16
br label %26
22: ; preds = %16
br label %23
23: ; preds = %22
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %11
26: ; preds = %21, %11
%27 = load i32, i32* %3
%28 = load i32, i32* %2
%29 = icmp ne i32 %27, %28
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %34
32: ; preds = %26
%33 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %34
34: ; preds = %32, %30
br label %35
35: ; preds = %34, %8
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [17 x i8] c"Enter an integer\00"
@str.5 = [11 x i8] c"Not prime.\00"
@str.6 = [14 x i8] c"Prime number.\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 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 eq i32 %5, 2
br i1 %6, label %20, label %7
7: ; preds = %0
%8 = icmp sgt i32 %5, 2
br i1 %8, label %9, label %16
9: ; preds = %7, %13
%10 = phi i32 [ %14, %13 ], [ 2, %7 ]
%11 = srem i32 %5, %10
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %9
%14 = add nuw nsw i32 %10, 1
%15 = icmp eq i32 %14, %5
br i1 %15, label %19, label %9
16: ; preds = %9, %7
%17 = phi i32 [ 2, %7 ], [ %10, %9 ]
%18 = icmp eq i32 %17, %5
br i1 %18, label %19, label %20
19: ; preds = %13, %16
br label %20
20: ; preds = %16, %0, %19
%21 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.6, i64 0, i64 0), %19 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.6, i64 0, i64 0), %0 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.5, i64 0, i64 0), %16 ]
%22 = call i32 @puts(i8* dereferenceable(1) %21)
ret i32 0
}