#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;
  for (int 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)
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     1176 <checkIfPrime+0x66>
mov    -0x4(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1163 <checkIfPrime+0x53>
movl   $0x1,-0x8(%rbp)
jmp    1176 <checkIfPrime+0x66>
jmp    1168 <checkIfPrime+0x58>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1129 <checkIfPrime+0x19>
cmpl   $0x0,-0x8(%rbp)
jne    1194 <checkIfPrime+0x84>
mov    -0x4(%rbp),%esi
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
jmp    11a3 <checkIfPrime+0x93>
mov    -0x4(%rbp),%esi
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkIfPrime>:
mov    %edi,%r9d
lea    0xee6(%rip),%rdi
cmp    $0x4,%r9d
jl     115c <checkIfPrime+0x4c>
mov    %r9d,%ecx
shr    %ecx
neg    %ecx
mov    $0x2,%esi
lea    0xedb(%rip),%r8
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r9d,%eax
cltd
idiv   %esi
test   %edx,%edx
je     1164 <checkIfPrime+0x54>
lea    (%rcx,%rsi,1),%eax
add    $0x1,%eax
mov    %esi,%edx
add    $0x1,%edx
mov    %edx,%esi
cmp    $0x1,%eax
jne    1140 <checkIfPrime+0x30>
mov    %r9d,%esi
jmp    1030 <printf@plt>
mov    %r8,%rdi
mov    %r9d,%esi
jmp    1030 <printf@plt>

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

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