#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 *, int);
int problem9(void) {
  int a, b, c;
  for (c = 1; c < 1000; c++) {
    for (b = 1; b < c; b++) {
      for (a = 1; a < b; a++) {
        if (a + b + c == 1000 && (a * a) + (b * b) == c * c) {
          printf("The Pythagorean triplet where a + b + c = 1000 has a product "
                 "of %d\n",
                 a * b * c);
          return 0;
        }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<problem9>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x10(%rbp)
cmpl   $0x3e8,-0x10(%rbp)
jge    11e1 <problem9+0xd1>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11ce <problem9+0xbe>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11bb <problem9+0xab>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
cmp    $0x3e8,%eax
jne    11a8 <problem9+0x98>
mov    -0x8(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    %ecx,%eax
mov    -0x10(%rbp),%ecx
imul   -0x10(%rbp),%ecx
cmp    %ecx,%eax
jne    11a8 <problem9+0x98>
mov    -0x8(%rbp),%esi
imul   -0xc(%rbp),%esi
imul   -0x10(%rbp),%esi
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e8 <problem9+0xd8>
jmp    11ad <problem9+0x9d>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1146 <problem9+0x36>
jmp    11c0 <problem9+0xb0>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <problem9+0x23>
jmp    11d3 <problem9+0xc3>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    111f <problem9+0xf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<problem9>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%r9d
mov    $0xfffffc1b,%r8d
jmp    1141 <problem9+0x31>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r9d
add    $0x1,%r8d
cmp    $0x3e8,%r9d
je     11c0 <problem9+0xb0>
cmp    $0x2,%r9d
jb     1130 <problem9+0x20>
mov    %r9d,%r10d
imul   %r9d,%r10d
mov    $0x1,%r11d
xor    %ecx,%ecx
mov    %r8d,%eax
mov    %r9d,%edx
jmp    1172 <problem9+0x62>
xchg   %ax,%ax
add    $0x1,%r11d
add    %r9d,%edx
add    $0xffffffff,%ecx
add    $0x1,%eax
cmp    %r9d,%r11d
je     1130 <problem9+0x20>
cmp    $0x2,%r11d
jb     1160 <problem9+0x50>
mov    %r11d,%edi
imul   %r11d,%edi
mov    $0x1,%ebx
mov    %edx,%esi
jmp    11a0 <problem9+0x90>
nopl   0x0(%rax,%rax,1)
add    %edx,%esi
lea    (%rcx,%rbx,1),%ebp
add    $0x1,%ebp
add    $0x1,%ebx
cmp    $0x1,%ebp
je     1160 <problem9+0x50>
lea    (%rax,%rbx,1),%ebp
cmp    $0x1,%ebp
jne    1190 <problem9+0x80>
mov    %ebx,%ebp
imul   %ebx,%ebp
add    %edi,%ebp
cmp    %r10d,%ebp
jne    1190 <problem9+0x80>
lea    0xe45(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [68 x i8] c"The Pythagorean triplet where a + b + c = 1000 has a product of %d\0A\00"
define i32 @problem9() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 1, i32* %4
br label %5
5: ; preds = %53, %0
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 1000
br i1 %7, label %8, label %56
8: ; preds = %5
store i32 1, i32* %3
br label %9
9: ; preds = %49, %8
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %52
13: ; preds = %9
store i32 1, i32* %2
br label %14
14: ; preds = %45, %13
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %48
18: ; preds = %14
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = add nsw i32 %19, %20
%22 = load i32, i32* %4
%23 = add nsw i32 %21, %22
%24 = icmp eq i32 %23, 1000
br i1 %24, label %25, label %44
25: ; preds = %18
%26 = load i32, i32* %2
%27 = load i32, i32* %2
%28 = mul nsw i32 %26, %27
%29 = load i32, i32* %3
%30 = load i32, i32* %3
%31 = mul nsw i32 %29, %30
%32 = add nsw i32 %28, %31
%33 = load i32, i32* %4
%34 = load i32, i32* %4
%35 = mul nsw i32 %33, %34
%36 = icmp eq i32 %32, %35
br i1 %36, label %37, label %44
37: ; preds = %25
%38 = load i32, i32* %2
%39 = load i32, i32* %3
%40 = mul nsw i32 %38, %39
%41 = load i32, i32* %4
%42 = mul nsw i32 %40, %41
%43 = call i32 @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i32 %42)
store i32 0, i32* %1
br label %57
44: ; preds = %25, %18
br label %45
45: ; preds = %44
%46 = load i32, i32* %2
%47 = add nsw i32 %46, 1
store i32 %47, i32* %2
br label %14
48: ; preds = %14
br label %49
49: ; preds = %48
%50 = load i32, i32* %3
%51 = add nsw i32 %50, 1
store i32 %51, i32* %3
br label %9
52: ; preds = %9
br label %53
53: ; preds = %52
%54 = load i32, i32* %4
%55 = add nsw i32 %54, 1
store i32 %55, i32* %4
br label %5
56: ; preds = %5
store i32 0, i32* %1
br label %57
57: ; preds = %56, %37
%58 = load i32, i32* %1
ret i32 %58
}

LLVM IR (-O2):
@.str = [68 x i8] c"The Pythagorean triplet where a + b + c = 1000 has a product of %d\0A\00"
define i32 @problem9() {
br label %1
1: ; preds = %0, %30
%2 = phi i32 [ 1, %0 ], [ %31, %30 ]
%3 = icmp ugt i32 %2, 1
br i1 %3, label %4, label %30
4: ; preds = %1
%5 = mul nsw i32 %2, %2
br label %6
6: ; preds = %4, %27
%7 = phi i32 [ 1, %4 ], [ %28, %27 ]
%8 = icmp ugt i32 %7, 1
br i1 %8, label %9, label %27
9: ; preds = %6
%10 = add nuw nsw i32 %7, %2
%11 = mul nsw i32 %7, %7
br label %12
12: ; preds = %9, %24
%13 = phi i32 [ 1, %9 ], [ %25, %24 ]
%14 = add nuw nsw i32 %10, %13
%15 = icmp eq i32 %14, 1000
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = mul nsw i32 %13, %13
%18 = add nuw nsw i32 %17, %11
%19 = icmp eq i32 %18, %5
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = mul i32 %7, %2
%22 = mul i32 %21, %13
%23 = tail call i32 @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %33
24: ; preds = %12, %16
%25 = add nuw nsw i32 %13, 1
%26 = icmp eq i32 %25, %7
br i1 %26, label %27, label %12
27: ; preds = %24, %6
%28 = add nuw nsw i32 %7, 1
%29 = icmp eq i32 %28, %2
br i1 %29, label %30, label %6
30: ; preds = %27, %1
%31 = add nuw nsw i32 %2, 1
%32 = icmp eq i32 %31, 1000
br i1 %32, label %33, label %1
33: ; preds = %30, %20
ret i32 0
}