#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 sqrt(int);
int isSquareFree(int n) {
  if (n % 2 == 0)
    n /= 2;
  if (n % 2 == 0)
    return 0;
  int i;
  for (i = 3; i <= sqrt(n); i += 2) {
    if (n % i == 0) {
      n /= i;
      if (n % i == 0)
        return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<isSquareFree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    113d <isSquareFree+0x2d>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    115d <isSquareFree+0x4d>
movl   $0x0,-0x4(%rbp)
jmp    11d6 <isSquareFree+0xc6>
movl   $0x3,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <sqrt@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jg     11cf <isSquareFree+0xbf>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11bc <isSquareFree+0xac>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11b7 <isSquareFree+0xa7>
movl   $0x0,-0x4(%rbp)
jmp    11d6 <isSquareFree+0xc6>
jmp    11bc <isSquareFree+0xac>
jmp    11c1 <isSquareFree+0xb1>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    1164 <isSquareFree+0x54>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isSquareFree>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
test   $0x1,%bpl
jne    1127 <isSquareFree+0x17>
mov    %ebp,%eax
shr    $0x1f,%eax
add    %ebp,%eax
sar    %eax
mov    %eax,%ebp
xor    %r14d,%r14d
test   $0x1,%bpl
je     1142 <isSquareFree+0x32>
mov    %ebp,%edi
call   1030 <sqrt@plt>
cmp    $0x3,%eax
jge    114a <isSquareFree+0x3a>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x3,%ebx
jmp    116e <isSquareFree+0x5e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x2,%ebx
mov    %ebp,%edi
call   1030 <sqrt@plt>
cmp    %eax,%ebx
jg     113c <isSquareFree+0x2c>
mov    %ebp,%eax
cltd
idiv   %ebx
test   %edx,%edx
jne    1160 <isSquareFree+0x50>
mov    %eax,%ecx
cltd
idiv   %ebx
mov    %ecx,%ebp
test   %edx,%edx
jne    1160 <isSquareFree+0x50>
jmp    1142 <isSquareFree+0x32>

LLVM IR (-O0):
define i32 @isSquareFree(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = srem i32 %5, 2
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32, i32* %3
%10 = sdiv i32 %9, 2
store i32 %10, i32* %3
br label %11
11: ; preds = %8, %1
%12 = load i32, i32* %3
%13 = srem i32 %12, 2
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11
store i32 0, i32* %2
br label %42
16: ; preds = %11
store i32 3, i32* %4
br label %17
17: ; preds = %38, %16
%18 = load i32, i32* %4
%19 = load i32, i32* %3
%20 = call i32 @sqrt(i32 %19)
%21 = icmp sle i32 %18, %20
br i1 %21, label %22, label %41
22: ; preds = %17
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = srem i32 %23, %24
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %37
27: ; preds = %22
%28 = load i32, i32* %4
%29 = load i32, i32* %3
%30 = sdiv i32 %29, %28
store i32 %30, i32* %3
%31 = load i32, i32* %3
%32 = load i32, i32* %4
%33 = srem i32 %31, %32
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %27
store i32 0, i32* %2
br label %42
36: ; preds = %27
br label %37
37: ; preds = %36, %22
br label %38
38: ; preds = %37
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 2
store i32 %40, i32* %4
br label %17
41: ; preds = %17
store i32 1, i32* %2
br label %42
42: ; preds = %41, %35, %15
%43 = load i32, i32* %2
ret i32 %43
}

LLVM IR (-O2):
define i32 @isSquareFree(i32 %0) {
%2 = and i32 %0, 1
%3 = icmp eq i32 %2, 0
%4 = sdiv i32 %0, 2
%5 = select i1 %3, i32 %4, i32 %0
%6 = and i32 %5, 1
%7 = icmp eq i32 %6, 0
br i1 %7, label %25, label %8
8: ; preds = %1
%9 = tail call i32 @sqrt(i32 %5)
%10 = icmp slt i32 %9, 3
br i1 %10, label %25, label %11
11: ; preds = %8, %20
%12 = phi i32 [ %22, %20 ], [ 3, %8 ]
%13 = phi i32 [ %21, %20 ], [ %5, %8 ]
%14 = srem i32 %13, %12
%15 = sdiv i32 %13, %12
%16 = icmp eq i32 %14, 0
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = srem i32 %15, %12
%19 = icmp eq i32 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %11, %17
%21 = phi i32 [ %15, %17 ], [ %13, %11 ]
%22 = add nuw nsw i32 %12, 2
%23 = tail call i32 @sqrt(i32 %21)
%24 = icmp sgt i32 %22, %23
br i1 %24, label %25, label %11
25: ; preds = %20, %17, %8, %1
%26 = phi i32 [ 0, %1 ], [ 1, %8 ], [ 1, %20 ], [ 0, %17 ]
ret i32 %26
}