#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(void) {
  int m = 2, n = 1, first_leg = 0, second_leg = 0, hypotenuse = 0,
      sum_of_pythagorean_triple = 0, product_of_pythagorean_triple = 0;
  for (; m <= 20; m++) {
    n = 1;
    for (; n < m; n++) {
      first_leg = (m * m) - (n * n);
      second_leg = 2 * m * n;
      hypotenuse = (m * m) + (n * n);
      sum_of_pythagorean_triple = first_leg + second_leg + hypotenuse;
      if (sum_of_pythagorean_triple == 1000) {
        product_of_pythagorean_triple = first_leg * second_leg * hypotenuse;
        printf("%d\n", product_of_pythagorean_triple);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x14,-0x8(%rbp)
jg     11fc <main+0xec>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e9 <main+0xd9>
mov    -0x8(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0xc(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x3e8,-0x1c(%rbp)
jne    11d6 <main+0xc6>
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
jmp    11db <main+0xcb>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1161 <main+0x51>
jmp    11ee <main+0xde>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1150 <main+0x40>
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
push   %rax
mov    $0x2,%ebp
xor    %r12d,%r12d
mov    $0x4,%r13d
lea    0xed0(%rip),%r15
jmp    1154 <main+0x44>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x4(%rsp),%ebp
add    $0x1,%ebp
add    $0xffffffff,%r12d
add    $0x2,%r13d
cmp    $0x15,%ebp
je     11b2 <main+0xa2>
mov    %ebp,0x4(%rsp)
imul   %ebp,%ebp
mov    $0x1,%r14d
mov    %r13d,%ebx
jmp    1188 <main+0x78>
cs nopw 0x0(%rax,%rax,1)
lea    (%r12,%r14,1),%eax
add    $0x1,%eax
mov    %r14d,%ecx
add    $0x1,%ecx
add    %r13d,%ebx
mov    %ecx,%r14d
cmp    $0x2,%eax
je     1140 <main+0x30>
mov    %r14d,%eax
imul   %r14d,%eax
mov    %ebp,%esi
sub    %eax,%esi
add    %ebp,%eax
lea    (%rsi,%rbx,1),%ecx
add    %eax,%ecx
cmp    $0x3e8,%ecx
jne    1170 <main+0x60>
imul   %ebx,%esi
imul   %eax,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
jmp    1170 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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