#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 checkIfPrime(int numberToCheck) {
  int flag = 0;
  int i = 2;
  if (numberToCheck == 0 || numberToCheck == 1) {
    printf("%d is not a prime\n", numberToCheck);
    return;
  }
  for (i = 2; i <= numberToCheck / 2; i++) {
    if (numberToCheck % i == 0) {
      flag = 1;
      break;
    }
  }
  if (flag == 0) {
    printf("\n%d is prime\n", numberToCheck);
  } else {
    printf("%d is not a prime number", numberToCheck);
  }
}


x86 assembly (clang, -O0):
<checkIfPrime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     113d <checkIfPrime+0x2d>
cmpl   $0x1,-0x4(%rbp)
jne    1151 <checkIfPrime+0x41>
mov    -0x4(%rbp),%esi
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
jmp    11d2 <checkIfPrime+0xc2>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jg     11a5 <checkIfPrime+0x95>
mov    -0x4(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1192 <checkIfPrime+0x82>
movl   $0x1,-0x8(%rbp)
jmp    11a5 <checkIfPrime+0x95>
jmp    1197 <checkIfPrime+0x87>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1158 <checkIfPrime+0x48>
cmpl   $0x0,-0x8(%rbp)
jne    11c3 <checkIfPrime+0xb3>
mov    -0x4(%rbp),%esi
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
jmp    11d2 <checkIfPrime+0xc2>
mov    -0x4(%rbp),%esi
lea    0xe54(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkIfPrime>:
mov    %edi,%esi
cmp    $0x2,%edi
jae    1123 <checkIfPrime+0x13>
lea    0xee2(%rip),%rdi
jmp    1030 <printf@plt>
lea    0xee9(%rip),%rdi
cmp    $0x4,%esi
jl     1168 <checkIfPrime+0x58>
mov    %esi,%r9d
shr    %r9d
neg    %r9d
mov    $0x2,%ecx
lea    0xedd(%rip),%r8
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %esi,%eax
cltd
idiv   %ecx
test   %edx,%edx
je     116d <checkIfPrime+0x5d>
lea    (%r9,%rcx,1),%eax
add    $0x1,%eax
add    $0x1,%ecx
cmp    $0x1,%eax
jne    1150 <checkIfPrime+0x40>
jmp    1030 <printf@plt>
mov    %r8,%rdi
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [19 x i8] c"%d is not a prime\0A\00"
@.str.1 = [14 x i8] c"\0A%d is prime\0A\00"
@.str.2 = [25 x i8] c"%d is not a prime number\00"
define void @checkIfPrime(i32 %0) {
%2 = icmp ult i32 %0, 2
br i1 %2, label %14, label %3
3: ; preds = %1
%4 = icmp slt i32 %0, 4
br i1 %4, label %14, label %5
5: ; preds = %3
%6 = lshr i32 %0, 1
br label %10
7: ; preds = %10
%8 = add nuw nsw i32 %11, 1
%9 = icmp eq i32 %11, %6
br i1 %9, label %14, label %10
10: ; preds = %5, %7
%11 = phi i32 [ %8, %7 ], [ 2, %5 ]
%12 = srem i32 %0, %11
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %7
14: ; preds = %10, %7, %3, %1
%15 = phi i8* [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), %7 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), %10 ]
%16 = tail call i32 @printf(i8* %15, i32 %0)
ret void
}