#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 gcd(int, int);
int get_hypotenuse(int, int);
int /*<<< orphan*/ printf(char *, ...);
void generate_triple(int max) {
  int i, j;
  for (i = 1; i < max; i++) {
    for (j = 1; j < i; j++) {
      if (gcd(i, j) == 1) {
        int hyp = get_hypotenuse(i, j);
        if (hyp) {
          printf("%4d %4d %4d\n", j, i, hyp);
          break;
        }
      }
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<generate_triple>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11d4 <generate_triple+0xa4>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c1 <generate_triple+0x91>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <gcd@plt>
cmp    $0x1,%eax
jne    11ae <generate_triple+0x7e>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <get_hypotenuse@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11a9 <generate_triple+0x79>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c1 <generate_triple+0x91>
jmp    11ae <generate_triple+0x7e>
jmp    11b3 <generate_triple+0x83>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1155 <generate_triple+0x25>
jmp    11c6 <generate_triple+0x96>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1142 <generate_triple+0x12>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_triple>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x2,%edi
jl     11d0 <generate_triple+0x90>
mov    %edi,%r15d
mov    $0x1,%ebp
lea    0xea0(%rip),%r14
xor    %r12d,%r12d
jmp    117c <generate_triple+0x3c>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebp
add    $0xffffffff,%r12d
cmp    %r15d,%ebp
je     11d0 <generate_triple+0x90>
cmp    $0x2,%ebp
jb     1170 <generate_triple+0x30>
mov    $0x1,%ebx
jmp    11a3 <generate_triple+0x63>
nopl   0x0(%rax,%rax,1)
lea    (%r12,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
je     1170 <generate_triple+0x30>
mov    %ebp,%edi
mov    %ebx,%esi
call   1060 <gcd@plt>
cmp    $0x1,%eax
jne    1190 <generate_triple+0x50>
mov    %ebp,%edi
mov    %ebx,%esi
call   1050 <get_hypotenuse@plt>
test   %eax,%eax
je     1190 <generate_triple+0x50>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1170 <generate_triple+0x30>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"%4d %4d %4d\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @generate_triple(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
br label %6
6: ; preds = %37, %1
%7 = load i32, i32* %3
%8 = load i32, i32* %2
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %40
10: ; preds = %6
store i32 1, i32* %4
br label %11
11: ; preds = %33, %10
%12 = load i32, i32* %4
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %36
15: ; preds = %11
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = call i32 @gcd(i32 %16, i32 %17)
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %32
20: ; preds = %15
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = call i32 @get_hypotenuse(i32 %21, i32 %22)
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %20
%27 = load i32, i32* %4
%28 = load i32, i32* %3
%29 = load i32, i32* %5
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %27, i32 %28, i32 %29)
br label %36
31: ; preds = %20
br label %32
32: ; preds = %31, %15
br label %33
33: ; preds = %32
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %11
36: ; preds = %26, %11
br label %37
37: ; preds = %36
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %6
40: ; preds = %6
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"%4d %4d %4d\0A\00"
define void @generate_triple(i32 %0) {
%2 = icmp sgt i32 %0, 1
br i1 %2, label %3, label %21
3: ; preds = %1, %18
%4 = phi i32 [ %19, %18 ], [ 1, %1 ]
%5 = icmp ugt i32 %4, 1
br i1 %5, label %6, label %18
6: ; preds = %3, %15
%7 = phi i32 [ %16, %15 ], [ 1, %3 ]
%8 = tail call i32 @gcd(i32 %4, i32 %7)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %15
10: ; preds = %6
%11 = tail call i32 @get_hypotenuse(i32 %4, i32 %7)
%12 = icmp eq i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %4, i32 %11)
br label %18
15: ; preds = %10, %6
%16 = add nuw nsw i32 %7, 1
%17 = icmp eq i32 %16, %4
br i1 %17, label %18, label %6
18: ; preds = %15, %3, %13
%19 = add nuw nsw i32 %4, 1
%20 = icmp eq i32 %19, %0
br i1 %20, label %21, label %3
21: ; preds = %18, %1
%22 = tail call i32 @putchar(i32 10)
ret void
}