#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, int);
scalar_t__ pythagorean(int, int, int);
void search(int perimeter) {
  int a, b, c, abc;
  for (a = 1; a < perimeter; a++) {
    for (b = 1 + a; b < perimeter; b++) {
      c = perimeter - a - b;
      if (c > 0 && pythagorean(a, b, c)) {
        abc = a * b * c;
        printf("a,b,c = %i, %i, %i ; a*b*c = %i \n", a, b, c, abc);
      }
    }
  }
}


x86 assembly (clang, -O0):
<search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ce <search+0xae>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11bb <search+0x9b>
mov    -0x4(%rbp),%eax
sub    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    11a8 <search+0x88>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <pythagorean@plt>
cmp    $0x0,%rax
je     11a8 <search+0x88>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
jmp    11ad <search+0x8d>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1147 <search+0x27>
jmp    11c0 <search+0xa0>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1132 <search+0x12>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jl     11df <search+0xbf>
mov    %edi,%r15d
lea    -0x3(%r15),%eax
mov    %eax,0x10(%rsp)
mov    $0x1,%eax
mov    $0x4,%r14d
movl   $0x2,0xc(%rsp)
jmp    1177 <search+0x57>
nopw   0x0(%rax,%rax,1)
addl   $0xfffffffe,0x10(%rsp)
add    %r14d,0xc(%rsp)
add    $0x2,%r14d
mov    0x14(%rsp),%eax
cmp    %r15d,%eax
je     11df <search+0xbf>
mov    %eax,%r12d
lea    0x1(%r12),%eax
mov    %eax,0x14(%rsp)
cmp    %r15d,%eax
jge    1160 <search+0x40>
mov    0xc(%rsp),%r13d
mov    0x10(%rsp),%ebp
mov    0x14(%rsp),%ebx
jmp    11ae <search+0x8e>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebx
add    $0xffffffff,%ebp
add    %r12d,%r13d
cmp    %ebx,%r15d
je     1160 <search+0x40>
test   %ebp,%ebp
jle    11a0 <search+0x80>
mov    %r12d,%edi
mov    %ebx,%esi
mov    %ebp,%edx
call   1040 <pythagorean@plt>
test   %rax,%rax
je     11a0 <search+0x80>
mov    %r13d,%r8d
imul   %ebp,%r8d
lea    0xe2f(%rip),%rdi
mov    %r12d,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
call   1030 <printf@plt>
jmp    11a0 <search+0x80>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"a,b,c = %i, %i, %i ; a*b*c = %i \0A\00"
define void @search(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
br label %7
7: ; preds = %48, %1
%8 = load i32, i32* %3
%9 = load i32, i32* %2
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %51
11: ; preds = %7
%12 = load i32, i32* %3
%13 = add nsw i32 1, %12
store i32 %13, i32* %4
br label %14
14: ; preds = %44, %11
%15 = load i32, i32* %4
%16 = load i32, i32* %2
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %47
18: ; preds = %14
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = sub nsw i32 %19, %20
%22 = load i32, i32* %4
%23 = sub nsw i32 %21, %22
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %43
26: ; preds = %18
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = load i32, i32* %5
%30 = call i64 @pythagorean(i32 %27, i32 %28, i32 %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %43
32: ; preds = %26
%33 = load i32, i32* %3
%34 = load i32, i32* %4
%35 = mul nsw i32 %33, %34
%36 = load i32, i32* %5
%37 = mul nsw i32 %35, %36
store i32 %37, i32* %6
%38 = load i32, i32* %3
%39 = load i32, i32* %4
%40 = load i32, i32* %5
%41 = load i32, i32* %6
%42 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %38, i32 %39, i32 %40, i32 %41)
br label %43
43: ; preds = %32, %26, %18
br label %44
44: ; preds = %43
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
br label %14
47: ; preds = %14
br label %48
48: ; preds = %47
%49 = load i32, i32* %3
%50 = add nsw i32 %49, 1
store i32 %50, i32* %3
br label %7
51: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [34 x i8] c"a,b,c = %i, %i, %i ; a*b*c = %i \0A\00"
define void @search(i32 %0) {
%2 = icmp sgt i32 %0, 1
br i1 %2, label %5, label %24
3: ; preds = %21, %5
%4 = icmp eq i32 %7, %0
br i1 %4, label %24, label %5
5: ; preds = %1, %3
%6 = phi i32 [ %7, %3 ], [ 1, %1 ]
%7 = add nuw nsw i32 %6, 1
%8 = icmp slt i32 %7, %0
br i1 %8, label %9, label %3
9: ; preds = %5, %21
%10 = phi i32 [ %22, %21 ], [ %7, %5 ]
%11 = add nuw i32 %6, %10
%12 = sub i32 %0, %11
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %9
%15 = tail call i64 @pythagorean(i32 %6, i32 %10, i32 %12)
%16 = icmp eq i64 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = mul nsw i32 %10, %6
%19 = mul nsw i32 %18, %12
%20 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %10, i32 %12, i32 %19)
br label %21
21: ; preds = %9, %14, %17
%22 = add nuw i32 %10, 1
%23 = icmp eq i32 %22, %0
br i1 %23, label %3, label %9
24: ; preds = %3, %1
ret void
}