#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);
void noobPrime(int num) {
  int flag = 1, iterator;
  if (num <= 2) {
    flag = 1;
  }
  for (iterator = 2; iterator < num; iterator++) {
    if (num % iterator == 0) {
      flag = 0;
      break;
    }
  }
  if (flag == 1) {
    printf("num: %d is prime", num);
  } else
    printf("num:%d is not prime", num);
}


x86 assembly (clang, -O0):
<noobPrime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x2,-0x4(%rbp)
jg     1133 <noobPrime+0x23>
movl   $0x1,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1175 <noobPrime+0x65>
mov    -0x4(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1162 <noobPrime+0x52>
movl   $0x0,-0x8(%rbp)
jmp    1175 <noobPrime+0x65>
jmp    1167 <noobPrime+0x57>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113a <noobPrime+0x2a>
cmpl   $0x1,-0x8(%rbp)
jne    1193 <noobPrime+0x83>
mov    -0x4(%rbp),%esi
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
jmp    11a2 <noobPrime+0x92>
mov    -0x4(%rbp),%esi
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<noobPrime>:
mov    %edi,%esi
lea    0xee7(%rip),%rdi
cmp    $0x3,%esi
jl     1140 <noobPrime+0x30>
mov    $0x2,%ecx
lea    0xee7(%rip),%r8
nopw   0x0(%rax,%rax,1)
mov    %esi,%eax
cltd
idiv   %ecx
test   %edx,%edx
je     1145 <noobPrime+0x35>
add    $0x1,%ecx
cmp    %ecx,%esi
jne    1130 <noobPrime+0x20>
jmp    1030 <printf@plt>
mov    %r8,%rdi
jmp    1030 <printf@plt>

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

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