#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 *, unsigned int, unsigned int, unsigned int);
int /*<<< orphan*/ puts(char *);
int main(void) {
  unsigned int contatoreLatoA;
  unsigned int contatoreLatoB;
  unsigned int contatoreLatoC;
  puts("E' in azione l'algoritmo per scoprire le Triple pitagoriche");
  for (contatoreLatoA = 1; contatoreLatoA <= 500; contatoreLatoA++) {
    for (contatoreLatoB = 1; contatoreLatoB <= 500; contatoreLatoB++) {
      for (contatoreLatoC = 1; contatoreLatoC <= 500; contatoreLatoC++) {
        if (((contatoreLatoA * contatoreLatoA) +
             (contatoreLatoB * contatoreLatoB)) ==
            (contatoreLatoC * contatoreLatoC)) {
          printf("Tripla pitagorica trovata! LatoA: %u LatoB: %u LatoC: %u\n",
                 contatoreLatoA, contatoreLatoB, contatoreLatoC);
        }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x1f4,-0x8(%rbp)
ja     11e4 <main+0xc4>
movl   $0x1,-0xc(%rbp)
cmpl   $0x1f4,-0xc(%rbp)
ja     11d1 <main+0xb1>
movl   $0x1,-0x10(%rbp)
cmpl   $0x1f4,-0x10(%rbp)
ja     11be <main+0x9e>
mov    -0x8(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    %ecx,%eax
mov    -0x10(%rbp),%ecx
imul   -0x10(%rbp),%ecx
cmp    %ecx,%eax
jne    11ab <main+0x8b>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
jmp    11b0 <main+0x90>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116a <main+0x4a>
jmp    11c3 <main+0xa3>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1156 <main+0x36>
jmp    11d6 <main+0xb6>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1142 <main+0x22>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r15d
lea    0xef8(%rip),%r14
jmp    115d <main+0x3d>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r15d
cmp    $0x1f5,%r15d
je     11b6 <main+0x96>
mov    %r15d,%r12d
imul   %r15d,%r12d
mov    $0x1,%r13d
jmp    117d <main+0x5d>
nopl   0x0(%rax)
add    $0x1,%r13d
cmp    $0x1f5,%r13d
je     1150 <main+0x30>
mov    %r13d,%ebp
imul   %r13d,%ebp
add    %r12d,%ebp
mov    $0x1,%ebx
jmp    119b <main+0x7b>
xchg   %ax,%ax
add    $0x1,%ebx
cmp    $0x1f5,%ebx
je     1170 <main+0x50>
mov    %ebx,%eax
imul   %ebx,%eax
cmp    %eax,%ebp
jne    1190 <main+0x70>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %r13d,%edx
mov    %ebx,%ecx
call   1040 <printf@plt>
jmp    1190 <main+0x70>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [60 x i8] c"E' in azione l'algoritmo per scoprire le Triple pitagoriche\00"
@.str.1 = [58 x i8] c"Tripla pitagorica trovata! LatoA: %u LatoB: %u LatoC: %u\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @puts(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
br label %6
6: ; preds = %43, %0
%7 = load i32, i32* %2
%8 = icmp ule i32 %7, 500
br i1 %8, label %9, label %46
9: ; preds = %6
store i32 1, i32* %3
br label %10
10: ; preds = %39, %9
%11 = load i32, i32* %3
%12 = icmp ule i32 %11, 500
br i1 %12, label %13, label %42
13: ; preds = %10
store i32 1, i32* %4
br label %14
14: ; preds = %35, %13
%15 = load i32, i32* %4
%16 = icmp ule i32 %15, 500
br i1 %16, label %17, label %38
17: ; preds = %14
%18 = load i32, i32* %2
%19 = load i32, i32* %2
%20 = mul i32 %18, %19
%21 = load i32, i32* %3
%22 = load i32, i32* %3
%23 = mul i32 %21, %22
%24 = add i32 %20, %23
%25 = load i32, i32* %4
%26 = load i32, i32* %4
%27 = mul i32 %25, %26
%28 = icmp eq i32 %24, %27
br i1 %28, label %29, label %34
29: ; preds = %17
%30 = load i32, i32* %2
%31 = load i32, i32* %3
%32 = load i32, i32* %4
%33 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0), i32 %30, i32 %31, i32 %32)
br label %34
34: ; preds = %29, %17
br label %35
35: ; preds = %34
%36 = load i32, i32* %4
%37 = add i32 %36, 1
store i32 %37, i32* %4
br label %14
38: ; preds = %14
br label %39
39: ; preds = %38
%40 = load i32, i32* %3
%41 = add i32 %40, 1
store i32 %41, i32* %3
br label %10
42: ; preds = %10
br label %43
43: ; preds = %42
%44 = load i32, i32* %2
%45 = add i32 %44, 1
store i32 %45, i32* %2
br label %6
46: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [60 x i8] c"E' in azione l'algoritmo per scoprire le Triple pitagoriche\00"
@.str.1 = [58 x i8] c"Tripla pitagorica trovata! LatoA: %u LatoB: %u LatoC: %u\0A\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
br label %2
2: ; preds = %0, %21
%3 = phi i32 [ 1, %0 ], [ %22, %21 ]
%4 = mul i32 %3, %3
br label %5
5: ; preds = %2, %18
%6 = phi i32 [ 1, %2 ], [ %19, %18 ]
%7 = mul i32 %6, %6
%8 = add i32 %7, %4
br label %9
9: ; preds = %5, %15
%10 = phi i32 [ 1, %5 ], [ %16, %15 ]
%11 = mul nuw nsw i32 %10, %10
%12 = icmp eq i32 %8, %11
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0), i32 %3, i32 %6, i32 %10)
br label %15
15: ; preds = %9, %13
%16 = add nuw nsw i32 %10, 1
%17 = icmp eq i32 %16, 501
br i1 %17, label %18, label %9
18: ; preds = %15
%19 = add nuw nsw i32 %6, 1
%20 = icmp eq i32 %19, 501
br i1 %20, label %21, label %5
21: ; preds = %18
%22 = add nuw nsw i32 %3, 1
%23 = icmp eq i32 %22, 501
br i1 %23, label %24, label %2
24: ; preds = %21
ret i32 0
}