#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 sq) {
  float counter;
  counter = sq;
  while (counter != 0) {
    if (sq / counter == counter) {
      printf("1");
      break;
    }
    counter--;
  }
  if (counter == 0)
    printf("0");
  return 0;
}


x86 assembly (clang, -O0):
<exact_square>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cvtsi2ssl -0x4(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1141 <exact_square+0x31>
jp     1141 <exact_square+0x31>
jmp    1183 <exact_square+0x73>
cvtsi2ssl -0x4(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
jne    116c <exact_square+0x5c>
jp     116c <exact_square+0x5c>
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
jmp    1183 <exact_square+0x73>
movss  0xe8c(%rip),%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1125 <exact_square+0x15>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11a6 <exact_square+0x96>
jp     11a6 <exact_square+0x96>
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exact_square>:
push   %rax
cvtsi2ss %edi,%xmm0
test   %edi,%edi
je     114b <exact_square+0x3b>
movss  0xedf(%rip),%xmm1
xorps  %xmm2,%xmm2
movaps %xmm0,%xmm4
nopw   0x0(%rax,%rax,1)
movaps %xmm0,%xmm3
divss  %xmm4,%xmm3
ucomiss %xmm4,%xmm3
jne    113e <exact_square+0x2e>
jnp    1150 <exact_square+0x40>
addss  %xmm1,%xmm4
ucomiss %xmm2,%xmm4
jne    1130 <exact_square+0x20>
jp     1130 <exact_square+0x20>
jmp    1166 <exact_square+0x56>
movaps %xmm0,%xmm4
jmp    1166 <exact_square+0x56>
mov    $0x31,%edi
movss  %xmm4,0x4(%rsp)
call   1030 <putchar@plt>
movss  0x4(%rsp),%xmm4
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm4
jne    117a <exact_square+0x6a>
jp     117a <exact_square+0x6a>
mov    $0x30,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rcx
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 float
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = sitofp i32 %4 to float
store float %5, float* %3
br label %6
6: ; preds = %18, %1
%7 = load float, float* %3
%8 = fcmp une float %7, 0.000000e+00
br i1 %8, label %9, label %21
9: ; preds = %6
%10 = load i32, i32* %2
%11 = sitofp i32 %10 to float
%12 = load float, float* %3
%13 = fdiv float %11, %12
%14 = load float, float* %3
%15 = fcmp oeq float %13, %14
br i1 %15, label %16, label %18
16: ; preds = %9
%17 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %21
18: ; preds = %9
%19 = load float, float* %3
%20 = fadd float %19, -1.000000e+00
store float %20, float* %3
br label %6
21: ; preds = %16, %6
%22 = load float, float* %3
%23 = fcmp oeq float %22, 0.000000e+00
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %24, %21
ret i32 0
}

LLVM IR (-O2):
define i32 @exact_square(i32 %0) {
%2 = sitofp i32 %0 to float
%3 = icmp eq i32 %0, 0
br i1 %3, label %13, label %4
4: ; preds = %1, %10
%5 = phi float [ %11, %10 ], [ %2, %1 ]
%6 = fdiv float %2, %5
%7 = fcmp oeq float %6, %5
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @putchar(i32 49)
br label %13
10: ; preds = %4
%11 = fadd float %5, -1.000000e+00
%12 = fcmp une float %11, 0.000000e+00
br i1 %12, label %4, label %13
13: ; preds = %10, %1, %8
%14 = phi float [ %5, %8 ], [ %2, %1 ], [ %11, %10 ]
%15 = fcmp oeq float %14, 0.000000e+00
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @putchar(i32 48)
br label %18
18: ; preds = %16, %13
ret i32 0
}