#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 find_pythagorean(int);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int a, b, c;
  int loops = 0;
  for (a = 1; a < 325; a++) {
    int lb = 500 - a / 2;
    for (b = 326; b < lb; b++) {
      c = 1000 - a - b;
      loops++;
      if (!(a < b && b < c)) {
        continue;
      }
      if (a * a + b * b == c * c) {
        printf(" got it a=%d, b=%d, c=%d, %d + %d = %d\n", a, b, c, a * a,
               b * b, c * c);
        printf(" product is %d\n", (a * b * c));
        goto done;
      }
    }
  }
done:
  printf(" using loops %d\n", loops);
  printf(" no try some new methods\n");
  printf("find sum is 1000 pythagorean is %d\n", find_pythagorean(1000));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x145,-0x8(%rbp)
jge    123e <main+0x11e>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0x1f4,%eax
sub    %ecx,%eax
mov    %eax,-0x18(%rbp)
movl   $0x146,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    122b <main+0x10b>
mov    $0x3e8,%eax
sub    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a3 <main+0x83>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     11a8 <main+0x88>
jmp    121d <main+0xfd>
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    1218 <main+0xf8>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x8(%rbp),%r8d
imul   -0x8(%rbp),%r8d
mov    -0xc(%rbp),%r9d
imul   -0xc(%rbp),%r9d
mov    -0x10(%rbp),%eax
imul   -0x10(%rbp),%eax
lea    0xe10(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
imul   -0xc(%rbp),%esi
imul   -0x10(%rbp),%esi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1243 <main+0x123>
jmp    121d <main+0xfd>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1168 <main+0x48>
jmp    1230 <main+0x110>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113d <main+0x1d>
jmp    1243 <main+0x123>
mov    -0x14(%rbp),%esi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x3e8,%edi
call   1040 <find_pythagorean@plt>
mov    %eax,%esi
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1,%esi
xor    %eax,%eax
mov    $0x146,%r10d
mov    $0x2a1,%r11d
jmp    116a <main+0x3a>
nopl   0x0(%rax)
add    $0x1,%esi
add    $0x146,%r10d
add    $0xffffffff,%r11d
cmp    $0x145,%esi
je     11ee <main+0xbe>
mov    %eax,%r14d
mov    %esi,%ecx
shr    %ecx
mov    %esi,%r8d
imul   %r8d,%r8d
sub    %ecx,%eax
add    $0xae,%eax
add    $0x1,%r14d
mov    %r11d,%ebx
mov    %r10d,%r15d
mov    $0x146,%edx
jmp    11ab <main+0x7b>
add    $0x1,%r14d
lea    (%rcx,%rdx,1),%edi
add    $0x1,%edi
add    $0x1,%edx
add    %esi,%r15d
add    $0xffffffff,%ebx
cmp    $0x1f4,%edi
je     1150 <main+0x20>
cmp    %ebx,%edx
jae    1190 <main+0x60>
mov    %edx,%r9d
imul   %r9d,%r9d
lea    (%r9,%r8,1),%edi
mov    %ebx,%ebp
imul   %ebx,%ebp
cmp    %ebp,%edi
jne    1190 <main+0x60>
mov    %edi,(%rsp)
lea    0xe33(%rip),%rdi
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
imul   %ebx,%r15d
lea    0xe47(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%eax
lea    0xe43(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe68(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3e8,%edi
call   1050 <find_pythagorean@plt>
lea    0xe2e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c" got it a=%d, b=%d, c=%d, %d + %d = %d\0A\00"
@.str.1 = [16 x i8] c" product is %d\0A\00"
@.str.2 = [17 x i8] c" using loops %d\0A\00"
@.str.3 = [26 x i8] c" no try some new methods\0A\00"
@.str.4 = [36 x i8] c"find sum is 1000 pythagorean is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 1, i32* %2
br label %7
7: ; preds = %70, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 325
br i1 %9, label %10, label %73
10: ; preds = %7
%11 = load i32, i32* %2
%12 = sdiv i32 %11, 2
%13 = sub nsw i32 500, %12
store i32 %13, i32* %6
store i32 326, i32* %3
br label %14
14: ; preds = %66, %10
%15 = load i32, i32* %3
%16 = load i32, i32* %6
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %69
18: ; preds = %14
%19 = load i32, i32* %2
%20 = sub nsw i32 1000, %19
%21 = load i32, i32* %3
%22 = sub nsw i32 %20, %21
store i32 %22, i32* %4
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %32
28: ; preds = %18
%29 = load i32, i32* %3
%30 = load i32, i32* %4
%31 = icmp slt i32 %29, %30
br i1 %31, label %33, label %32
32: ; preds = %28, %18
br label %66
33: ; preds = %28
%34 = load i32, i32* %2
%35 = load i32, i32* %2
%36 = mul nsw i32 %34, %35
%37 = load i32, i32* %3
%38 = load i32, i32* %3
%39 = mul nsw i32 %37, %38
%40 = add nsw i32 %36, %39
%41 = load i32, i32* %4
%42 = load i32, i32* %4
%43 = mul nsw i32 %41, %42
%44 = icmp eq i32 %40, %43
br i1 %44, label %45, label %65
45: ; preds = %33
%46 = load i32, i32* %2
%47 = load i32, i32* %3
%48 = load i32, i32* %4
%49 = load i32, i32* %2
%50 = load i32, i32* %2
%51 = mul nsw i32 %49, %50
%52 = load i32, i32* %3
%53 = load i32, i32* %3
%54 = mul nsw i32 %52, %53
%55 = load i32, i32* %4
%56 = load i32, i32* %4
%57 = mul nsw i32 %55, %56
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %46, i32 %47, i32 %48, i32 %51, i32 %54, i32 %57)
%59 = load i32, i32* %2
%60 = load i32, i32* %3
%61 = mul nsw i32 %59, %60
%62 = load i32, i32* %4
%63 = mul nsw i32 %61, %62
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %63)
br label %74
65: ; preds = %33
br label %66
66: ; preds = %65, %32
%67 = load i32, i32* %3
%68 = add nsw i32 %67, 1
store i32 %68, i32* %3
br label %14
69: ; preds = %14
br label %70
70: ; preds = %69
%71 = load i32, i32* %2
%72 = add nsw i32 %71, 1
store i32 %72, i32* %2
br label %7
73: ; preds = %7
br label %74
74: ; preds = %73, %45
%75 = load i32, i32* %5
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %75)
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%78 = call i32 @find_pythagorean(i32 1000)
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i32 %78)
ret i32 0
}

