#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 */
scalar_t__ countNumSubsquare(int, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int squareSide, numSubsquare, side;
  while (1) {
    scanf("%d", &squareSide);
    if (squareSide == 0)
      break;
    numSubsquare = 0;
    for (side = 1; side <= squareSide; side++)
      numSubsquare += countNumSubsquare(side, squareSide);
    printf("%d\n", numSubsquare);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    115e <main+0x2e>
jmp    11b2 <main+0x82>
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     119e <main+0x6e>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <countNumSubsquare@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116c <main+0x3c>
mov    -0xc(%rbp),%esi
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xebd(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
je     11b6 <main+0x86>
lea    0xea7(%rip),%r14
lea    0xe9d(%rip),%r15
lea    0xc(%rsp),%r12
jmp    118f <main+0x5f>
nopw   0x0(%rax,%rax,1)
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
je     11b6 <main+0x86>
test   %esi,%esi
jle    1170 <main+0x40>
xor    %ebx,%ebx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebx
mov    %ebx,%edi
call   1040 <countNumSubsquare@plt>
add    %eax,%ebp
mov    0xc(%rsp),%esi
cmp    %esi,%ebx
jl     11a0 <main+0x70>
jmp    1172 <main+0x42>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
br label %5
5: ; preds = %0, %26
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %5
br label %29
10: ; preds = %5
store i32 0, i32* %3
store i32 1, i32* %4
br label %11
11: ; preds = %23, %10
%12 = load i32, i32* %4
%13 = load i32, i32* %2
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %26
15: ; preds = %11
%16 = load i32, i32* %4
%17 = load i32, i32* %2
%18 = call i64 @countNumSubsquare(i32 %16, i32 %17)
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = add nsw i64 %20, %18
%22 = trunc i64 %21 to i32
store i32 %22, i32* %3
br label %23
23: ; preds = %15
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %11
26: ; preds = %11
%27 = load i32, i32* %3
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %5
29: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = icmp eq i32 %4, 0
br i1 %5, label %25, label %6
6: ; preds = %0, %19
%7 = phi i32 [ %23, %19 ], [ %4, %0 ]
%8 = icmp slt i32 %7, 1
br i1 %8, label %19, label %9
9: ; preds = %6, %9
%10 = phi i32 [ %17, %9 ], [ %7, %6 ]
%11 = phi i32 [ %16, %9 ], [ 1, %6 ]
%12 = phi i32 [ %15, %9 ], [ 0, %6 ]
%13 = call i64 @countNumSubsquare(i32 %11, i32 %10)
%14 = trunc i64 %13 to i32
%15 = add i32 %12, %14
%16 = add nuw nsw i32 %11, 1
%17 = load i32, i32* %1
%18 = icmp slt i32 %11, %17
br i1 %18, label %9, label %19
19: ; preds = %9, %6
%20 = phi i32 [ 0, %6 ], [ %15, %9 ]
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%23 = load i32, i32* %1
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %6
25: ; preds = %19, %0
ret i32 0
}