#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 main() {
  int num;
  int curnum;
  int isPrime = 1;
  num = -1;
  while (num < 2) {
    printf("Please enter an integer that is greater than 1: ");
    scanf("%d", &num);
  }
  curnum = num - 1;
  while (curnum > 1) {
    if ((num % curnum) == 0)
      isPrime = 0;
    curnum -= 1;
  }
  if (isPrime == 1)
    printf("The number is prime.");
  else
    printf("The number is composite.");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0xc(%rbp)
movl   $0xffffffff,-0x4(%rbp)
cmpl   $0x2,-0x4(%rbp)
jge    1161 <main+0x41>
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
lea    0xede(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1136 <main+0x16>
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1199 <main+0x79>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    118b <main+0x6b>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116a <main+0x4a>
cmpl   $0x1,-0xc(%rbp)
jne    11b4 <main+0x94>
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
jmp    11c0 <main+0xa0>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0xffffffff,0xc(%rsp)
ff
lea    0xec8(%rip),%r14
lea    0xef2(%rip),%r15
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%ecx
cmp    $0x2,%ecx
jl     1150 <main+0x30>
jne    1177 <main+0x57>
lea    0xebf(%rip),%rdi
jmp    11aa <main+0x8a>
lea    0x1(%rcx),%edi
mov    $0x1,%esi
nop
lea    -0x2(%rdi),%ebx
mov    %ecx,%eax
cltd
idiv   %ebx
test   %edx,%edx
cmove  %edx,%esi
add    $0xffffffff,%edi
cmp    $0x3,%edi
ja     1180 <main+0x60>
cmp    $0x1,%esi
lea    0xe95(%rip),%rax
lea    0xea3(%rip),%rdi
cmove  %rax,%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [49 x i8] c"Please enter an integer that is greater than 1: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"The number is prime.\00"
@.str.3 = [25 x i8] c"The number is composite.\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 1, i32* %3
store i32 -1, i32* %1
br label %4
4: ; preds = %7, %0
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 2
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %4
10: ; preds = %4
%11 = load i32, i32* %1
%12 = sub nsw i32 %11, 1
store i32 %12, i32* %2
br label %13
13: ; preds = %22, %10
%14 = load i32, i32* %2
%15 = icmp sgt i32 %14, 1
br i1 %15, label %16, label %25
16: ; preds = %13
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = srem i32 %17, %18
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16
store i32 0, i32* %3
br label %22
22: ; preds = %21, %16
%23 = load i32, i32* %2
%24 = sub nsw i32 %23, 1
store i32 %24, i32* %2
br label %13
25: ; preds = %13
%26 = load i32, i32* %3
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %32
30: ; preds = %25
%31 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %32
32: ; preds = %30, %28
ret void
}

LLVM IR (-O2):
@.str = [49 x i8] c"Please enter an integer that is greater than 1: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"The number is prime.\00"
@.str.3 = [25 x i8] c"The number is composite.\00"
define void @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 -1, i32* %1
br label %5
3: ; preds = %5
%4 = icmp eq i32 %8, 2
br i1 %4, label %21, label %10
5: ; preds = %0, %5
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 2
br i1 %9, label %5, label %3
10: ; preds = %3, %10
%11 = phi i32 [ %13, %10 ], [ %8, %3 ]
%12 = phi i32 [ %16, %10 ], [ 1, %3 ]
%13 = add nsw i32 %11, -1
%14 = srem i32 %8, %13
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i32 0, i32 %12
%17 = icmp ugt i32 %11, 3
br i1 %17, label %10, label %18
18: ; preds = %10
%19 = icmp eq i32 %16, 1
%20 = select i1 %19, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0)
br label %21
21: ; preds = %18, %3
%22 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), %3 ], [ %20, %18 ]
%23 = call i32 @printf(i8* dereferenceable(1) %22)
ret void
}