#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 */
float pow(int, int);
int find_triplet_product(int sum) {
  float x, y, z;
  for (int a = 1; a < sum; ++a) {
    x = pow(a, 2);
    for (int b = a + 1; b < sum; ++b) {
      y = pow(b, 2);
      for (int c = b + 1; c < sum; ++c) {
        z = pow(c, 2);
        if (x + y == z) {
          if (a + b + c == sum) {
            return a * b * c;
          }
        }
      }
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<find_triplet_product>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    120b <find_triplet_product+0xfb>
mov    -0x18(%rbp),%edi
mov    $0x2,%esi
call   1030 <pow@plt>
movss  %xmm0,-0xc(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f8 <find_triplet_product+0xe8>
mov    -0x1c(%rbp),%edi
mov    $0x2,%esi
call   1030 <pow@plt>
movss  %xmm0,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e5 <find_triplet_product+0xd5>
mov    -0x20(%rbp),%edi
mov    $0x2,%esi
call   1030 <pow@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
ucomiss -0x14(%rbp),%xmm0
jne    11d2 <find_triplet_product+0xc2>
jp     11d2 <find_triplet_product+0xc2>
mov    -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11cd <find_triplet_product+0xbd>
mov    -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1212 <find_triplet_product+0x102>
jmp    11d2 <find_triplet_product+0xc2>
jmp    11d7 <find_triplet_product+0xc7>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1170 <find_triplet_product+0x60>
jmp    11ea <find_triplet_product+0xda>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1149 <find_triplet_product+0x39>
jmp    11fd <find_triplet_product+0xed>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1122 <find_triplet_product+0x12>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_triplet_product>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    $0xffffffff,%eax
cmp    $0x2,%edi
jl     12b1 <find_triplet_product+0x1a1>
mov    %edi,%ebx
lea    -0x6(%rbx),%r12d
mov    $0x1,%eax
mov    $0x12,%edi
mov    $0xa,%ecx
mov    $0x6,%r14d
mov    $0x4,%edx
mov    $0x2,%r13d
movl   $0x2,0x10(%rsp)
mov    $0x6,%r15d
mov    $0x12,%esi
mov    %rdi,0x40(%rsp)
mov    %rsi,0x48(%rsp)
mov    %edx,0x28(%rsp)
mov    %ecx,0x30(%rsp)
mov    %eax,%ebp
mov    %eax,%edi
mov    $0x2,%esi
call   1030 <pow@plt>
movss  %xmm0,0x38(%rsp)
mov    %rbp,%rax
mov    %rbp,0x50(%rsp)
lea    0x1(%rbp),%eax
mov    %r12d,0x34(%rsp)
mov    %r12d,0x18(%rsp)
mov    %r13d,0x24(%rsp)
mov    %r15d,0x20(%rsp)
mov    %r15d,0x14(%rsp)
mov    %r14d,0x2c(%rsp)
mov    %eax,%r12d
mov    %eax,0x1c(%rsp)
cmp    %ebx,%eax
jl     123e <find_triplet_product+0x12e>
mov    0x20(%rsp),%r15d
mov    0x40(%rsp),%rax
add    %eax,%r15d
mov    0x48(%rsp),%rsi
add    %esi,%eax
add    $0x6,%esi
mov    0x30(%rsp),%ecx
mov    0x2c(%rsp),%r14d
add    %ecx,%r14d
add    $0x4,%ecx
addl   $0x2,0x10(%rsp)
mov    0x28(%rsp),%edx
mov    0x24(%rsp),%r13d
add    %edx,%r13d
add    $0x2,%edx
mov    0x34(%rsp),%r12d
add    $0xfffffffd,%r12d
mov    %eax,%edi
mov    0x1c(%rsp),%eax
cmp    %ebx,%eax
jne    1165 <find_triplet_product+0x55>
jmp    12c0 <find_triplet_product+0x1b0>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x3c(%rsp),%r14d
add    %r14d,0x14(%rsp)
add    0x10(%rsp),%r14d
add    0x50(%rsp),%r13d
addl   $0xfffffffe,0x18(%rsp)
cmp    %ebx,%r12d
je     11bf <find_triplet_product+0xaf>
mov    %r14d,0x3c(%rsp)
mov    %r12d,%edi
mov    $0x2,%esi
call   1030 <pow@plt>
movss  %xmm0,0xc(%rsp)
add    $0x1,%r12d
cmp    %ebx,%r12d
jge    1220 <find_triplet_product+0x110>
movss  0xc(%rsp),%xmm0
addss  0x38(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
mov    0x18(%rsp),%r14d
mov    0x14(%rsp),%r15d
mov    %r12d,%ebp
jmp    128a <find_triplet_product+0x17a>
add    $0x1,%ebp
add    %r13d,%r15d
cmp    %ebx,%ebp
jge    1220 <find_triplet_product+0x110>
mov    %ebp,%edi
mov    $0x2,%esi
call   1030 <pow@plt>
sub    $0x1,%r14d
setb   %al
movss  0xc(%rsp),%xmm1
ucomiss %xmm0,%xmm1
jne    1280 <find_triplet_product+0x170>
jp     1280 <find_triplet_product+0x170>
test   %al,%al
je     1280 <find_triplet_product+0x170>
mov    %r15d,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xffffffff,%eax
jmp    12b1 <find_triplet_product+0x1a1>

LLVM IR (-O0):
define i32 @find_triplet_product(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i32 1, i32* %7
br label %10
10: ; preds = %64, %1
%11 = load i32, i32* %7
%12 = load i32, i32* %3
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %67
14: ; preds = %10
%15 = load i32, i32* %7
%16 = call float @pow(i32 %15, i32 2)
store float %16, float* %4
%17 = load i32, i32* %7
%18 = add nsw i32 %17, 1
store i32 %18, i32* %8
br label %19
19: ; preds = %60, %14
%20 = load i32, i32* %8
%21 = load i32, i32* %3
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %63
23: ; preds = %19
%24 = load i32, i32* %8
%25 = call float @pow(i32 %24, i32 2)
store float %25, float* %5
%26 = load i32, i32* %8
%27 = add nsw i32 %26, 1
store i32 %27, i32* %9
br label %28
28: ; preds = %56, %23
%29 = load i32, i32* %9
%30 = load i32, i32* %3
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %59
32: ; preds = %28
%33 = load i32, i32* %9
%34 = call float @pow(i32 %33, i32 2)
store float %34, float* %6
%35 = load float, float* %4
%36 = load float, float* %5
%37 = fadd float %35, %36
%38 = load float, float* %6
%39 = fcmp oeq float %37, %38
br i1 %39, label %40, label %55
40: ; preds = %32
%41 = load i32, i32* %7
%42 = load i32, i32* %8
%43 = add nsw i32 %41, %42
%44 = load i32, i32* %9
%45 = add nsw i32 %43, %44
%46 = load i32, i32* %3
%47 = icmp eq i32 %45, %46
br i1 %47, label %48, label %54
48: ; preds = %40
%49 = load i32, i32* %7
%50 = load i32, i32* %8
%51 = mul nsw i32 %49, %50
%52 = load i32, i32* %9
%53 = mul nsw i32 %51, %52
store i32 %53, i32* %2
br label %68
54: ; preds = %40
br label %55
55: ; preds = %54, %32
br label %56
56: ; preds = %55
%57 = load i32, i32* %9
%58 = add nsw i32 %57, 1
store i32 %58, i32* %9
br label %28
59: ; preds = %28
br label %60
60: ; preds = %59
%61 = load i32, i32* %8
%62 = add nsw i32 %61, 1
store i32 %62, i32* %8
br label %19
63: ; preds = %19
br label %64
64: ; preds = %63
%65 = load i32, i32* %7
%66 = add nsw i32 %65, 1
store i32 %66, i32* %7
br label %10
67: ; preds = %10
store i32 -1, i32* %2
br label %68
68: ; preds = %67, %48
%69 = load i32, i32* %2
ret i32 %69
}

LLVM IR (-O2):
define i32 @find_triplet_product(i32 %0) {
%2 = icmp sgt i32 %0, 1
br i1 %2, label %5, label %33
3: ; preds = %10, %5
%4 = icmp eq i32 %8, %0
br i1 %4, label %33, label %5
5: ; preds = %1, %3
%6 = phi i32 [ %8, %3 ], [ 1, %1 ]
%7 = tail call float @pow(i32 %6, i32 2)
%8 = add nuw nsw i32 %6, 1
%9 = icmp slt i32 %8, %0
br i1 %9, label %12, label %3
10: ; preds = %27, %12
%11 = icmp eq i32 %15, %0
br i1 %11, label %3, label %12
12: ; preds = %5, %10
%13 = phi i32 [ %15, %10 ], [ %8, %5 ]
%14 = tail call float @pow(i32 %13, i32 2)
%15 = add nuw i32 %13, 1
%16 = icmp slt i32 %15, %0
br i1 %16, label %17, label %10
17: ; preds = %12
%18 = fadd float %7, %14
%19 = add nuw nsw i32 %13, %6
br label %20
20: ; preds = %17, %27
%21 = phi i32 [ %15, %17 ], [ %28, %27 ]
%22 = tail call float @pow(i32 %21, i32 2)
%23 = fcmp oeq float %18, %22
%24 = add nuw nsw i32 %19, %21
%25 = icmp eq i32 %24, %0
%26 = select i1 %23, i1 %25, i1 false
br i1 %26, label %30, label %27
27: ; preds = %20
%28 = add nuw nsw i32 %21, 1
%29 = icmp slt i32 %28, %0
br i1 %29, label %20, label %10
30: ; preds = %20
%31 = mul nsw i32 %13, %6
%32 = mul nsw i32 %31, %21
br label %33
33: ; preds = %3, %1, %30
%34 = phi i32 [ %32, %30 ], [ -1, %1 ], [ -1, %3 ]
ret i32 %34
}