#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 *, ...);
void find_circles_within(unsigned n) {
  unsigned x = 0, y = 0;
  printf("  x\t  y\n");
  while (x * x + y * y <= n) {
    printf("%3u\t%3u\n", x, y);
    y++;
    while (x * x + y * y <= n) {
      printf("%3u\t%3u\n", x, y);
      y++;
    }
    y = 0;
    x++;
  }
}


x86 assembly (clang, -O0):
<find_circles_within>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    %ecx,%eax
cmp    -0x4(%rbp),%eax
ja     11bd <find_circles_within+0xad>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    %ecx,%eax
cmp    -0x4(%rbp),%eax
ja     11a8 <find_circles_within+0x98>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116d <find_circles_within+0x5d>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1137 <find_circles_within+0x27>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_circles_within>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r15d
lea    0xed7(%rip),%rdi
call   1030 <puts@plt>
lea    0xec2(%rip),%r14
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    115f <find_circles_within+0x3f>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r12d
mov    %r12d,%ebp
imul   %ebp,%ebp
cmp    %r15d,%ebp
ja     11a0 <find_circles_within+0x80>
mov    %r14,%rdi
mov    %r12d,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x1(%rbp),%eax
cmp    %r15d,%eax
ja     1150 <find_circles_within+0x30>
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
mov    %ebx,%eax
imul   %ebx,%eax
add    %ebp,%eax
cmp    %r15d,%eax
jbe    1180 <find_circles_within+0x60>
jmp    1150 <find_circles_within+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c" x\09 y\0A\00"
@.str.1 = [9 x i8] c"%3u\09%3u\0A\00"
define void @find_circles_within(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %38, %1
%7 = load i32, i32* %3
%8 = load i32, i32* %3
%9 = mul i32 %7, %8
%10 = load i32, i32* %4
%11 = load i32, i32* %4
%12 = mul i32 %10, %11
%13 = add i32 %9, %12
%14 = load i32, i32* %2
%15 = icmp ule i32 %13, %14
br i1 %15, label %16, label %41
16: ; preds = %6
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %18)
%20 = load i32, i32* %4
%21 = add i32 %20, 1
store i32 %21, i32* %4
br label %22
22: ; preds = %32, %16
%23 = load i32, i32* %3
%24 = load i32, i32* %3
%25 = mul i32 %23, %24
%26 = load i32, i32* %4
%27 = load i32, i32* %4
%28 = mul i32 %26, %27
%29 = add i32 %25, %28
%30 = load i32, i32* %2
%31 = icmp ule i32 %29, %30
br i1 %31, label %32, label %38
32: ; preds = %22
%33 = load i32, i32* %3
%34 = load i32, i32* %4
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %33, i32 %34)
%36 = load i32, i32* %4
%37 = add i32 %36, 1
store i32 %37, i32* %4
br label %22
38: ; preds = %22
store i32 0, i32* %4
%39 = load i32, i32* %3
%40 = add i32 %39, 1
store i32 %40, i32* %3
br label %6
41: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"%3u\09%3u\0A\00"
@str = [8 x i8] c" x\09 y\00"
define void @find_circles_within(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %3
3: ; preds = %1, %16
%4 = phi i32 [ 0, %1 ], [ %18, %16 ]
%5 = phi i32 [ 0, %1 ], [ %17, %16 ]
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %5, i32 0)
%7 = add i32 %4, 1
%8 = icmp ugt i32 %7, %0
br i1 %8, label %16, label %9
9: ; preds = %3, %9
%10 = phi i32 [ %12, %9 ], [ 1, %3 ]
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %5, i32 %10)
%12 = add i32 %10, 1
%13 = mul i32 %12, %12
%14 = add i32 %13, %4
%15 = icmp ugt i32 %14, %0
br i1 %15, label %16, label %9
16: ; preds = %9, %3
%17 = add i32 %5, 1
%18 = mul i32 %17, %17
%19 = icmp ugt i32 %18, %0
br i1 %19, label %20, label %3
20: ; preds = %16
ret void
}