#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__ triplet(int, int, int);
int problem_9(void) {
  int i, j, k;
  for (i = 1000; i > 0; i--) {
    for (j = i - 1; j > 0; j--) {
      k = 1000 - i - j;
      if (triplet(i, j, k)) {
        return i * j * k;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<problem_9>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x3e8,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    119b <problem_9+0x8b>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    1188 <problem_9+0x78>
mov    $0x3e8,%eax
sub    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <triplet@plt>
cmp    $0x0,%rax
je     1175 <problem_9+0x65>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a2 <problem_9+0x92>
jmp    117a <problem_9+0x6a>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1132 <problem_9+0x22>
jmp    118d <problem_9+0x7d>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    111f <problem_9+0xf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<problem_9>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x3e8,%r14d
mov    $0xfffffc18,%r12d
mov    $0x7cf,%ecx
mov    $0xfff0bdc0,%r13d
mov    %ecx,0x4(%rsp)
mov    %r13d,%r15d
mov    %r12d,%ebx
mov    %r14d,%ebp
nop
cmp    $0x2,%ebp
jl     1170 <problem_9+0x60>
add    $0xffffffff,%ebp
add    $0x1,%ebx
mov    %r14d,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <triplet@plt>
add    %r14d,%r15d
test   %rax,%rax
je     1140 <problem_9+0x30>
jmp    1190 <problem_9+0x80>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    -0x1(%r14),%eax
add    $0x2,%r12d
mov    0x4(%rsp),%ecx
add    %ecx,%r13d
add    $0xfffffffe,%ecx
cmp    $0x1,%r14d
mov    %eax,%r14d
ja     1132 <problem_9+0x22>
xor    %r15d,%r15d
jmp    1197 <problem_9+0x87>
imul   %ebx,%r15d
neg    %r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @problem_9() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 1000, i32* %2
br label %5
5: ; preds = %35, %0
%6 = load i32, i32* %2
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %38
8: ; preds = %5
%9 = load i32, i32* %2
%10 = sub nsw i32 %9, 1
store i32 %10, i32* %3
br label %11
11: ; preds = %31, %8
%12 = load i32, i32* %3
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %34
14: ; preds = %11
%15 = load i32, i32* %2
%16 = sub nsw i32 1000, %15
%17 = load i32, i32* %3
%18 = sub nsw i32 %16, %17
store i32 %18, i32* %4
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = call i64 @triplet(i32 %19, i32 %20, i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %14
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = mul nsw i32 %25, %26
%28 = load i32, i32* %4
%29 = mul nsw i32 %27, %28
store i32 %29, i32* %1
br label %39
30: ; preds = %14
br label %31
31: ; preds = %30
%32 = load i32, i32* %3
%33 = add nsw i32 %32, -1
store i32 %33, i32* %3
br label %11
34: ; preds = %11
br label %35
35: ; preds = %34
%36 = load i32, i32* %2
%37 = add nsw i32 %36, -1
store i32 %37, i32* %2
br label %5
38: ; preds = %5
store i32 0, i32* %1
br label %39
39: ; preds = %38, %24
%40 = load i32, i32* %1
ret i32 %40
}

LLVM IR (-O2):
define i32 @problem_9() {
br label %1
1: ; preds = %0, %16
%2 = phi i32 [ 1000, %0 ], [ %17, %16 ]
%3 = sub nuw nsw i32 1000, %2
br label %4
4: ; preds = %1, %8
%5 = phi i32 [ %6, %8 ], [ %2, %1 ]
%6 = add nsw i32 %5, -1
%7 = icmp sgt i32 %5, 1
br i1 %7, label %8, label %16
8: ; preds = %4
%9 = sub nsw i32 1, %5
%10 = add nsw i32 %3, %9
%11 = tail call i64 @triplet(i32 %2, i32 %6, i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %4, label %13
13: ; preds = %8
%14 = mul nsw i32 %6, %2
%15 = mul nsw i32 %14, %10
br label %19
16: ; preds = %4
%17 = add nsw i32 %2, -1
%18 = icmp ugt i32 %2, 1
br i1 %18, label %1, label %19
19: ; preds = %16, %13
%20 = phi i32 [ %15, %13 ], [ 0, %16 ]
ret i32 %20
}