#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 pow(int, double);
int isPrime007(int n) {
  int i = 0;
  if (n < 4) {
    return 1;
  }
  if (!(n % 2)) {
    return 0;
  }
  for (i = 3; i <= pow(n, 0.5); i += 2) {
    if (!(n % i)) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    1138 <isPrime007+0x28>
movl   $0x1,-0x4(%rbp)
jmp    11b8 <isPrime007+0xa8>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1158 <isPrime007+0x48>
movl   $0x0,-0x4(%rbp)
jmp    11b8 <isPrime007+0xa8>
movl   $0x3,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
movsd  0xe90(%rip),%xmm0
call   1030 <pow@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jg     11b1 <isPrime007+0xa1>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    119e <isPrime007+0x8e>
movl   $0x0,-0x4(%rbp)
jmp    11b8 <isPrime007+0xa8>
jmp    11a3 <isPrime007+0x93>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    115f <isPrime007+0x4f>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %r14
push   %rbx
mov    $0x1,%r14d
cmp    $0x4,%edi
jl     116f <isPrime007+0x5f>
mov    %edi,%ebp
test   $0x1,%bpl
jne    112c <isPrime007+0x1c>
xor    %r14d,%r14d
jmp    116f <isPrime007+0x5f>
movsd  0xecc(%rip),%xmm0
mov    %ebp,%edi
call   1030 <pow@plt>
cmp    $0x3,%eax
jl     116f <isPrime007+0x5f>
mov    $0x3,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%eax
cltd
idiv   %ebx
test   %edx,%edx
je     1127 <isPrime007+0x17>
add    $0x2,%ebx
mov    %ebp,%edi
movsd  0xe9a(%rip),%xmm0
call   1030 <pow@plt>
cmp    %eax,%ebx
jle    1150 <isPrime007+0x40>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @isPrime007(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %4
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 4
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 1, i32* %2
br label %30
8: ; preds = %1
%9 = load i32, i32* %3
%10 = srem i32 %9, 2
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %8
store i32 0, i32* %2
br label %30
13: ; preds = %8
store i32 3, i32* %4
br label %14
14: ; preds = %26, %13
%15 = load i32, i32* %4
%16 = load i32, i32* %3
%17 = call i32 @pow(i32 %16, double 5.000000e-01)
%18 = icmp sle i32 %15, %17
br i1 %18, label %19, label %29
19: ; preds = %14
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = srem i32 %20, %21
%23 = icmp ne i32 %22, 0
br i1 %23, label %25, label %24
24: ; preds = %19
store i32 0, i32* %2
br label %30
25: ; preds = %19
br label %26
26: ; preds = %25
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 2
store i32 %28, i32* %4
br label %14
29: ; preds = %14
store i32 1, i32* %2
br label %30
30: ; preds = %29, %24, %12, %7
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
define i32 @isPrime007(i32 %0) {
%2 = icmp slt i32 %0, 4
br i1 %2, label %17, label %3
3: ; preds = %1
%4 = and i32 %0, 1
%5 = icmp eq i32 %4, 0
br i1 %5, label %17, label %6
6: ; preds = %3
%7 = tail call i32 @pow(i32 %0, double 5.000000e-01)
%8 = icmp slt i32 %7, 3
br i1 %8, label %17, label %12
9: ; preds = %12
%10 = tail call i32 @pow(i32 %0, double 5.000000e-01)
%11 = icmp sgt i32 %16, %10
br i1 %11, label %17, label %12
12: ; preds = %6, %9
%13 = phi i32 [ %16, %9 ], [ 3, %6 ]
%14 = srem i32 %0, %13
%15 = icmp eq i32 %14, 0
%16 = add nuw nsw i32 %13, 2
br i1 %15, label %17, label %9
17: ; preds = %12, %9, %6, %3, %1
%18 = phi i32 [ 1, %1 ], [ 0, %3 ], [ 1, %6 ], [ 0, %12 ], [ 1, %9 ]
ret i32 %18
}