#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, int, int, int);
int sqrt(int);
int main() {
  int i;
  for (i = 1000; i <= 9999; i++) {
    if (sqrt(i) == (int)sqrt(i) && i / 100 + i % 100 == sqrt(i)) {
      printf("%d+%02d=(%.0lf)^2=%d\n", i / 100, i % 100, sqrt(i), i);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3e8,-0x8(%rbp)
cmpl   $0x270f,-0x8(%rbp)
jg     11e8 <main+0xc8>
mov    -0x8(%rbp),%edi
call   1040 <sqrt@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <sqrt@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
cmp    %ecx,%eax
jne    11d5 <main+0xb5>
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    -0x14(%rbp),%eax
add    %edx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <sqrt@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jne    11d5 <main+0xb5>
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <sqrt@plt>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    %eax,%ecx
mov    -0x8(%rbp),%r8d
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
jmp    11da <main+0xba>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x3e8,%ebx
lea    0xecd(%rip),%r14
jmp    114b <main+0x2b>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebx
cmp    $0x2710,%ebx
je     11ae <main+0x8e>
mov    %ebx,%edi
call   1040 <sqrt@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1040 <sqrt@plt>
cmp    %eax,%ebp
jne    1140 <main+0x20>
mov    %ebx,%eax
imul   $0x51eb851f,%rax,%r15
shr    $0x25,%r15
imul   $0xffffff9d,%r15d,%ebp
add    %ebx,%ebp
mov    %ebx,%edi
call   1040 <sqrt@plt>
cmp    %eax,%ebp
jne    1140 <main+0x20>
imul   $0xffffff9c,%r15d,%r15d
movzwl %bx,%eax
shr    $0x2,%eax
imul   $0x147b,%eax,%ebp
shr    $0x11,%ebp
add    %ebx,%r15d
mov    %ebx,%edi
call   1040 <sqrt@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %eax,%ecx
mov    %ebx,%r8d
call   1030 <printf@plt>
jmp    1140 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"%d+%02d=(%.0lf)^2=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 1000, i32* %2
br label %3
3: ; preds = %31, %0
%4 = load i32, i32* %2
%5 = icmp sle i32 %4, 9999
br i1 %5, label %6, label %34
6: ; preds = %3
%7 = load i32, i32* %2
%8 = call i32 @sqrt(i32 %7)
%9 = load i32, i32* %2
%10 = call i32 @sqrt(i32 %9)
%11 = icmp eq i32 %8, %10
br i1 %11, label %12, label %30
12: ; preds = %6
%13 = load i32, i32* %2
%14 = sdiv i32 %13, 100
%15 = load i32, i32* %2
%16 = srem i32 %15, 100
%17 = add nsw i32 %14, %16
%18 = load i32, i32* %2
%19 = call i32 @sqrt(i32 %18)
%20 = icmp eq i32 %17, %19
br i1 %20, label %21, label %30
21: ; preds = %12
%22 = load i32, i32* %2
%23 = sdiv i32 %22, 100
%24 = load i32, i32* %2
%25 = srem i32 %24, 100
%26 = load i32, i32* %2
%27 = call i32 @sqrt(i32 %26)
%28 = load i32, i32* %2
%29 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %23, i32 %25, i32 %27, i32 %28)
br label %30
30: ; preds = %21, %12, %6
br label %31
31: ; preds = %30
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %3
34: ; preds = %3
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"%d+%02d=(%.0lf)^2=%d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %18
%2 = phi i32 [ 1000, %0 ], [ %19, %18 ]
%3 = tail call i32 @sqrt(i32 %2)
%4 = tail call i32 @sqrt(i32 %2)
%5 = icmp eq i32 %3, %4
br i1 %5, label %6, label %18
6: ; preds = %1
%7 = trunc i32 %2 to i16
%8 = udiv i16 %7, 100
%9 = zext i16 %8 to i32
%10 = urem i16 %7, 100
%11 = zext i16 %10 to i32
%12 = add nuw nsw i32 %9, %11
%13 = tail call i32 @sqrt(i32 %2)
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %18
15: ; preds = %6
%16 = tail call i32 @sqrt(i32 %2)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %11, i32 %16, i32 %2)
br label %18
18: ; preds = %1, %6, %15
%19 = add nuw nsw i32 %2, 1
%20 = icmp eq i32 %19, 10000
br i1 %20, label %21, label %1
21: ; preds = %18
ret i32 0
}