#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 *);
int main() {
  int numero, c, p = 1;
  printf("Informe um numero positivo: ");
  scanf("%d", &numero);
  c = 1;
  while (p < numero) {
    c++;
    p = c * c;
  }
  if (p == numero) {
    printf("\nO numero %d eh quadrado perfeito.\n", numero);
  } else {
    printf("\nO numero %d nao eh quadrado perfeito.\n", numero);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    117f <main+0x5f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    115b <main+0x3b>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11a1 <main+0x81>
mov    -0x8(%rbp),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b2 <main+0x92>
mov    -0x8(%rbp),%esi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee7(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
mov    $0x1,%eax
cmp    $0x2,%esi
jl     116c <main+0x4c>
mov    $0x2,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ecx,%eax
imul   %ecx,%eax
add    $0x1,%ecx
cmp    %esi,%eax
jl     1160 <main+0x40>
cmp    %esi,%eax
lea    0xeab(%rip),%rax
lea    0xec8(%rip),%rdi
cmove  %rax,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Informe um numero positivo: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [36 x i8] c"\0AO numero %d eh quadrado perfeito.\0A\00"
@.str.3 = [40 x i8] c"\0AO numero %d nao eh quadrado perfeito.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %7
7: ; preds = %11, %0
%8 = load i32, i32* %4
%9 = load i32, i32* %2
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %17
11: ; preds = %7
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = load i32, i32* %3
%16 = mul nsw i32 %14, %15
store i32 %16, i32* %4
br label %7
17: ; preds = %7
%18 = load i32, i32* %4
%19 = load i32, i32* %2
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i32, i32* %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %22)
br label %27
24: ; preds = %17
%25 = load i32, i32* %2
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %24, %21
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"Informe um numero positivo: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [36 x i8] c"\0AO numero %d eh quadrado perfeito.\0A\00"
@.str.3 = [40 x i8] c"\0AO numero %d nao eh quadrado perfeito.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 1
br i1 %6, label %7, label %12
7: ; preds = %0, %7
%8 = phi i32 [ %9, %7 ], [ 1, %0 ]
%9 = add nuw nsw i32 %8, 1
%10 = mul nsw i32 %9, %9
%11 = icmp slt i32 %10, %5
br i1 %11, label %7, label %12
12: ; preds = %7, %0
%13 = phi i32 [ 1, %0 ], [ %10, %7 ]
%14 = icmp eq i32 %13, %5
%15 = select i1 %14, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %15, i32 %5)
ret i32 0
}