#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 pow(int, int);
int /*<<< orphan*/ printf(char *, int, int);
int main() {
  int n = 2, m, check = 0;
  while (n < 1000) {
    for (m = 1; m < n; m++) {
      if (pow(n, 2) + (n * m) == 500) {
        printf("n = %i\nm = %i", n, m);
      }
    }
    n++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x3e8,-0x8(%rbp)
jge    11b1 <main+0x91>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a3 <main+0x83>
mov    -0x8(%rbp),%edi
mov    $0x2,%esi
call   1040 <pow@plt>
mov    -0x8(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    %ecx,%eax
cmp    $0x1f4,%eax
jne    1190 <main+0x70>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
jmp    1195 <main+0x75>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1151 <main+0x31>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113d <main+0x1d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x2,%r12d
xor    %r15d,%r15d
lea    0xec8(%rip),%r14
jmp    1151 <main+0x31>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r12d
add    $0xffffffff,%r15d
cmp    $0x3e8,%r12d
je     119b <main+0x7b>
mov    $0x1,%ebx
mov    $0xfffffe0e,%ebp
jmp    1176 <main+0x56>
nopl   (%rax)
lea    (%r15,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
add    %r12d,%ebp
mov    %ecx,%ebx
cmp    $0x2,%eax
je     1140 <main+0x20>
mov    %r12d,%edi
mov    $0x2,%esi
call   1040 <pow@plt>
mov    %r15d,%ecx
sub    %eax,%ecx
cmp    %ebp,%ecx
jne    1160 <main+0x40>
mov    %r14,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
jmp    1160 <main+0x40>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"n = %i\0Am = %i\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 2, i32* %2
store i32 0, i32* %4
br label %5
5: ; preds = %29, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 1000
br i1 %7, label %8, label %32
8: ; preds = %5
store i32 1, i32* %3
br label %9
9: ; preds = %26, %8
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %29
13: ; preds = %9
%14 = load i32, i32* %2
%15 = call i32 @pow(i32 %14, i32 2)
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = mul nsw i32 %16, %17
%19 = add nsw i32 %15, %18
%20 = icmp eq i32 %19, 500
br i1 %20, label %21, label %25
21: ; preds = %13
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %22, i32 %23)
br label %25
25: ; preds = %21, %13
br label %26
26: ; preds = %25
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %9
29: ; preds = %9
%30 = load i32, i32* %2
%31 = add nsw i32 %30, 1
store i32 %31, i32* %2
br label %5
32: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"n = %i\0Am = %i\00"
define i32 @main() {
br label %1
1: ; preds = %0, %14
%2 = phi i32 [ 2, %0 ], [ %15, %14 ]
br label %3
3: ; preds = %1, %11
%4 = phi i32 [ 1, %1 ], [ %12, %11 ]
%5 = tail call i32 @pow(i32 %2, i32 2)
%6 = mul nuw nsw i32 %4, %2
%7 = add nsw i32 %5, %6
%8 = icmp eq i32 %7, 500
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %4)
br label %11
11: ; preds = %3, %9
%12 = add nuw nsw i32 %4, 1
%13 = icmp eq i32 %12, %2
br i1 %13, label %14, label %3
14: ; preds = %11
%15 = add nuw nsw i32 %2, 1
%16 = icmp eq i32 %15, 1000
br i1 %16, label %17, label %1
17: ; preds = %14
ret i32 0
}