#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() {
  for (int a = 1; a < 500; a++) {
    for (int b = a + 1; b < 500; b++) {
      for (int c = b + 1; c < 500; c++) {
        if (a + b + c == 1000 && (a * a + b * b == c * c)) {
          printf("A Pythagorean triplet for which a+b+c = 1000 is: %d  %d  %d, "
                 "where its product is:\n",
                 a, b, c);
          printf("%d\n", a * b * c);
          return 0;
        }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x1f4,-0x8(%rbp)
jge    1207 <main+0xf7>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x1f4,-0xc(%rbp)
jge    11f4 <main+0xe4>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x1f4,-0x10(%rbp)
jge    11e1 <main+0xd1>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
cmp    $0x3e8,%eax
jne    11ce <main+0xbe>
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    11ce <main+0xbe>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
imul   -0xc(%rbp),%esi
imul   -0x10(%rbp),%esi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    120e <main+0xfe>
jmp    11d3 <main+0xc3>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1152 <main+0x42>
jmp    11e6 <main+0xd6>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113c <main+0x2c>
jmp    11f9 <main+0xe9>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1126 <main+0x16>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    $0x1,%eax
mov    $0x12,%ecx
mov    %rcx,0x20(%rsp)
movl   $0xa,0x14(%rsp)
movl   $0x6,0xc(%rsp)
movl   $0x4,0x10(%rsp)
movl   $0x2,0x8(%rsp)
movl   $0x3e2,0x4(%rsp)
mov    $0x2,%edi
movl   $0x6,(%rsp)
mov    $0x12,%r13d
mov    %eax,%esi
lea    0x1(%rsi),%eax
mov    %eax,0x18(%rsp)
cmp    $0x1f2,%esi
ja     1210 <main+0x100>
mov    %esi,%eax
imul   %esi,%eax
mov    %eax,0x1c(%rsp)
mov    0x4(%rsp),%r12d
mov    0x8(%rsp),%r11d
mov    (%rsp),%ebp
mov    0xc(%rsp),%r9d
mov    0x18(%rsp),%r8d
jmp    11b6 <main+0xa6>
xchg   %ax,%ax
add    %r9d,%ebp
add    %edi,%r9d
add    %esi,%r11d
add    $0xfffffffe,%r12d
cmp    $0x1f4,%r8d
je     1210 <main+0x100>
mov    %r8d,%edx
lea    0x1(%rdx),%r8d
cmp    $0x1f2,%edx
ja     11a0 <main+0x90>
mov    %edx,%r10d
imul   %edx,%r10d
add    0x1c(%rsp),%r10d
mov    %r12d,%r15d
mov    %ebp,%ebx
mov    %r8d,%ecx
jmp    11f0 <main+0xe0>
nopl   0x0(%rax,%rax,1)
lea    0x1(%rcx),%eax
add    %r11d,%ebx
cmp    $0x1f3,%ecx
mov    %eax,%ecx
jae    11a0 <main+0x90>
sub    $0x1,%r15d
jae    11e0 <main+0xd0>
mov    %ecx,%r14d
imul   %ecx,%r14d
cmp    %r14d,%r10d
jne    11e0 <main+0xd0>
jmp    125e <main+0x14e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x20(%rsp),%rax
add    %eax,(%rsp)
lea    (%rax,%r13,1),%ecx
add    $0x6,%r13d
mov    0x14(%rsp),%eax
add    %eax,0xc(%rsp)
add    $0x4,%eax
mov    %eax,0x14(%rsp)
add    $0x2,%edi
mov    0x10(%rsp),%eax
add    %eax,0x8(%rsp)
add    $0x2,%eax
mov    %eax,0x10(%rsp)
addl   $0xfffffffd,0x4(%rsp)
mov    %ecx,%eax
mov    %rax,0x20(%rsp)
mov    0x18(%rsp),%eax
cmp    $0x1f4,%eax
jne    1167 <main+0x57>
jmp    127c <main+0x16c>
lea    0xd9b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xde1(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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