#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 ceilingUp(int /*<<< orphan*/);
int /*<<< orphan*/ sqrt(unsigned long long);
unsigned long long int prime(unsigned long long int numCheck) {
  int primeNum = 0;
  if (numCheck <= 2) {
    primeNum = 1;
  } else {
    for (int i = 2; i < ceilingUp(sqrt(numCheck)); i++) {
      if (numCheck % i == 0) {
        primeNum = 0;
        break;
      } else {
        primeNum = 1;
      }
    }
  }
  return (primeNum);
}


x86 assembly (clang, -O0):
<prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpq   $0x2,-0x8(%rbp)
ja     114a <prime+0x2a>
movl   $0x1,-0xc(%rbp)
jmp    11b6 <prime+0x96>
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <sqrt@plt>
mov    %eax,%edi
call   1030 <ceilingUp@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    11b1 <prime+0x91>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
xor    %edx,%edx
div    %rcx
cmp    $0x0,%rdx
jne    1197 <prime+0x77>
movl   $0x0,-0xc(%rbp)
jmp    11b1 <prime+0x91>
movl   $0x1,-0xc(%rbp)
jmp    11a3 <prime+0x83>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1151 <prime+0x31>
jmp    11b6 <prime+0x96>
movslq -0xc(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prime>:
push   %r15
push   %r14
push   %rbx
mov    $0x1,%r14d
cmp    $0x3,%rdi
jb     119b <prime+0x7b>
mov    %rdi,%r15
call   1040 <sqrt@plt>
mov    %eax,%edi
call   1030 <ceilingUp@plt>
cmp    $0x3,%eax
jl     1198 <prime+0x78>
mov    $0x2,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r15,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     1170 <prime+0x50>
mov    %r15,%rax
xor    %edx,%edx
div    %rbx
test   %rdx,%rdx
jne    117c <prime+0x5c>
jmp    1198 <prime+0x78>
nopl   0x0(%rax,%rax,1)
mov    %r15d,%eax
xor    %edx,%edx
div    %ebx
test   %rdx,%rdx
je     1198 <prime+0x78>
add    $0x1,%rbx
mov    %r15,%rdi
call   1040 <sqrt@plt>
mov    %eax,%edi
call   1030 <ceilingUp@plt>
cltq
cmp    %rax,%rbx
jl     1150 <prime+0x30>
jmp    119b <prime+0x7b>
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @prime(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
store i64 %0, i64* %2
store i32 0, i32* %3
%5 = load i64, i64* %2
%6 = icmp ule i64 %5, 2
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 1, i32* %3
br label %28
8: ; preds = %1
store i32 2, i32* %4
br label %9
9: ; preds = %24, %8
%10 = load i32, i32* %4
%11 = load i64, i64* %2
%12 = call i32 @sqrt(i64 %11)
%13 = call i32 @ceilingUp(i32 %12)
%14 = icmp slt i32 %10, %13
br i1 %14, label %15, label %27
15: ; preds = %9
%16 = load i64, i64* %2
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = urem i64 %16, %18
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %15
store i32 0, i32* %3
br label %27
22: ; preds = %15
store i32 1, i32* %3
br label %23
23: ; preds = %22
br label %24
24: ; preds = %23
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %9
27: ; preds = %21, %9
br label %28
28: ; preds = %27, %7
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
ret i64 %30
}

LLVM IR (-O2):
define i64 @prime(i64 %0) {
%2 = icmp ult i64 %0, 3
br i1 %2, label %17, label %3
3: ; preds = %1
%4 = tail call i32 @sqrt(i64 %0)
%5 = tail call i32 @ceilingUp(i32 %4)
%6 = icmp sgt i32 %5, 2
br i1 %6, label %12, label %17
7: ; preds = %12
%8 = tail call i32 @sqrt(i64 %0)
%9 = tail call i32 @ceilingUp(i32 %8)
%10 = sext i32 %9 to i64
%11 = icmp slt i64 %16, %10
br i1 %11, label %12, label %17
12: ; preds = %3, %7
%13 = phi i64 [ %16, %7 ], [ 2, %3 ]
%14 = urem i64 %0, %13
%15 = icmp eq i64 %14, 0
%16 = add nuw nsw i64 %13, 1
br i1 %15, label %17, label %7
17: ; preds = %12, %7, %3, %1
%18 = phi i64 [ 1, %1 ], [ 0, %3 ], [ 0, %12 ], [ 1, %7 ]
ret i64 %18
}