#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(double);
int HashedTbl_isPrime(int n) {
  int divisor;
  int prime = 1;
  int limit;
  double input;
  input = n * 1.0;
  limit = (int)(sqrt(input));
  for (divisor = 2; divisor <= limit; divisor++) {
    if ((n % divisor) == 0) {
      prime = 0;
      break;
    }
  }
  return (prime);
}


x86 assembly (clang, -O0):
<HashedTbl_isPrime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xed1(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <sqrt@plt>
mov    %eax,-0x10(%rbp)
movl   $0x2,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1187 <HashedTbl_isPrime+0x77>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    1174 <HashedTbl_isPrime+0x64>
movl   $0x0,-0xc(%rbp)
jmp    1187 <HashedTbl_isPrime+0x77>
jmp    1179 <HashedTbl_isPrime+0x69>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114c <HashedTbl_isPrime+0x3c>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HashedTbl_isPrime>:
push   %rbx
mov    %edi,%ebx
cvtsi2sd %edi,%xmm0
call   1030 <sqrt@plt>
mov    %rax,%rsi
mov    $0x1,%ecx
cmp    $0x2,%esi
jl     114f <HashedTbl_isPrime+0x3f>
neg    %esi
mov    $0x2,%edi
mov    %ebx,%eax
cltd
idiv   %edi
test   %edx,%edx
je     114d <HashedTbl_isPrime+0x3d>
lea    (%rsi,%rdi,1),%eax
add    $0x1,%eax
mov    %edi,%edx
add    $0x1,%edx
mov    %edx,%edi
cmp    $0x1,%eax
jne    1130 <HashedTbl_isPrime+0x20>
jmp    114f <HashedTbl_isPrime+0x3f>
xor    %ecx,%ecx
mov    %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @HashedTbl_isPrime(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
store i32 %0, i32* %2
store i32 1, i32* %4
%7 = load i32, i32* %2
%8 = sitofp i32 %7 to double
%9 = fmul double %8, 1.000000e+00
store double %9, double* %6
%10 = load double, double* %6
%11 = call i64 @sqrt(double %10)
%12 = trunc i64 %11 to i32
store i32 %12, i32* %5
store i32 2, i32* %3
br label %13
13: ; preds = %24, %1
%14 = load i32, i32* %3
%15 = load i32, i32* %5
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %27
17: ; preds = %13
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = srem i32 %18, %19
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %17
store i32 0, i32* %4
br label %27
23: ; preds = %17
br label %24
24: ; preds = %23
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %13
27: ; preds = %22, %13
%28 = load i32, i32* %4
ret i32 %28
}

LLVM IR (-O2):
define i32 @HashedTbl_isPrime(i32 %0) {
%2 = sitofp i32 %0 to double
%3 = tail call i64 @sqrt(double %2)
%4 = trunc i64 %3 to i32
%5 = icmp slt i32 %4, 2
br i1 %5, label %13, label %9
6: ; preds = %9
%7 = add nuw i32 %10, 1
%8 = icmp eq i32 %10, %4
br i1 %8, label %13, label %9
9: ; preds = %1, %6
%10 = phi i32 [ %7, %6 ], [ 2, %1 ]
%11 = srem i32 %0, %10
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %6
13: ; preds = %6, %9, %1
%14 = phi i32 [ 1, %1 ], [ 0, %9 ], [ 1, %6 ]
ret i32 %14
}