#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 /*<<< orphan*/ scanf(char *, int *);
void exact_square(void) {
  int x;
  scanf("%d", &x);
  printf("\n");
  int n = 1;
  while (n < x) {
    if (x == n * n) {
      printf("1");
      return;
    }
    n++;
  }
  printf("0");
}


x86 assembly (clang, -O0):
<exact_square>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1188 <exact_square+0x68>
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
imul   -0x8(%rbp),%ecx
cmp    %ecx,%eax
jne    117a <exact_square+0x5a>
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
jmp    1194 <exact_square+0x74>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114b <exact_square+0x2b>
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exact_square>:
push   %rax
lea    0xed8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
mov    $0x30,%edi
cmp    $0x2,%eax
jl     1167 <exact_square+0x47>
mov    $0x1,%ecx
nop
mov    %ecx,%edx
imul   %ecx,%edx
cmp    %edx,%eax
je     1162 <exact_square+0x42>
add    $0x1,%ecx
cmp    %ecx,%eax
jne    1150 <exact_square+0x30>
jmp    1167 <exact_square+0x47>
mov    $0x31,%edi
call   1030 <putchar@plt>
pop    %rax
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @exact_square() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = call i32 @putchar(i32 10)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 1
br i1 %6, label %9, label %14
7: ; preds = %9
%8 = icmp eq i32 %13, %5
br i1 %8, label %14, label %9
9: ; preds = %0, %7
%10 = phi i32 [ %13, %7 ], [ 1, %0 ]
%11 = mul nsw i32 %10, %10
%12 = icmp eq i32 %5, %11
%13 = add nuw nsw i32 %10, 1
br i1 %12, label %14, label %7
14: ; preds = %7, %9, %0
%15 = phi i32 [ 48, %0 ], [ 49, %9 ], [ 48, %7 ]
%16 = call i32 @putchar(i32 %15)
ret void
}