#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 */
scalar_t__ pow(int, int);
int solution() {
  int limit, a, b, c;
  limit = 1000;
  for (b = 1; b < limit; b++) {
    for (c = 1; c < limit; c++) {
      a = limit - b - c;
      if (pow(a, 2) + pow(b, 2) == pow(c, 2)) {
        return a * b * c;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<solution>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x3e8,-0x8(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d3 <solution+0xc3>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c0 <solution+0xb0>
mov    -0x8(%rbp),%eax
sub    -0x10(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x2,%esi
call   1030 <pow@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%edi
mov    $0x2,%esi
call   1030 <pow@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x2,%esi
call   1030 <pow@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jne    11ad <solution+0x9d>
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11da <solution+0xca>
jmp    11b2 <solution+0xa2>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1139 <solution+0x29>
jmp    11c5 <solution+0xb5>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <solution+0x16>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solution>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%r14d
mov    $0x3e6,%eax
mov    %eax,0x4(%rsp)
mov    %eax,%r15d
mov    $0x2,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0x1(%r12),%ebp
mov    %r15d,%edi
mov    $0x2,%esi
call   1030 <pow@plt>
mov    %rax,%r13
mov    %r14d,%edi
mov    $0x2,%esi
call   1030 <pow@plt>
mov    %rax,%rbx
add    %r13,%rbx
mov    %ebp,%edi
mov    $0x2,%esi
call   1030 <pow@plt>
cmp    %rax,%rbx
je     11ed <solution+0xdd>
cmp    $0x3e8,%r12d
je     11d0 <solution+0xc0>
lea    -0x1(%r15),%ebp
mov    %ebp,%edi
mov    $0x2,%esi
call   1030 <pow@plt>
mov    %rax,%r13
mov    %r14d,%edi
mov    $0x2,%esi
call   1030 <pow@plt>
mov    %rax,%rbx
add    %r13,%rbx
mov    %r12d,%edi
mov    $0x2,%esi
call   1030 <pow@plt>
cmp    %rax,%rbx
je     11f3 <solution+0xe3>
add    $0x2,%r12d
add    $0xfffffffe,%r15d
jmp    1140 <solution+0x30>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14d
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3e8,%r14d
jne    1126 <solution+0x16>
xor    %r12d,%r12d
jmp    11fb <solution+0xeb>
mov    %ebp,%r12d
mov    %r15d,%ebp
imul   %r14d,%r12d
imul   %ebp,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @solution() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 1000, i32* %2
store i32 1, i32* %4
br label %6
6: ; preds = %40, %0
%7 = load i32, i32* %4
%8 = load i32, i32* %2
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %43
10: ; preds = %6
store i32 1, i32* %5
br label %11
11: ; preds = %36, %10
%12 = load i32, i32* %5
%13 = load i32, i32* %2
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %39
15: ; preds = %11
%16 = load i32, i32* %2
%17 = load i32, i32* %4
%18 = sub nsw i32 %16, %17
%19 = load i32, i32* %5
%20 = sub nsw i32 %18, %19
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = call i64 @pow(i32 %21, i32 2)
%23 = load i32, i32* %4
%24 = call i64 @pow(i32 %23, i32 2)
%25 = add nsw i64 %22, %24
%26 = load i32, i32* %5
%27 = call i64 @pow(i32 %26, i32 2)
%28 = icmp eq i64 %25, %27
br i1 %28, label %29, label %35
29: ; preds = %15
%30 = load i32, i32* %3
%31 = load i32, i32* %4
%32 = mul nsw i32 %30, %31
%33 = load i32, i32* %5
%34 = mul nsw i32 %32, %33
store i32 %34, i32* %1
br label %44
35: ; preds = %15
br label %36
36: ; preds = %35
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %11
39: ; preds = %11
br label %40
40: ; preds = %39
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
br label %6
43: ; preds = %6
store i32 0, i32* %1
br label %44
44: ; preds = %43, %29
%45 = load i32, i32* %1
ret i32 %45
}

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