#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 /*<<< orphan*/ printf(char *);
int exact_square(int number) {
  int counter, l = 0;
  for (counter = 0; counter <= number; counter++) {
    if (number == counter * counter) {
      l = 1;
      break;
    }
  }
  if (l == 1) {
    printf("1");
    return 1;
  } else {
    printf("0");
    return 0;
  }
}


x86 assembly (clang, -O0):
<exact_square>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1166 <exact_square+0x56>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0xc(%rbp),%ecx
cmp    %ecx,%eax
jne    1153 <exact_square+0x43>
movl   $0x1,-0x10(%rbp)
jmp    1166 <exact_square+0x56>
jmp    1158 <exact_square+0x48>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1129 <exact_square+0x19>
cmpl   $0x1,-0x10(%rbp)
jne    1188 <exact_square+0x78>
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    119b <exact_square+0x8b>
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exact_square>:
push   %rbx
mov    %edi,%eax
mov    $0x30,%edi
test   %eax,%eax
js     1140 <exact_square+0x30>
lea    0x1(%rax),%ecx
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %edx,%esi
imul   %edx,%esi
cmp    %eax,%esi
je     1144 <exact_square+0x34>
add    $0x1,%edx
cmp    %edx,%ecx
jne    1130 <exact_square+0x20>
xor    %ebx,%ebx
jmp    114e <exact_square+0x3e>
mov    $0x1,%ebx
mov    $0x31,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @exact_square(i32 %0) {
%2 = icmp slt i32 %0, 0
br i1 %2, label %10, label %6
3: ; preds = %6
%4 = add nuw i32 %7, 1
%5 = icmp eq i32 %7, %0
br i1 %5, label %10, label %6
6: ; preds = %1, %3
%7 = phi i32 [ %4, %3 ], [ 0, %1 ]
%8 = mul nsw i32 %7, %7
%9 = icmp eq i32 %8, %0
br i1 %9, label %10, label %3
10: ; preds = %3, %6, %1
%11 = phi i32 [ 48, %1 ], [ 49, %6 ], [ 48, %3 ]
%12 = phi i32 [ 0, %1 ], [ 1, %6 ], [ 0, %3 ]
%13 = tail call i32 @putchar(i32 %11)
ret i32 %12
}