LLVM IR (-O2):
@.str = [40 x i8] c" got it a=%d, b=%d, c=%d, %d + %d = %d\0A\00"
@.str.1 = [16 x i8] c" product is %d\0A\00"
@.str.2 = [17 x i8] c" using loops %d\0A\00"
@.str.4 = [36 x i8] c"find sum is 1000 pythagorean is %d\0A\00"
@str = [25 x i8] c" no try some new methods\00"
define i32 @main() {
br label %1
1: ; preds = %28, %0
%2 = phi i32 [ 0, %0 ], [ %7, %28 ]
%3 = phi i32 [ 1, %0 ], [ %29, %28 ]
%4 = lshr i32 %3, 1
%5 = mul nsw i32 %3, %3
%6 = add i32 %2, 174
%7 = sub i32 %6, %4
br label %8
8: ; preds = %1, %20
%9 = phi i32 [ %2, %1 ], [ %13, %20 ]
%10 = phi i32 [ 326, %1 ], [ %21, %20 ]
%11 = add nuw nsw i32 %3, %10
%12 = sub nuw nsw i32 1000, %11
%13 = add i32 %9, 1
%14 = icmp ult i32 %10, %12
br i1 %14, label %15, label %20
15: ; preds = %8
%16 = mul nsw i32 %10, %10
%17 = add nuw nsw i32 %16, %5
%18 = mul nuw nsw i32 %12, %12
%19 = icmp eq i32 %17, %18
br i1 %19, label %23, label %20
20: ; preds = %15, %8
%21 = add nuw nsw i32 %10, 1
%22 = icmp eq i32 %13, %7
br i1 %22, label %28, label %8
23: ; preds = %15
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %10, i32 %12, i32 %5, i32 %16, i32 %17)
%25 = mul nsw i32 %10, %3
%26 = mul nsw i32 %25, %12
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %31
28: ; preds = %20
%29 = add nuw nsw i32 %3, 1
%30 = icmp eq i32 %29, 325
br i1 %30, label %31, label %1
31: ; preds = %28, %23
%32 = phi i32 [ %13, %23 ], [ %7, %28 ]
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%35 = tail call i32 @find_pythagorean(i32 1000)
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i32 %35)
ret i32 0
}