#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 atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "usage: %s <N>\n", argv[0]);
    return 1;
  }
  int N = atoi(argv[1]);
  for (int a = 1; a <= N / 3; a++) {
    int a_square = a * a;
    for (int b = a + 1; b <= N; b++) {
      int c = N - a - b;
      if (c <= b)
        break;
      if (a_square + b * b != c * c)
        continue;
      printf("%d\n", a * b * c);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1178 <main+0x48>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe99(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1248 <main+0x118>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jg     1241 <main+0x111>
mov    -0x18(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     122e <main+0xfe>
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     11e9 <main+0xb9>
jmp    122e <main+0xfe>
mov    -0x1c(%rbp),%eax
mov    -0x20(%rbp),%ecx
imul   -0x20(%rbp),%ecx
add    %ecx,%eax
mov    -0x24(%rbp),%ecx
imul   -0x24(%rbp),%ecx
cmp    %ecx,%eax
je     1209 <main+0xd9>
jmp    1220 <main+0xf0>
mov    -0x18(%rbp),%esi
imul   -0x20(%rbp),%esi
imul   -0x24(%rbp),%esi
lea    0xdf4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c0 <main+0x90>
jmp    1233 <main+0x103>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118f <main+0x5f>
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    $0x28,%rsp
cmp    $0x2,%edi
jne    1247 <main+0x117>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x3,%ecx
jl     1268 <main+0x138>
mov    %ecx,%eax
mov    $0xaaaaaaab,%edx
imul   %rax,%rdx
shr    $0x21,%rdx
mov    %rdx,0x18(%rsp)
mov    %ecx,%ebx
neg    %ebx
lea    -0x3(%rcx),%eax
mov    %eax,0x10(%rsp)
movl   $0x1,0x8(%rsp)
mov    $0x4,%eax
movl   $0x2,0xc(%rsp)
mov    %rcx,0x20(%rsp)
jmp    11c0 <main+0x90>
nopl   0x0(%rax,%rax,1)
addl   $0xfffffffe,0x10(%rsp)
mov    0x14(%rsp),%eax
add    %eax,0xc(%rsp)
add    $0x2,%eax
cmp    0x18(%rsp),%r13d
mov    0x20(%rsp),%rcx
je     1266 <main+0x136>
mov    %eax,0x14(%rsp)
mov    0x8(%rsp),%eax
mov    %eax,%r13d
lea    0x1(%r13),%eax
mov    %eax,0x8(%rsp)
cmp    %ecx,%r13d
jge    11a0 <main+0x70>
mov    %r13d,%r12d
imul   %r13d,%r12d
mov    0xc(%rsp),%r15d
mov    0x10(%rsp),%ebp
mov    0x8(%rsp),%eax
mov    %eax,%r14d
jmp    121b <main+0xeb>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    (%rbx,%r14,1),%eax
add    $0x1,%eax
mov    %r14d,%ecx
add    $0x1,%ecx
add    $0xffffffff,%ebp
add    %r13d,%r15d
mov    %ecx,%r14d
cmp    $0x1,%eax
je     11a0 <main+0x70>
cmp    %r14d,%ebp
jle    11a0 <main+0x70>
mov    %r14d,%eax
imul   %r14d,%eax
add    %r12d,%eax
mov    %ebp,%ecx
imul   %ebp,%ecx
cmp    %ecx,%eax
jne    1200 <main+0xd0>
mov    %r15d,%esi
imul   %ebp,%esi
lea    0xdcf(%rip),%rdi
call   1030 <printf@plt>
jmp    1200 <main+0xd0>
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xda6(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%eax
jmp    1268 <main+0x138>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [15 x i8] c"usage: %s <N>\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %17)
store i32 1, i32* %3
br label %75
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %6
store i32 1, i32* %7
br label %24
24: ; preds = %71, %19
%25 = load i32, i32* %7
%26 = load i32, i32* %6
%27 = sdiv i32 %26, 3
%28 = icmp sle i32 %25, %27
br i1 %28, label %29, label %74
29: ; preds = %24
%30 = load i32, i32* %7
%31 = load i32, i32* %7
%32 = mul nsw i32 %30, %31
store i32 %32, i32* %8
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
br label %35
35: ; preds = %67, %29
%36 = load i32, i32* %9
%37 = load i32, i32* %6
%38 = icmp sle i32 %36, %37
br i1 %38, label %39, label %70
39: ; preds = %35
%40 = load i32, i32* %6
%41 = load i32, i32* %7
%42 = sub nsw i32 %40, %41
%43 = load i32, i32* %9
%44 = sub nsw i32 %42, %43
store i32 %44, i32* %10
%45 = load i32, i32* %10
%46 = load i32, i32* %9
%47 = icmp sle i32 %45, %46
br i1 %47, label %48, label %49
48: ; preds = %39
br label %70
49: ; preds = %39
%50 = load i32, i32* %8
%51 = load i32, i32* %9
%52 = load i32, i32* %9
%53 = mul nsw i32 %51, %52
%54 = add nsw i32 %50, %53
%55 = load i32, i32* %10
%56 = load i32, i32* %10
%57 = mul nsw i32 %55, %56
%58 = icmp ne i32 %54, %57
br i1 %58, label %59, label %60
59: ; preds = %49
br label %67
60: ; preds = %49
%61 = load i32, i32* %7
%62 = load i32, i32* %9
%63 = mul nsw i32 %61, %62
%64 = load i32, i32* %10
%65 = mul nsw i32 %63, %64
%66 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %65)
br label %67
67: ; preds = %60, %59
%68 = load i32, i32* %9
%69 = add nsw i32 %68, 1
store i32 %69, i32* %9
br label %35
70: ; preds = %48, %35
br label %71
71: ; preds = %70
%72 = load i32, i32* %7
%73 = add nsw i32 %72, 1
store i32 %73, i32* %7
br label %24
74: ; preds = %24
store i32 0, i32* %3
br label %75
75: ; preds = %74, %13
%76 = load i32, i32* %3
ret i32 %76
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [15 x i8] c"usage: %s <N>\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %39
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = icmp slt i32 %11, 3
br i1 %12, label %39, label %13
13: ; preds = %8
%14 = udiv i32 %11, 3
br label %15
15: ; preds = %13, %37
%16 = phi i32 [ %18, %37 ], [ 1, %13 ]
%17 = mul nsw i32 %16, %16
%18 = add nuw nsw i32 %16, 1
%19 = icmp slt i32 %16, %11
br i1 %19, label %20, label %37
20: ; preds = %15, %34
%21 = phi i32 [ %35, %34 ], [ %18, %15 ]
%22 = add nuw i32 %16, %21
%23 = sub i32 %11, %22
%24 = icmp sgt i32 %23, %21
br i1 %24, label %25, label %37
25: ; preds = %20
%26 = mul nsw i32 %21, %21
%27 = add nuw nsw i32 %26, %17
%28 = mul nsw i32 %23, %23
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %34
30: ; preds = %25
%31 = mul nsw i32 %21, %16
%32 = mul nsw i32 %31, %23
%33 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %30, %25
%35 = add nuw nsw i32 %21, 1
%36 = icmp eq i32 %21, %11
br i1 %36, label %37, label %20
37: ; preds = %34, %20, %15
%38 = icmp eq i32 %16, %14
br i1 %38, label %39, label %15
39: ; preds = %37, %8, %4
%40 = phi i32 [ 1, %4 ], [ 0, %8 ], [ 0, %37 ]
ret i32 %40
}