#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 */
long sqrt(unsigned long);
unsigned short int isPrime(unsigned long int number) {
  for (long i = 2; i < sqrt(number); i++)
    if (number % i == 0)
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<isPrime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <sqrt@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jge    117c <isPrime+0x6c>
mov    -0x10(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
cmp    $0x0,%rdx
jne    1166 <isPrime+0x56>
movw   $0x0,-0x2(%rbp)
jmp    1182 <isPrime+0x72>
jmp    116b <isPrime+0x5b>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1124 <isPrime+0x14>
movw   $0x1,-0x2(%rbp)
movzwl -0x2(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isPrime>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1030 <sqrt@plt>
mov    $0x1,%r14w
cmp    $0x3,%rax
jl     1171 <isPrime+0x61>
mov    $0x2,%ebp
nopl   0x0(%rax)
mov    %rbx,%rax
or     %rbp,%rax
shr    $0x20,%rax
je     1150 <isPrime+0x40>
mov    %rbx,%rax
xor    %edx,%edx
div    %rbp
test   %rdx,%rdx
jne    115b <isPrime+0x4b>
jmp    116e <isPrime+0x5e>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
xor    %edx,%edx
div    %ebp
test   %rdx,%rdx
je     116e <isPrime+0x5e>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <sqrt@plt>
cmp    %rax,%rbp
jl     1130 <isPrime+0x20>
jmp    1171 <isPrime+0x61>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define zeroext i16 @isPrime(i64 %0) {
%2 = alloca i16
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
store i64 2, i64* %4
br label %5
5: ; preds = %17, %1
%6 = load i64, i64* %4
%7 = load i64, i64* %3
%8 = call i64 @sqrt(i64 %7)
%9 = icmp slt i64 %6, %8
br i1 %9, label %10, label %20
10: ; preds = %5
%11 = load i64, i64* %3
%12 = load i64, i64* %4
%13 = urem i64 %11, %12
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %10
store i16 0, i16* %2
br label %21
16: ; preds = %10
br label %17
17: ; preds = %16
%18 = load i64, i64* %4
%19 = add nsw i64 %18, 1
store i64 %19, i64* %4
br label %5
20: ; preds = %5
store i16 1, i16* %2
br label %21
21: ; preds = %20, %15
%22 = load i16, i16* %2
ret i16 %22
}

LLVM IR (-O2):
define zeroext i16 @isPrime(i64 %0) {
%2 = tail call i64 @sqrt(i64 %0)
%3 = icmp sgt i64 %2, 2
br i1 %3, label %7, label %12
4: ; preds = %7
%5 = tail call i64 @sqrt(i64 %0)
%6 = icmp slt i64 %11, %5
br i1 %6, label %7, label %12
7: ; preds = %1, %4
%8 = phi i64 [ %11, %4 ], [ 2, %1 ]
%9 = urem i64 %0, %8
%10 = icmp eq i64 %9, 0
%11 = add nuw nsw i64 %8, 1
br i1 %10, label %12, label %4
12: ; preds = %4, %7, %1
%13 = phi i16 [ 1, %1 ], [ 0, %7 ], [ 1, %4 ]
ret i16 %13
}