#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 check_prime(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, j;
  printf("Part A: \n");
  printf("Enter a Positive Number: ");
  scanf("%d", &n);
  if (check_prime(n) == 1)
    printf("It's A Prime Number!!! \n");
  else
    printf("Not A Prime Number!!! \n");
  printf("Part B: \n");
  for (j = 100; j <= 200; j++)
    if (check_prime(j))
      printf("%d \n", j);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1030 <check_prime@plt>
cmp    $0x1,%eax
jne    118f <main+0x5f>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    119d <main+0x6d>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x64,-0xc(%rbp)
cmpl   $0xc8,-0xc(%rbp)
jg     11f4 <main+0xc4>
mov    -0xc(%rbp),%edi
call   1030 <check_prime@plt>
cmp    $0x0,%eax
je     11e1 <main+0xb1>
mov    -0xc(%rbp),%esi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e6 <main+0xb6>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b2 <main+0x82>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xed7(%rip),%rdi
call   1040 <puts@plt>
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%edi
call   1030 <check_prime@plt>
cmp    $0x1,%eax
lea    0xec9(%rip),%rax
lea    0xea2(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
lea    0xea9(%rip),%rdi
call   1040 <puts@plt>
mov    $0x64,%ebx
lea    0xe73(%rip),%r14
jmp    11bb <main+0x7b>
nopl   0x0(%rax)
add    $0x1,%ebx
cmp    $0xc9,%ebx
je     11d4 <main+0x94>
mov    %ebx,%edi
call   1030 <check_prime@plt>
test   %eax,%eax
je     11b0 <main+0x70>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11b0 <main+0x70>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Part A: \0A\00"
@.str.1 = [26 x i8] c"Enter a Positive Number: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [25 x i8] c"It's A Prime Number!!! \0A\00"
@.str.4 = [24 x i8] c"Not A Prime Number!!! \0A\00"
@.str.5 = [10 x i8] c"Part B: \0A\00"
@.str.6 = [5 x i8] c"%d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = call i32 @check_prime(i32 %7)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %14
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %14
14: ; preds = %12, %10
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
store i32 100, i32* %3
br label %16
16: ; preds = %27, %14
%17 = load i32, i32* %3
%18 = icmp sle i32 %17, 200
br i1 %18, label %19, label %30
19: ; preds = %16
%20 = load i32, i32* %3
%21 = call i32 @check_prime(i32 %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i32, i32* %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %23, %19
br label %27
27: ; preds = %26
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %16
30: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [26 x i8] c"Enter a Positive Number: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.6 = [5 x i8] c"%d \0A\00"
@str = [9 x i8] c"Part A: \00"
@str.7 = [23 x i8] c"Not A Prime Number!!! \00"
@str.8 = [9 x i8] c"Part B: \00"
@str.9 = [24 x i8] c"It's A 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 ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = call i32 @check_prime(i32 %6)
%8 = icmp eq i32 %7, 1
%9 = select i1 %8, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @str.9, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @str.7, i64 0, i64 0)
%10 = call i32 @puts(i8* dereferenceable(1) %9)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.8, i64 0, i64 0))
br label %12
12: ; preds = %0, %18
%13 = phi i32 [ 100, %0 ], [ %19, %18 ]
%14 = call i32 @check_prime(i32 %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 %13)
br label %18
18: ; preds = %12, %16
%19 = add nuw nsw i32 %13, 1
%20 = icmp eq i32 %19, 201
br i1 %20, label %21, label %12
21: ; preds = %18
ret i32 0
}