#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__ is_perfect_square(int);
int /*<<< orphan*/ printf(char *, int);
int sqrt_period(int);
int main(int argc, char *argv[]) {
  int count = 0;
  for (int n = 2; n <= 10000; n++) {
    if (is_perfect_square(n))
      continue;
    int period = sqrt_period(n);
    if (period % 2 == 1)
      count++;
  }
  printf("%i", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
cmpl   $0x2710,-0x18(%rbp)
jg     11b3 <main+0x83>
mov    -0x18(%rbp),%edi
call   1050 <is_perfect_square@plt>
cmp    $0x0,%rax
je     1178 <main+0x48>
jmp    11a5 <main+0x75>
mov    -0x18(%rbp),%edi
call   1030 <sqrt_period@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    11a0 <main+0x70>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a5 <main+0x75>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1154 <main+0x24>
mov    -0x14(%rbp),%esi
lea    0xe43(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x2,%ebp
xor    %ebx,%ebx
jmp    114b <main+0x1b>
nopl   0x0(%rax)
add    $0x1,%ebp
cmp    $0x2711,%ebp
je     1176 <main+0x46>
mov    %ebp,%edi
call   1050 <is_perfect_square@plt>
test   %rax,%rax
jne    1140 <main+0x10>
mov    %ebp,%edi
call   1030 <sqrt_period@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
xor    %ecx,%ecx
cmp    $0x1,%eax
sete   %cl
add    %ecx,%ebx
jmp    1140 <main+0x10>
lea    0xe83(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%i\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 2, i32* %7
br label %9
9: ; preds = %27, %2
%10 = load i32, i32* %7
%11 = icmp sle i32 %10, 10000
br i1 %11, label %12, label %30
12: ; preds = %9
%13 = load i32, i32* %7
%14 = call i64 @is_perfect_square(i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
br label %27
17: ; preds = %12
%18 = load i32, i32* %7
%19 = call i32 @sqrt_period(i32 %18)
store i32 %19, i32* %8
%20 = load i32, i32* %8
%21 = srem i32 %20, 2
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %26
23: ; preds = %17
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %26
26: ; preds = %23, %17
br label %27
27: ; preds = %26, %16
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %9
30: ; preds = %9
%31 = load i32, i32* %6
%32 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %5
3: ; preds = %16
%4 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %17)
ret i32 0
5: ; preds = %2, %16
%6 = phi i32 [ 0, %2 ], [ %17, %16 ]
%7 = phi i32 [ 2, %2 ], [ %18, %16 ]
%8 = tail call i64 @is_perfect_square(i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %5
%11 = tail call i32 @sqrt_period(i32 %7)
%12 = srem i32 %11, 2
%13 = icmp eq i32 %12, 1
%14 = zext i1 %13 to i32
%15 = add nsw i32 %6, %14
br label %16
16: ; preds = %5, %10
%17 = phi i32 [ %6, %5 ], [ %15, %10 ]
%18 = add nuw nsw i32 %7, 1
%19 = icmp eq i32 %18, 10001
br i1 %19, label %3, label %5
}