#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 *, unsigned long, ...);
float sqrt(unsigned long);
int main() {
  unsigned long int base = 1, sum = 0, legs = 2, count = 0;
  float height = 0;
  while (count < 6) {
    for (base = 2; base < 2 * legs; base += 2) {
      height = sqrt(legs * legs - base * base / 4);
      if (base - height == 1.0 || height - base == 1.0) {
        printf("found base %ld legs %ld and height %f \n", base, legs, height);
        sum += legs;
        count++;
      }
    }
    legs++;
  }
  printf("%ld \n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x1,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x2,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
cmpq   $0x6,-0x28(%rbp)
jae    12d7 <main+0x1b7>
movq   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
shl    $0x1,%rcx
cmp    %rcx,%rax
jae    12c6 <main+0x1a6>
mov    -0x20(%rbp),%rdi
imul   %rdi,%rdi
mov    -0x10(%rbp),%rax
imul   %rax,%rax
shr    $0x2,%rax
sub    %rax,%rdi
call   1040 <sqrt@plt>
movss  %xmm0,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x34(%rbp)
test   %rax,%rax
movss  %xmm0,-0x30(%rbp)
js     11dd <main+0xbd>
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
subss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe0d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1208 <main+0xe8>
jp     1208 <main+0xe8>
jmp    1279 <main+0x159>
movss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x3c(%rbp)
test   %rax,%rax
movss  %xmm0,-0x38(%rbp)
js     124f <main+0x12f>
movss  -0x3c(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x40(%rbp),%xmm0
movss  -0x38(%rbp),%xmm1
subss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd97(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    12b0 <main+0x190>
jp     12b0 <main+0x190>
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd77(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    12b5 <main+0x195>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
jmp    116a <main+0x4a>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1157 <main+0x37>
mov    -0x18(%rbp),%rsi
lea    0xd4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x2,%r12d
xor    %r13d,%r13d
xor    %r14d,%r14d
jmp    114e <main+0x2e>
nopl   0x0(%rax)
add    $0x1,%r12
cmp    $0x6,%r13
jae    1203 <main+0xe3>
lea    (%r12,%r12,1),%rbp
cmp    $0x3,%rbp
jb     1140 <main+0x20>
mov    %r12,%r15
imul   %r12,%r15
mov    $0x2,%ebx
jmp    1198 <main+0x78>
cs nopw 0x0(%rax,%rax,1)
cvtss2sd %xmm0,%xmm0
lea    0xe89(%rip),%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    $0x1,%al
call   1030 <printf@plt>
add    %r12,%r14
add    $0x1,%r13
add    $0x2,%rbx
cmp    %rbp,%rbx
jae    1140 <main+0x20>
mov    %rbx,%rax
imul   %rbx,%rax
shr    $0x2,%rax
mov    %r15,%rdi
sub    %rax,%rdi
call   1040 <sqrt@plt>
test   %rbx,%rbx
js     11c0 <main+0xa0>
xorps  %xmm1,%xmm1
cvtsi2ss %rbx,%xmm1
jmp    11da <main+0xba>
nopl   (%rax)
mov    %rbx,%rax
shr    %rax
mov    %ebx,%ecx
and    $0x1,%ecx
or     %rax,%rcx
xorps  %xmm1,%xmm1
cvtsi2ss %rcx,%xmm1
addss  %xmm1,%xmm1
movss  0xe1e(%rip),%xmm3
movaps %xmm1,%xmm2
subss  %xmm0,%xmm2
ucomiss %xmm3,%xmm2
jne    11f0 <main+0xd0>
jnp    1170 <main+0x50>
movaps %xmm0,%xmm2
subss  %xmm1,%xmm2
ucomiss %xmm3,%xmm2
jne    118f <main+0x6f>
jp     118f <main+0x6f>
jmp    1170 <main+0x50>
lea    0xe22(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"found base %ld legs %ld and height %f \0A\00"
@.str.1 = [6 x i8] c"%ld \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca float
store i32 0, i32* %1
store i64 1, i64* %2
store i64 0, i64* %3
store i64 2, i64* %4
store i64 0, i64* %5
store float 0.000000e+00, float* %6
br label %7
7: ; preds = %54, %0
%8 = load i64, i64* %5
%9 = icmp ult i64 %8, 6
br i1 %9, label %10, label %57
10: ; preds = %7
store i64 2, i64* %2
br label %11
11: ; preds = %51, %10
%12 = load i64, i64* %2
%13 = load i64, i64* %4
%14 = mul i64 2, %13
%15 = icmp ult i64 %12, %14
br i1 %15, label %16, label %54
16: ; preds = %11
%17 = load i64, i64* %4
%18 = load i64, i64* %4
%19 = mul i64 %17, %18
%20 = load i64, i64* %2
%21 = load i64, i64* %2
%22 = mul i64 %20, %21
%23 = udiv i64 %22, 4
%24 = sub i64 %19, %23
%25 = call float @sqrt(i64 %24)
store float %25, float* %6
%26 = load i64, i64* %2
%27 = uitofp i64 %26 to float
%28 = load float, float* %6
%29 = fsub float %27, %28
%30 = fpext float %29 to double
%31 = fcmp oeq double %30, 1.000000e+00
br i1 %31, label %39, label %32
32: ; preds = %16
%33 = load float, float* %6
%34 = load i64, i64* %2
%35 = uitofp i64 %34 to float
%36 = fsub float %33, %35
%37 = fpext float %36 to double
%38 = fcmp oeq double %37, 1.000000e+00
br i1 %38, label %39, label %50
39: ; preds = %32, %16
%40 = load i64, i64* %2
%41 = load i64, i64* %4
%42 = load float, float* %6
%43 = fpext float %42 to double
%44 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i64 %40, i64 %41, double %43)
%45 = load i64, i64* %4
%46 = load i64, i64* %3
%47 = add i64 %46, %45
store i64 %47, i64* %3
%48 = load i64, i64* %5
%49 = add i64 %48, 1
store i64 %49, i64* %5
br label %50
50: ; preds = %39, %32
br label %51
51: ; preds = %50
%52 = load i64, i64* %2
%53 = add i64 %52, 2
store i64 %53, i64* %2
br label %11
54: ; preds = %11
%55 = load i64, i64* %4
%56 = add i64 %55, 1
store i64 %56, i64* %4
br label %7
57: ; preds = %7
%58 = load i64, i64* %3
%59 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %58)
ret i32 0
}

LLVM IR (-O2):
@.str = [40 x i8] c"found base %ld legs %ld and height %f \0A\00"
@.str.1 = [6 x i8] c"%ld \0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %33
%2 = phi i64 [ 0, %0 ], [ %35, %33 ]
%3 = phi i64 [ 2, %0 ], [ %36, %33 ]
%4 = phi i64 [ 0, %0 ], [ %34, %33 ]
%5 = shl i64 %3, 1
%6 = icmp ugt i64 %5, 2
br i1 %6, label %7, label %33
7: ; preds = %1
%8 = mul i64 %3, %3
br label %9
9: ; preds = %7, %28
%10 = phi i64 [ %2, %7 ], [ %30, %28 ]
%11 = phi i64 [ %4, %7 ], [ %29, %28 ]
%12 = phi i64 [ 2, %7 ], [ %31, %28 ]
%13 = mul i64 %12, %12
%14 = lshr exact i64 %13, 2
%15 = sub i64 %8, %14
%16 = tail call float @sqrt(i64 %15)
%17 = uitofp i64 %12 to float
%18 = fsub float %17, %16
%19 = fcmp oeq float %18, 1.000000e+00
%20 = fsub float %16, %17
%21 = fcmp oeq float %20, 1.000000e+00
%22 = or i1 %19, %21
br i1 %22, label %23, label %28
23: ; preds = %9
%24 = fpext float %16 to double
%25 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i64 %12, i64 %3, double %24)
%26 = add i64 %11, %3
%27 = add i64 %10, 1
br label %28
28: ; preds = %9, %23
%29 = phi i64 [ %26, %23 ], [ %11, %9 ]
%30 = phi i64 [ %27, %23 ], [ %10, %9 ]
%31 = add nuw i64 %12, 2
%32 = icmp ult i64 %31, %5
br i1 %32, label %9, label %33
33: ; preds = %28, %1
%34 = phi i64 [ %4, %1 ], [ %29, %28 ]
%35 = phi i64 [ %2, %1 ], [ %30, %28 ]
%36 = add i64 %3, 1
%37 = icmp ult i64 %35, 6
br i1 %37, label %1, label %38
38: ; preds = %33
%39 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %34)
ret i32 0
}