#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 sqrt(size_t);
bool isPrimeNumber(size_t number) {
  size_t i;
  size_t max = sqrt(number) + 1;
  if (number == 1 || number == 2)
    return true;
  for (i = 2; i <= max; i++) {
    if (number % i == 0)
      return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<isPrimeNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <sqrt@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x1,-0x10(%rbp)
je     1144 <isPrimeNumber+0x34>
cmpq   $0x2,-0x10(%rbp)
jne    1150 <isPrimeNumber+0x40>
movl   $0x1,-0x4(%rbp)
jmp    11a5 <isPrimeNumber+0x95>
movq   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
ja     119e <isPrimeNumber+0x8e>
mov    -0x10(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
cmp    $0x0,%rdx
jne    1188 <isPrimeNumber+0x78>
movl   $0x0,-0x4(%rbp)
jmp    11a5 <isPrimeNumber+0x95>
jmp    118d <isPrimeNumber+0x7d>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1158 <isPrimeNumber+0x48>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isPrimeNumber>:
push   %rbx
mov    %rdi,%rbx
call   1030 <sqrt@plt>
lea    -0x1(%rbx),%rdx
mov    $0x1,%ecx
cmp    $0x2,%rdx
jb     1178 <isPrimeNumber+0x68>
add    $0x1,%eax
cmp    $0x2,%eax
jb     1178 <isPrimeNumber+0x68>
movslq %eax,%rsi
mov    $0x2,%edi
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rax
or     %rdi,%rax
shr    $0x20,%rax
je     1160 <isPrimeNumber+0x50>
mov    %rbx,%rax
xor    %edx,%edx
div    %rdi
test   %rdx,%rdx
jne    116b <isPrimeNumber+0x5b>
jmp    1176 <isPrimeNumber+0x66>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
xor    %edx,%edx
div    %edi
test   %rdx,%rdx
je     1176 <isPrimeNumber+0x66>
add    $0x1,%rdi
cmp    %rsi,%rdi
jbe    1140 <isPrimeNumber+0x30>
jmp    1178 <isPrimeNumber+0x68>
xor    %ecx,%ecx
mov    %ecx,%eax
pop    %rbx
ret

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

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