#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 n) {
  int c = 0, i;
  for (i = 1; i <= n; i++) {
    if (i * i == n) {
      c = 1;
      break;
    }
  }
  if (n <= 0) {
    printf(
        "You can't input a negative or neutral number.It will show you 0.\n");
  }
  return c;
}


x86 assembly (clang, -O0):
<exact_square>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1164 <exact_square+0x54>
mov    -0xc(%rbp),%eax
imul   -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    1151 <exact_square+0x41>
movl   $0x1,-0x8(%rbp)
jmp    1164 <exact_square+0x54>
jmp    1156 <exact_square+0x46>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1129 <exact_square+0x19>
cmpl   $0x0,-0x4(%rbp)
jg     117a <exact_square+0x6a>
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exact_square>:
push   %rbx
test   %edi,%edi
jle    114f <exact_square+0x3f>
mov    %edi,%eax
neg    %eax
mov    $0x1,%ebx
mov    $0x1,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ecx,%edx
imul   %ecx,%edx
cmp    %edi,%edx
je     1149 <exact_square+0x39>
lea    (%rax,%rcx,1),%edx
add    $0x1,%edx
add    $0x1,%ecx
cmp    $0x1,%edx
jne    1130 <exact_square+0x20>
xor    %ebx,%ebx
test   %edi,%edi
jg     115d <exact_square+0x4d>
jmp    1151 <exact_square+0x41>
xor    %ebx,%ebx
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [66 x i8] c"You can't input a negative or neutral number.It will show you 0.\0A\00"
define i32 @exact_square(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 1, i32* %4
br label %5
5: ; preds = %17, %1
%6 = load i32, i32* %4
%7 = load i32, i32* %2
%8 = icmp sle i32 %6, %7
br i1 %8, label %9, label %20
9: ; preds = %5
%10 = load i32, i32* %4
%11 = load i32, i32* %4
%12 = mul nsw i32 %10, %11
%13 = load i32, i32* %2
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %9
store i32 1, i32* %3
br label %20
16: ; preds = %9
br label %17
17: ; preds = %16
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
br label %5
20: ; preds = %15, %5
%21 = load i32, i32* %2
%22 = icmp sle i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
br label %25
25: ; preds = %23, %20
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@str = [65 x i8] c"You can't input a negative or neutral number.It will show you 0.\00"
define i32 @exact_square(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %12, 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 ], [ 1, %1 ]
%8 = mul nsw i32 %7, %7
%9 = icmp eq i32 %8, %0
br i1 %9, label %10, label %3
10: ; preds = %3, %6
%11 = phi i32 [ 0, %3 ], [ 1, %6 ]
br i1 %2, label %12, label %15
12: ; preds = %1, %10
%13 = phi i32 [ %11, %10 ], [ 0, %1 ]
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str, i64 0, i64 0))
br label %15
15: ; preds = %12, %10
%16 = phi i32 [ %13, %12 ], [ %11, %10 ]
ret i32 %16
}