#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 *, int);
int scanf(char *, int *);
int main() {
  int n, total;
  while (scanf("%d", &n) == 1) {
    if (n != 0) {
      total = (n * (n + 1) * (2 * n + 1) / 6);
      printf("%d\n", total);
    } else {
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    1193 <main+0x73>
cmpl   $0x0,-0x8(%rbp)
je     1189 <main+0x69>
mov    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    $0x6,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
jmp    118e <main+0x6e>
jmp    1193 <main+0x73>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed0(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    11a4 <main+0x84>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     11a4 <main+0x84>
lea    0xeb5(%rip),%r14
lea    0xeab(%rip),%r15
lea    0xc(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
lea    0x1(%rax),%ecx
imul   %eax,%ecx
add    %eax,%eax
add    $0x1,%eax
imul   %ecx,%eax
cltq
imul   $0x2aaaaaab,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
shr    $0x20,%rsi
add    %eax,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    11a4 <main+0x84>
mov    0xc(%rsp),%eax
test   %eax,%eax
jne    1160 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
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
store i32 0, i32* %1
br label %4
4: ; preds = %23, %0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %24
7: ; preds = %4
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %22
10: ; preds = %7
%11 = load i32, i32* %2
%12 = load i32, i32* %2
%13 = add nsw i32 %12, 1
%14 = mul nsw i32 %11, %13
%15 = load i32, i32* %2
%16 = mul nsw i32 2, %15
%17 = add nsw i32 %16, 1
%18 = mul nsw i32 %14, %17
%19 = sdiv i32 %18, 6
store i32 %19, i32* %3
%20 = load i32, i32* %3
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %23
22: ; preds = %7
br label %24
23: ; preds = %10
br label %4
24: ; preds = %22, %4
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 = icmp eq i32 %3, 1
%5 = load i32, i32* %1
%6 = icmp ne i32 %5, 0
%7 = select i1 %4, i1 %6, i1 false
br i1 %7, label %8, label %22
8: ; preds = %0, %8
%9 = phi i32 [ %19, %8 ], [ %5, %0 ]
%10 = add nsw i32 %9, 1
%11 = mul nsw i32 %10, %9
%12 = shl nsw i32 %9, 1
%13 = or i32 %12, 1
%14 = mul nsw i32 %11, %13
%15 = sdiv i32 %14, 6
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%18 = icmp eq i32 %17, 1
%19 = load i32, i32* %1
%20 = icmp ne i32 %19, 0
%21 = select i1 %18, i1 %20, i1 false
br i1 %21, label %8, label %22
22: ; preds = %8, %0
ret i32 0
}