#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
void pifagor() {
  long a, b, c;
  long long a2, b2, c2;
  for (a = 3;; ++a) {
    b = a - 1;
    a2 = (long long)a * a;
    b2 = (long long)b * b;
    for (c = 1; c < b; ++c) {
      c2 = (long long)c * c;
      if (a2 == b2 + c2) {
        printf("%ld - %ld - %ld\n", a, b, c);
        fflush(stdout);
        break;
      }
      if (a2 < b2 + c2)
        break;
    }
    if (a % 1000 == 0) {
      printf(".");
      fflush(stdout);
    }
  }
}


x86 assembly (clang, -O0):
<pifagor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movq   $0x3,-0x8(%rbp)
mov    -0x8(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
imul   -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
imul   -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    11eb <pifagor+0xcb>
mov    -0x18(%rbp),%rax
imul   -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
add    -0x30(%rbp),%rcx
cmp    %rcx,%rax
jne    11bb <pifagor+0x9b>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
jmp    11eb <pifagor+0xcb>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
add    -0x30(%rbp),%rcx
cmp    %rcx,%rax
jge    11d5 <pifagor+0xb5>
jmp    11eb <pifagor+0xcb>
jmp    11da <pifagor+0xba>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    115e <pifagor+0x3e>
mov    -0x8(%rbp),%rax
mov    $0x3e8,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    121f <pifagor+0xff>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
jmp    1224 <pifagor+0x104>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1130 <pifagor+0x10>

x86 assembly (clang, -O2):
<pifagor>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    $0x3,%ebx
lea    0xebb(%rip),%r14
mov    0x2e94(%rip),%r15
movabs $0x1cac083126e978d5,%r12
08 ac 1c
movabs $0x4189374bc6a7ef,%r13
jmp    1174 <pifagor+0x44>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
lea    -0x1(%rbx),%rdx
mov    %rbx,%rax
imul   %rbx,%rax
mov    %rdx,%rsi
imul   %rdx,%rsi
mov    $0x1,%ecx
nopl   0x0(%rax,%rax,1)
mov    %rcx,%rdi
imul   %rcx,%rdi
add    %rsi,%rdi
cmp    %rdi,%rax
je     11b0 <pifagor+0x80>
jb     11c5 <pifagor+0x95>
add    $0x1,%rcx
cmp    %rdx,%rcx
jb     1190 <pifagor+0x60>
jmp    11c5 <pifagor+0x95>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r15),%edi
call   1050 <fflush@plt>
mov    %rbx,%rax
imul   %r12,%rax
ror    $0x3,%rax
cmp    %r13,%rax
ja     1170 <pifagor+0x40>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    (%r15),%edi
call   1050 <fflush@plt>
jmp    1170 <pifagor+0x40>

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

LLVM IR (-O2):
@.str = [17 x i8] c"%ld - %ld - %ld\0A\00"
@stdout = global i32 0
define void @pifagor() {
br label %1
1: ; preds = %0, %27
%2 = phi i64 [ 3, %0 ], [ %28, %27 ]
%3 = add nsw i64 %2, -1
%4 = mul nsw i64 %2, %2
%5 = mul nsw i64 %3, %3
br label %6
6: ; preds = %1, %15
%7 = phi i64 [ %17, %15 ], [ 1, %1 ]
%8 = mul nsw i64 %7, %7
%9 = add nuw nsw i64 %8, %5
%10 = icmp eq i64 %4, %9
br i1 %10, label %11, label %15
11: ; preds = %6
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %2, i64 %3, i64 %7)
%13 = load i32, i32* @stdout
%14 = tail call i32 @fflush(i32 %13)
br label %20
15: ; preds = %6
%16 = icmp uge i64 %4, %9
%17 = add nuw nsw i64 %7, 1
%18 = icmp ult i64 %17, %3
%19 = select i1 %16, i1 %18, i1 false
br i1 %19, label %6, label %20
20: ; preds = %15, %11
%21 = urem i64 %2, 1000
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = tail call i32 @putchar(i32 46)
%25 = load i32, i32* @stdout
%26 = tail call i32 @fflush(i32 %25)
br label %27
27: ; preds = %20, %23
%28 = add nuw nsw i64 %2, 1
br label %1
}