#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 _isqrt(long);
long _prime(long EV_a) {
  long EV_max;
  long EV_divisor;
  long EV_remainder;
  if ((EV_a < 2)) {
    return 0;
  } else {
    EV_max = _isqrt(EV_a);
    EV_divisor = 2;
    while ((EV_divisor <= EV_max)) {
      EV_remainder = (EV_a - ((EV_a / EV_divisor) * EV_divisor));
      if ((EV_remainder == 0)) {
        return 0;
      }
      EV_divisor = (EV_divisor + 1);
    }
    return 1;
  }
}


x86 assembly (clang, -O0):
<_prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x2,-0x10(%rbp)
jge    1134 <_prime+0x24>
movq   $0x0,-0x8(%rbp)
jmp    11ad <_prime+0x9d>
mov    -0x10(%rbp),%rdi
call   1030 <_isqrt@plt>
mov    %rax,-0x18(%rbp)
movq   $0x2,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jg     11a5 <_prime+0x95>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
cqto
idivq  -0x20(%rbp)
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
imul   -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1194 <_prime+0x84>
movq   $0x0,-0x8(%rbp)
jmp    11ad <_prime+0x9d>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1149 <_prime+0x39>
movq   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_prime>:
push   %rbx
cmp    $0x2,%rdi
jge    111b <_prime+0xb>
xor    %ecx,%ecx
jmp    1182 <_prime+0x72>
mov    %rdi,%rbx
call   1030 <_isqrt@plt>
mov    $0x1,%ecx
cmp    $0x2,%rax
jl     1182 <_prime+0x72>
mov    $0x1,%esi
sub    %rax,%rsi
mov    $0x2,%edi
xor    %ecx,%ecx
nopl   (%rax)
mov    %rbx,%rax
or     %rdi,%rax
shr    $0x20,%rax
je     1160 <_prime+0x50>
mov    %rbx,%rax
cqto
idiv   %rdi
test   %rdx,%rdx
jne    116b <_prime+0x5b>
jmp    1182 <_prime+0x72>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
xor    %edx,%edx
div    %edi
test   %rdx,%rdx
je     1182 <_prime+0x72>
lea    (%rsi,%rdi,1),%rax
add    $0x1,%rax
add    $0x1,%rdi
cmp    $0x2,%rax
jne    1140 <_prime+0x30>
mov    $0x1,%ecx
mov    %rcx,%rax
pop    %rbx
ret

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

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