#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*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ pow2(int);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ stderr;
int main(void) {
  int a_found = 0, b_found = 0;
  for (int a_test = 1; a_test < 1000; ++a_test) {
    int asquared = pow2(a_test);
    for (int b_test = a_test + 1; b_test < (1000 - a_test); ++b_test) {
      if (pow2(1000 - a_test - b_test) == (asquared + pow2(b_test))) {
        a_found = a_test;
        b_found = b_test;
        break;
      }
    }
    if (a_found != 0) {
      break;
    }
  }
  if (a_found == 0) {
    fprintf(stderr, "nothing found for a and b!\n");
    return -1;
  }
  int c_found = 1000 - a_found - b_found;
  printf("found: a=%d, b=%d, c=%d\n", a_found, b_found, c_found);
  printf("a*b*c: %d\n", a_found * b_found * c_found);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x3e8,-0x10(%rbp)
jge    1209 <main+0xd9>
mov    -0x10(%rbp),%edi
call   1030 <pow2@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x3e8,%ecx
sub    -0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    11e7 <main+0xb7>
mov    $0x3e8,%edi
sub    -0x10(%rbp),%edi
sub    -0x18(%rbp),%edi
call   1030 <pow2@plt>
mov    %rax,-0x28(%rbp)
movslq -0x14(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <pow2@plt>
mov    -0x30(%rbp),%rcx
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
add    %rdx,%rcx
cmp    %rcx,%rax
jne    11d4 <main+0xa4>
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11e7 <main+0xb7>
jmp    11d9 <main+0xa9>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1175 <main+0x45>
cmpl   $0x0,-0x8(%rbp)
je     11f6 <main+0xc6>
jmp    1209 <main+0xd9>
jmp    11fb <main+0xcb>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1154 <main+0x24>
cmpl   $0x0,-0x8(%rbp)
jne    1234 <main+0x104>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
lea    0xddd(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1279 <main+0x149>
mov    $0x3e8,%eax
sub    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
imul   -0xc(%rbp),%esi
imul   -0x1c(%rbp),%esi
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%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,%ecx
movl   $0x3e5,0xc(%rsp)
mov    $0x4,%eax
movl   $0x2,0x8(%rsp)
jmp    1180 <main+0x50>
nopw   0x0(%rax,%rax,1)
addl   $0xfffffffe,0xc(%rsp)
mov    0x14(%rsp),%eax
add    %eax,0x8(%rsp)
add    $0x2,%eax
mov    0x10(%rsp),%ecx
cmp    $0x3e8,%ecx
je     1228 <main+0xf8>
mov    %eax,0x14(%rsp)
mov    %ecx,%r14d
mov    %ecx,%edi
call   1030 <pow2@plt>
lea    0x1(%r14),%edx
mov    $0x3e8,%ecx
sub    %r14d,%ecx
mov    %edx,0x10(%rsp)
cmp    %edx,%ecx
jbe    1160 <main+0x30>
movslq %eax,%r13
mov    0x8(%rsp),%r15d
mov    0xc(%rsp),%ebx
mov    0x10(%rsp),%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
call   1030 <pow2@plt>
mov    %rax,%r12
mov    %ebp,%edi
call   1030 <pow2@plt>
add    %r13,%rax
cmp    %rax,%r12
je     11e9 <main+0xb9>
add    $0x1,%ebp
add    %r14d,%r15d
add    $0xffffffff,%ebx
jne    11c0 <main+0x90>
jmp    1160 <main+0x30>
lea    0xe2c(%rip),%rdi
xor    %r12d,%r12d
mov    %r14d,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
imul   %ebx,%r15d
lea    0xe29(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2db1(%rip),%rax
mov    (%rax),%edi
lea    0xdc8(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%r12d
jmp    1216 <main+0xe6>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"nothing found for a and b!\0A\00"
@.str.1 = [25 x i8] c"found: a=%d, b=%d, c=%d\0A\00"
@.str.2 = [11 x i8] c"a*b*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
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 1, i32* %4
br label %8
8: ; preds = %46, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 1000
br i1 %10, label %11, label %49
11: ; preds = %8
%12 = load i32, i32* %4
%13 = call i64 @pow2(i32 %12)
%14 = trunc i64 %13 to i32
store i32 %14, i32* %5
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %6
br label %17
17: ; preds = %38, %11
%18 = load i32, i32* %6
%19 = load i32, i32* %4
%20 = sub nsw i32 1000, %19
%21 = icmp slt i32 %18, %20
br i1 %21, label %22, label %41
22: ; preds = %17
%23 = load i32, i32* %4
%24 = sub nsw i32 1000, %23
%25 = load i32, i32* %6
%26 = sub nsw i32 %24, %25
%27 = call i64 @pow2(i32 %26)
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = load i32, i32* %6
%31 = call i64 @pow2(i32 %30)
%32 = add nsw i64 %29, %31
%33 = icmp eq i64 %27, %32
br i1 %33, label %34, label %37
34: ; preds = %22
%35 = load i32, i32* %4
store i32 %35, i32* %2
%36 = load i32, i32* %6
store i32 %36, i32* %3
br label %41
37: ; preds = %22
br label %38
38: ; preds = %37
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
br label %17
41: ; preds = %34, %17
%42 = load i32, i32* %2
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %41
br label %49
45: ; preds = %41
br label %46
46: ; preds = %45
%47 = load i32, i32* %4
%48 = add nsw i32 %47, 1
store i32 %48, i32* %4
br label %8
49: ; preds = %44, %8
%50 = load i32, i32* %2
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = load i32, i32* @stderr
%54 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %70
55: ; preds = %49
%56 = load i32, i32* %2
%57 = sub nsw i32 1000, %56
%58 = load i32, i32* %3
%59 = sub nsw i32 %57, %58
store i32 %59, i32* %7
%60 = load i32, i32* %2
%61 = load i32, i32* %3
%62 = load i32, i32* %7
%63 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %60, i32 %61, i32 %62)
%64 = load i32, i32* %2
%65 = load i32, i32* %3
%66 = mul nsw i32 %64, %65
%67 = load i32, i32* %7
%68 = mul nsw i32 %66, %67
%69 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %68)
store i32 0, i32* %1
br label %70
70: ; preds = %55, %52
%71 = load i32, i32* %1
ret i32 %71
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"nothing found for a and b!\0A\00"
@.str.1 = [25 x i8] c"found: a=%d, b=%d, c=%d\0A\00"
@.str.2 = [11 x i8] c"a*b*c: %d\0A\00"
define i32 @main() {
br label %4
1: ; preds = %21, %4
%2 = add nsw i32 %5, -1
%3 = icmp eq i32 %8, 1000
br i1 %3, label %24, label %4
4: ; preds = %0, %1
%5 = phi i32 [ 999, %0 ], [ %2, %1 ]
%6 = phi i32 [ 1, %0 ], [ %8, %1 ]
%7 = tail call i64 @pow2(i32 %6)
%8 = add nuw nsw i32 %6, 1
%9 = sub nuw nsw i32 1000, %6
%10 = icmp ugt i32 %9, %8
br i1 %10, label %11, label %1
11: ; preds = %4
%12 = shl i64 %7, 32
%13 = ashr exact i64 %12, 32
br label %14
14: ; preds = %11, %21
%15 = phi i32 [ %8, %11 ], [ %22, %21 ]
%16 = sub nsw i32 %9, %15
%17 = tail call i64 @pow2(i32 %16)
%18 = tail call i64 @pow2(i32 %15)
%19 = add nsw i64 %18, %13
%20 = icmp eq i64 %17, %19
br i1 %20, label %27, label %21
21: ; preds = %14
%22 = add nuw nsw i32 %15, 1
%23 = icmp eq i32 %22, %5
br i1 %23, label %1, label %14
24: ; preds = %1
%25 = load i32, i32* @stderr
%26 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %34
27: ; preds = %14
%28 = add nuw i32 %6, %15
%29 = sub i32 1000, %28
%30 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %15, i32 %29)
%31 = mul nsw i32 %15, %6
%32 = mul nsw i32 %31, %29
%33 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %27, %24
%35 = phi i32 [ -1, %24 ], [ 0, %27 ]
ret i32 %35
}