#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 *, ...);
scalar_t__ sqrt(unsigned int);
void main() {
  unsigned int x = 1, y = 1, z = 0;
  printf("%10s %10s %10s\n", "Z", "X", "Y");
  printf("      ___________________________\n");
  while (x <= 50) {
    z = (int)sqrt(x * x + y * y);
    while (y <= 50 && z <= 50) {
      if (z * z == x * x + y * y)
        printf("%10d %10d %10d\n", z, x, y);
      y = y + 1;
      z = (int)sqrt(x * x + y * y);
    }
    x = x + 1;
    y = x;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xebc(%rip),%rdi
lea    0xec5(%rip),%rsi
lea    0xec0(%rip),%rdx
lea    0xebb(%rip),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x32,-0x4(%rbp)
ja     1229 <main+0x109>
mov    -0x4(%rbp),%edi
imul   -0x4(%rbp),%edi
mov    -0x8(%rbp),%eax
imul   -0x8(%rbp),%eax
add    %eax,%edi
call   1040 <sqrt@plt>
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x32,-0x8(%rbp)
mov    %al,-0xd(%rbp)
ja     11a9 <main+0x89>
cmpl   $0x32,-0xc(%rbp)
setbe  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    11b9 <main+0x99>
jmp    1215 <main+0xf5>
mov    -0xc(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    -0x4(%rbp),%ecx
imul   -0x4(%rbp),%ecx
mov    -0x8(%rbp),%edx
imul   -0x8(%rbp),%edx
add    %edx,%ecx
cmp    %ecx,%eax
jne    11ef <main+0xcf>
mov    -0xc(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
imul   -0x4(%rbp),%edi
mov    -0x8(%rbp),%eax
imul   -0x8(%rbp),%eax
add    %eax,%edi
call   1040 <sqrt@plt>
mov    %eax,-0xc(%rbp)
jmp    1190 <main+0x70>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    116e <main+0x4e>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xec1(%rip),%rdi
lea    0xeca(%rip),%rsi
lea    0xec5(%rip),%rdx
lea    0xec0(%rip),%rcx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec4(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r15d
lea    0xea2(%rip),%r14
jmp    118a <main+0x5a>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r15d
cmp    $0x33,%r15d
je     11f0 <main+0xc0>
mov    %r15d,%r12d
imul   %r12d,%r12d
lea    (%r12,%r12,1),%edi
call   1050 <sqrt@plt>
cmp    $0x32,%eax
ja     1180 <main+0x50>
mov    %r15d,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,%ecx
imul   %eax,%ecx
mov    %ebx,%edx
imul   %ebx,%edx
add    %r12d,%edx
cmp    %edx,%ecx
jne    11d2 <main+0xa2>
mov    %r14,%rdi
mov    %eax,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x1(%rbx),%ebp
mov    %ebp,%edi
imul   %ebp,%edi
add    %r12d,%edi
call   1050 <sqrt@plt>
cmp    $0x31,%ebx
ja     1180 <main+0x50>
mov    %ebp,%ebx
cmp    $0x33,%eax
jb     11b0 <main+0x80>
jmp    1180 <main+0x50>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"%10s %10s %10s\0A\00"
@.str.1 = [2 x i8] c"Z\00"
@.str.2 = [2 x i8] c"X\00"
@.str.3 = [2 x i8] c"Y\00"
@.str.4 = [35 x i8] c" ___________________________\0A\00"
@.str.5 = [16 x i8] c"%10d %10d %10d\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 1, i32* %1
store i32 1, i32* %2
store i32 0, i32* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
br label %6
6: ; preds = %56, %0
%7 = load i32, i32* %1
%8 = icmp ule i32 %7, 50
br i1 %8, label %9, label %60
9: ; preds = %6
%10 = load i32, i32* %1
%11 = load i32, i32* %1
%12 = mul i32 %10, %11
%13 = load i32, i32* %2
%14 = load i32, i32* %2
%15 = mul i32 %13, %14
%16 = add i32 %12, %15
%17 = call i64 @sqrt(i32 %16)
%18 = trunc i64 %17 to i32
store i32 %18, i32* %3
br label %19
19: ; preds = %44, %9
%20 = load i32, i32* %2
%21 = icmp ule i32 %20, 50
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i32, i32* %3
%24 = icmp ule i32 %23, 50
br label %25
25: ; preds = %22, %19
%26 = phi i1 [ false, %19 ], [ %24, %22 ]
br i1 %26, label %27, label %56
27: ; preds = %25
%28 = load i32, i32* %3
%29 = load i32, i32* %3
%30 = mul i32 %28, %29
%31 = load i32, i32* %1
%32 = load i32, i32* %1
%33 = mul i32 %31, %32
%34 = load i32, i32* %2
%35 = load i32, i32* %2
%36 = mul i32 %34, %35
%37 = add i32 %33, %36
%38 = icmp eq i32 %30, %37
br i1 %38, label %39, label %44
39: ; preds = %27
%40 = load i32, i32* %3
%41 = load i32, i32* %1
%42 = load i32, i32* %2
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %40, i32 %41, i32 %42)
br label %44
44: ; preds = %39, %27
%45 = load i32, i32* %2
%46 = add i32 %45, 1
store i32 %46, i32* %2
%47 = load i32, i32* %1
%48 = load i32, i32* %1
%49 = mul i32 %47, %48
%50 = load i32, i32* %2
%51 = load i32, i32* %2
%52 = mul i32 %50, %51
%53 = add i32 %49, %52
%54 = call i64 @sqrt(i32 %53)
%55 = trunc i64 %54 to i32
store i32 %55, i32* %3
br label %19
56: ; preds = %25
%57 = load i32, i32* %1
%58 = add i32 %57, 1
store i32 %58, i32* %1
%59 = load i32, i32* %1
store i32 %59, i32* %2
br label %6
60: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"%10s %10s %10s\0A\00"
@.str.1 = [2 x i8] c"Z\00"
@.str.2 = [2 x i8] c"X\00"
@.str.3 = [2 x i8] c"Y\00"
@.str.5 = [16 x i8] c"%10d %10d %10d\0A\00"
@str = [34 x i8] c" ___________________________\00"
define void @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %3
3: ; preds = %0, %28
%4 = phi i32 [ 1, %0 ], [ %29, %28 ]
%5 = mul nuw nsw i32 %4, %4
%6 = shl nuw nsw i32 %5, 1
%7 = tail call i64 @sqrt(i32 %6)
%8 = trunc i64 %7 to i32
%9 = icmp ult i32 %8, 51
br i1 %9, label %10, label %28
10: ; preds = %3, %19
%11 = phi i32 [ %24, %19 ], [ %8, %3 ]
%12 = phi i32 [ %20, %19 ], [ %4, %3 ]
%13 = mul nuw nsw i32 %11, %11
%14 = mul nuw nsw i32 %12, %12
%15 = add nuw i32 %14, %5
%16 = icmp eq i32 %13, %15
br i1 %16, label %17, label %19
17: ; preds = %10
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %11, i32 %4, i32 %12)
br label %19
19: ; preds = %17, %10
%20 = add nuw nsw i32 %12, 1
%21 = mul nuw nsw i32 %20, %20
%22 = add nuw i32 %21, %5
%23 = tail call i64 @sqrt(i32 %22)
%24 = trunc i64 %23 to i32
%25 = icmp ult i32 %12, 50
%26 = icmp ult i32 %24, 51
%27 = select i1 %25, i1 %26, i1 false
br i1 %27, label %10, label %28
28: ; preds = %19, %3
%29 = add nuw nsw i32 %4, 1
%30 = icmp eq i32 %29, 51
br i1 %30, label %31, label %3
31: ; preds = %28
ret void
}