#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 */
scalar_t__ sqrt(int);
int naivePrime(int number) {
  long i, rac = (int)sqrt(number) + 1;
  if (number % 2 == 0)
    return 0;
  for (i = 3; i < rac; i += 2) {
    if (number % i == 0)
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<naivePrime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <sqrt@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    114c <naivePrime+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    119f <naivePrime+0x8f>
movq   $0x3,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    1198 <naivePrime+0x88>
movslq -0x8(%rbp),%rax
cqto
idivq  -0x10(%rbp)
cmp    $0x0,%rdx
jne    1182 <naivePrime+0x72>
movl   $0x0,-0x4(%rbp)
jmp    119f <naivePrime+0x8f>
jmp    1187 <naivePrime+0x77>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
jmp    1154 <naivePrime+0x44>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<naivePrime>:
push   %rbx
mov    %edi,%ebx
call   1030 <sqrt@plt>
xor    %r8d,%r8d
test   $0x1,%bl
je     1199 <naivePrime+0x89>
shl    $0x20,%rax
movabs $0x100000000,%rdi
add    %rax,%rdi
mov    $0x1,%r8d
movabs $0x300000001,%rax
cmp    %rax,%rdi
jl     1199 <naivePrime+0x89>
sar    $0x20,%rdi
movslq %ebx,%rsi
mov    $0x3,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rsi,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     1180 <naivePrime+0x70>
mov    %rsi,%rax
cqto
idiv   %rcx
test   %rdx,%rdx
jne    118b <naivePrime+0x7b>
jmp    1196 <naivePrime+0x86>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
test   %rdx,%rdx
je     1196 <naivePrime+0x86>
add    $0x2,%rcx
cmp    %rdi,%rcx
jl     1160 <naivePrime+0x50>
jmp    1199 <naivePrime+0x89>
xor    %r8d,%r8d
mov    %r8d,%eax
pop    %rbx
ret

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

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