#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 */
scalar_t__ is_triplet(int, int, int);
int /*<<< orphan*/ printf(char *, int const, int);
int main() {
  const int target = 1000;
  int product = 0;
  for (int a = 1; a < 1000; a++) {
    for (int b = 1; b < 1000; b++) {
      for (int c = 1; c < 1000; c++) {
        if (a + b + c == target && is_triplet(a, b, c)) {
          product = a * b * c;
          goto exit;
        }
      }
    }
  }
exit:
  printf("The product of the triplet with sum %d is %d.\n", target, product);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3e8,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x3e8,-0x10(%rbp)
jge    11f1 <main+0xd1>
movl   $0x1,-0x14(%rbp)
cmpl   $0x3e8,-0x14(%rbp)
jge    11de <main+0xbe>
movl   $0x1,-0x18(%rbp)
cmpl   $0x3e8,-0x18(%rbp)
jge    11cb <main+0xab>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
cmp    $0x3e8,%eax
jne    11b8 <main+0x98>
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <is_triplet@plt>
cmp    $0x0,%rax
je     11b8 <main+0x98>
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11f6 <main+0xd6>
jmp    11bd <main+0x9d>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116c <main+0x4c>
jmp    11d0 <main+0xb0>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1158 <main+0x38>
jmp    11e3 <main+0xc3>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1144 <main+0x24>
jmp    11f6 <main+0xd6>
mov    -0xc(%rbp),%edx
lea    0xe00(%rip),%rdi
mov    $0x3e8,%esi
call   1030 <printf@plt>
mov    -0x4(%rbp),%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    $0x1,%r12d
mov    $0xfffffc1b,%eax
mov    %eax,0x4(%rsp)
mov    %eax,%r13d
mov    %r12d,%r14d
mov    $0x1,%r15d
jmp    1164 <main+0x44>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15d
add    %r12d,%r14d
add    $0x1,%r13d
cmp    $0x3e8,%r15d
je     119c <main+0x7c>
mov    $0x1,%ebp
mov    %r14d,%ebx
jmp    117e <main+0x5e>
xchg   %ax,%ax
add    $0x1,%ebp
add    %r14d,%ebx
cmp    $0x3e8,%ebp
je     1150 <main+0x30>
lea    0x0(%r13,%rbp,1),%eax
cmp    $0x1,%eax
jne    1170 <main+0x50>
mov    %r12d,%edi
mov    %r15d,%esi
mov    %ebp,%edx
call   1040 <is_triplet@plt>
test   %rax,%rax
je     1170 <main+0x50>
jmp    11b2 <main+0x92>
add    $0x1,%r12d
mov    0x4(%rsp),%eax
add    $0x1,%eax
cmp    $0x3e8,%r12d
jne    1136 <main+0x16>
xor    %ebx,%ebx
lea    0xe47(%rip),%rdi
mov    $0x3e8,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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