#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 main() {
  int sum = 1000;
  int a = 1;
  for (a; a < sum / 3; a++) {
    int b;
    for (b = sum / 3; b < sum / 2; b++) {
      int c;
      for (c = sum / 3; c < sum / 2; c++) {
        if (a + b + c == 1000) {
          if (a * a + b * b == c * c) {
            printf("[+] Found Pythagorean Triplet: (%d, %d, %d)\n", a, b, c);
            printf("[*] Product == %d\n", a * b * c);
          }
        }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3e8,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    1244 <main+0x134>
mov    -0x8(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    1231 <main+0x121>
mov    -0x8(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    121e <main+0x10e>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
cmp    $0x3e8,%eax
jne    120b <main+0xfb>
mov    -0xc(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    %ecx,%eax
mov    -0x14(%rbp),%ecx
imul   -0x14(%rbp),%ecx
cmp    %ecx,%eax
jne    1206 <main+0xf6>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
imul   -0x10(%rbp),%esi
imul   -0x14(%rbp),%esi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120b <main+0xfb>
jmp    1210 <main+0x100>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1185 <main+0x75>
jmp    1223 <main+0x113>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1159 <main+0x49>
jmp    1236 <main+0x126>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x1,%r12d
mov    $0x1b129,%ebp
mov    $0x14d,%ecx
xor    %edx,%edx
jmp    1167 <main+0x57>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r12d
mov    0x4(%rsp),%ebp
add    $0x1b129,%ebp
add    $0x14d,%ecx
mov    (%rsp),%edx
add    $0x1,%edx
cmp    $0x14d,%r12d
je     121c <main+0x10c>
mov    %r12d,%esi
imul   %r12d,%esi
mov    %esi,0x8(%rsp)
mov    %edx,(%rsp)
mov    %edx,%r15d
mov    %ecx,%r13d
mov    %ebp,0x4(%rsp)
mov    $0x14d,%r14d
mov    %ecx,0xc(%rsp)
jmp    11ae <main+0x9e>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14d
mov    0xc(%rsp),%ecx
mov    0x10(%rsp),%ebp
add    %ecx,%ebp
add    %r12d,%r13d
add    $0x1,%r15d
cmp    $0x1f4,%r14d
je     1140 <main+0x30>
mov    %r14d,%eax
imul   %r14d,%eax
add    0x8(%rsp),%eax
mov    %eax,0x14(%rsp)
mov    $0x14d,%ebx
mov    %ebp,0x10(%rsp)
jmp    11de <main+0xce>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
add    %r13d,%ebp
cmp    $0x1f4,%ebx
je     1190 <main+0x80>
lea    (%r15,%rbx,1),%eax
cmp    $0x29a,%eax
jne    11d0 <main+0xc0>
mov    %ebx,%eax
imul   %ebx,%eax
cmp    %eax,0x14(%rsp)
jne    11d0 <main+0xc0>
lea    0xe05(%rip),%rdi
mov    %r12d,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe1c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11d0 <main+0xc0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [45 x i8] c"[+] Found Pythagorean Triplet: (%d, %d, %d)\0A\00"
@.str.1 = [19 x i8] c"[*] Product == %d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %27
%2 = phi i32 [ 1, %0 ], [ %28, %27 ]
%3 = mul nsw i32 %2, %2
br label %4
4: ; preds = %1, %24
%5 = phi i32 [ 333, %1 ], [ %25, %24 ]
%6 = add nuw nsw i32 %5, %2
%7 = mul nsw i32 %5, %5
%8 = add nuw nsw i32 %7, %3
%9 = mul nuw nsw i32 %5, %2
br label %10
10: ; preds = %4, %21
%11 = phi i32 [ 333, %4 ], [ %22, %21 ]
%12 = add nuw nsw i32 %6, %11
%13 = icmp eq i32 %12, 1000
%14 = mul nuw nsw i32 %11, %11
%15 = icmp eq i32 %8, %14
%16 = select i1 %13, i1 %15, i1 false
br i1 %16, label %17, label %21
17: ; preds = %10
%18 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %5, i32 %11)
%19 = mul nuw nsw i32 %9, %11
%20 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %10, %17
%22 = add nuw nsw i32 %11, 1
%23 = icmp eq i32 %22, 500
br i1 %23, label %24, label %10
24: ; preds = %21
%25 = add nuw nsw i32 %5, 1
%26 = icmp eq i32 %25, 500
br i1 %26, label %27, label %4
27: ; preds = %24
%28 = add nuw nsw i32 %2, 1
%29 = icmp eq i32 %28, 333
br i1 %29, label %30, label %1
30: ; preds = %27
ret i32 0
}