#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, int, ...);
void print_pythagorean_triples(int low, int high) {
  int n1, n2, n3, s1, s2, s3, tripleCounter = 0;
  for (n1 = low; n1 < high; n1++) {
    for (n2 = n1 + 1; n2 < high; n2++) {
      for (n3 = n2 + 1; n3 < high; n3++) {
        s1 = n1 * n1;
        s2 = n2 * n2;
        s3 = n3 * n3;
        if (s1 + s2 == s3) {
          printf("Triple #%3d:%4d,%3d,%3d", ++tripleCounter, n1, n2, n3);
          printf(" -->%5d +%5d =%5d\n", s1, s2, s3);
        }
      }
    }
  }
}


x86 assembly (clang, -O0):
<print_pythagorean_triples>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ff <print_pythagorean_triples+0xef>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ec <print_pythagorean_triples+0xdc>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d9 <print_pythagorean_triples+0xc9>
mov    -0xc(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    11c6 <print_pythagorean_triples+0xb6>
mov    -0x24(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x24(%rbp)
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cb <print_pythagorean_triples+0xbb>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1155 <print_pythagorean_triples+0x45>
jmp    11de <print_pythagorean_triples+0xce>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1140 <print_pythagorean_triples+0x30>
jmp    11f1 <print_pythagorean_triples+0xe1>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112b <print_pythagorean_triples+0x1b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_pythagorean_triples>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    %esi,%edi
jge    11dd <print_pythagorean_triples+0xcd>
mov    %esi,%r15d
xor    %ebp,%ebp
jmp    113c <print_pythagorean_triples+0x2c>
nopl   (%rax)
mov    (%rsp),%edi
cmp    %r15d,%edi
je     11dd <print_pythagorean_triples+0xcd>
mov    %edi,%r12d
lea    0x1(%r12),%eax
cmp    %r15d,%eax
mov    %eax,(%rsp)
jge    1130 <print_pythagorean_triples+0x20>
mov    %r12d,%ecx
imul   %ecx,%ecx
mov    %rcx,0x8(%rsp)
mov    %eax,%ebx
jmp    116b <print_pythagorean_triples+0x5b>
nopl   0x0(%rax,%rax,1)
mov    0x4(%rsp),%eax
mov    %eax,%ebx
cmp    %r15d,%eax
jge    1130 <print_pythagorean_triples+0x20>
lea    0x1(%rbx),%r13d
cmp    %r15d,%r13d
jge    1130 <print_pythagorean_triples+0x20>
mov    %ebx,%ecx
imul   %ecx,%ecx
mov    0x8(%rsp),%rax
mov    %rcx,0x10(%rsp)
lea    (%rcx,%rax,1),%r14d
mov    %r13d,0x4(%rsp)
jmp    1199 <print_pythagorean_triples+0x89>
xchg   %ax,%ax
add    $0x1,%r13d
cmp    %r15d,%r13d
jge    1160 <print_pythagorean_triples+0x50>
mov    %r13d,%eax
imul   %r13d,%eax
cmp    %eax,%r14d
jne    1190 <print_pythagorean_triples+0x80>
add    $0x1,%ebp
lea    0xe51(%rip),%rdi
mov    %ebp,%esi
mov    %r12d,%edx
mov    %ebx,%ecx
mov    %r13d,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe51(%rip),%rdi
mov    0x8(%rsp),%rsi
mov    0x10(%rsp),%rdx
mov    %r14d,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1190 <print_pythagorean_triples+0x80>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [24 x i8] c"Triple #%3d:%4d,%3d,%3d\00"
@.str.1 = [19 x i8] c" -->%5d +%5d =%5d\0A\00"
define void @print_pythagorean_triples(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, %1
br i1 %3, label %7, label %36
4: ; preds = %15, %14, %7
%5 = phi i32 [ %8, %7 ], [ %16, %15 ], [ %33, %14 ]
%6 = icmp eq i32 %10, %1
br i1 %6, label %36, label %7
7: ; preds = %2, %4
%8 = phi i32 [ %5, %4 ], [ 0, %2 ]
%9 = phi i32 [ %10, %4 ], [ %0, %2 ]
%10 = add i32 %9, 1
%11 = icmp slt i32 %10, %1
br i1 %11, label %12, label %4
12: ; preds = %7
%13 = mul nsw i32 %9, %9
br label %15
14: ; preds = %32
br i1 %19, label %15, label %4
15: ; preds = %12, %14
%16 = phi i32 [ %8, %12 ], [ %33, %14 ]
%17 = phi i32 [ %10, %12 ], [ %18, %14 ]
%18 = add nsw i32 %17, 1
%19 = icmp slt i32 %18, %1
br i1 %19, label %20, label %4
20: ; preds = %15
%21 = mul nsw i32 %17, %17
%22 = add nuw nsw i32 %21, %13
br label %23
23: ; preds = %20, %32
%24 = phi i32 [ %16, %20 ], [ %33, %32 ]
%25 = phi i32 [ %18, %20 ], [ %34, %32 ]
%26 = mul nsw i32 %25, %25
%27 = icmp eq i32 %22, %26
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = add nsw i32 %24, 1
%30 = tail call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %29, i32 %9, i32 %17, i32 %25)
%31 = tail call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %21, i32 %22)
br label %32
32: ; preds = %23, %28
%33 = phi i32 [ %29, %28 ], [ %24, %23 ]
%34 = add nsw i32 %25, 1
%35 = icmp slt i32 %34, %1
br i1 %35, label %23, label %14
36: ; preds = %4, %2
ret void
}