#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 is_Pythagorean_triplet(int, int, int);
int /*<<< orphan*/ printf(char *, int);
int Problem009(void) {
  int a, b, c = 0;
  int escapism = 0;
  for (a = 1; a < 500; a++) {
    for (b = a + 1; b < 500; b++) {
      c = 1000 - (a + b);
      escapism = is_Pythagorean_triplet(a, b, c);
      if (escapism)
        goto end009;
    }
  }
end009:
  printf("%30d", a * b * c);
  return 0;
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x4(%rbp)
cmpl   $0x1f4,-0x4(%rbp)
jge    11b6 <Problem009+0x96>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x1f4,-0x8(%rbp)
jge    11a3 <Problem009+0x83>
mov    -0x4(%rbp),%ecx
add    -0x8(%rbp),%ecx
mov    $0x3e8,%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <is_Pythagorean_triplet@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1190 <Problem009+0x70>
jmp    11bb <Problem009+0x9b>
jmp    1195 <Problem009+0x75>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1153 <Problem009+0x33>
jmp    11a8 <Problem009+0x88>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    113d <Problem009+0x1d>
jmp    11bb <Problem009+0x9b>
mov    -0x4(%rbp),%esi
imul   -0x8(%rbp),%esi
imul   -0xc(%rbp),%esi
lea    0xe33(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x1,%eax
xor    %r15d,%r15d
mov    $0x4,%r12d
movl   $0x2,0x10(%rsp)
movl   $0x3e6,0xc(%rsp)
jmp    1169 <Problem009+0x49>
xchg   %ax,%ax
add    %r12d,0x10(%rsp)
add    $0x2,%r12d
addl   $0xfffffffe,0xc(%rsp)
mov    0x14(%rsp),%eax
cmp    $0x1f4,%eax
je     11df <Problem009+0xbf>
mov    %eax,%r14d
lea    0x1(%r14),%eax
mov    %eax,0x14(%rsp)
cmp    $0x1f2,%r14d
ja     1150 <Problem009+0x30>
mov    0xc(%rsp),%eax
mov    %eax,%r15d
mov    0x10(%rsp),%r13d
mov    0x14(%rsp),%ebp
nopl   (%rax)
lea    -0x1(%r15),%ebx
mov    %r14d,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1040 <is_Pythagorean_triplet@plt>
test   %eax,%eax
jne    11b8 <Problem009+0x98>
add    $0x1,%ebp
add    %r14d,%r13d
add    $0xffffffff,%r15d
cmp    $0x1f4,%ebp
jne    1190 <Problem009+0x70>
jmp    1150 <Problem009+0x30>
mov    %ebx,%r15d
imul   %r13d,%r15d
lea    0xe3a(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x3d090,%r13d
jmp    11bb <Problem009+0x9b>

LLVM IR (-O0):
@.str = [5 x i8] c"%30d\00"
define i32 @Problem009() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %3
store i32 0, i32* %4
store i32 1, i32* %1
br label %5
5: ; preds = %31, %0
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 500
br i1 %7, label %8, label %34
8: ; preds = %5
%9 = load i32, i32* %1
%10 = add nsw i32 %9, 1
store i32 %10, i32* %2
br label %11
11: ; preds = %27, %8
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 500
br i1 %13, label %14, label %30
14: ; preds = %11
%15 = load i32, i32* %1
%16 = load i32, i32* %2
%17 = add nsw i32 %15, %16
%18 = sub nsw i32 1000, %17
store i32 %18, i32* %3
%19 = load i32, i32* %1
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = call i32 @is_Pythagorean_triplet(i32 %19, i32 %20, i32 %21)
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %14
br label %35
26: ; preds = %14
br label %27
27: ; preds = %26
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
store i32 %29, i32* %2
br label %11
30: ; preds = %11
br label %31
31: ; preds = %30
%32 = load i32, i32* %1
%33 = add nsw i32 %32, 1
store i32 %33, i32* %1
br label %5
34: ; preds = %5
br label %35
35: ; preds = %34, %25
%36 = load i32, i32* %1
%37 = load i32, i32* %2
%38 = mul nsw i32 %36, %37
%39 = load i32, i32* %3
%40 = mul nsw i32 %38, %39
%41 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%30d\00"
define i32 @Problem009() {
br label %4
1: ; preds = %15, %4
%2 = phi i32 [ %5, %4 ], [ %12, %15 ]
%3 = icmp eq i32 %7, 500
br i1 %3, label %20, label %4
4: ; preds = %0, %1
%5 = phi i32 [ 0, %0 ], [ %2, %1 ]
%6 = phi i32 [ 1, %0 ], [ %7, %1 ]
%7 = add nuw nsw i32 %6, 1
%8 = icmp ult i32 %6, 499
br i1 %8, label %9, label %1
9: ; preds = %4, %15
%10 = phi i32 [ %16, %15 ], [ %7, %4 ]
%11 = add nuw nsw i32 %6, %10
%12 = sub nsw i32 1000, %11
%13 = tail call i32 @is_Pythagorean_triplet(i32 %6, i32 %10, i32 %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = add nuw nsw i32 %10, 1
%17 = icmp eq i32 %16, 500
br i1 %17, label %1, label %9
18: ; preds = %9
%19 = mul nsw i32 %10, %6
br label %20
20: ; preds = %1, %18
%21 = phi i32 [ %12, %18 ], [ %2, %1 ]
%22 = phi i32 [ %19, %18 ], [ 250000, %1 ]
%23 = mul nsw i32 %22, %21
%24 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %23)
ret i32 0
}