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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    115e <main+0x2e>
jmp    11c7 <main+0x97>
mov    -0x8(%rbp),%edi
mov    $0x3,%esi
call   1050 <pow@plt>
shl    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
imul   $0x3,%ecx,%ecx
sub    %ecx,%eax
add    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x6,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%edi
test   %edi,%edi
je     11d7 <main+0xa7>
lea    0xea8(%rip),%r14
lea    0xe9e(%rip),%r15
lea    0x4(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    $0x3,%esi
call   1050 <pow@plt>
mov    %eax,%ebp
add    %eax,%ebp
mov    0x4(%rsp),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
lea    (%rax,%rax,2),%eax
sub    %eax,%ebp
mov    0x4(%rsp),%edi
add    %edi,%ebp
movslq %ebp,%rax
imul   $0x2aaaaaab,%rax,%rbp
mov    %rbp,%rax
shr    $0x3f,%rax
shr    $0x20,%rbp
add    %eax,%ebp
mov    $0x2,%esi
call   1050 <pow@plt>
add    %eax,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%edi
test   %edi,%edi
jne    1170 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
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
store i32 0, i32* %1
br label %4
4: ; preds = %0, %9
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %4
br label %26
9: ; preds = %4
%10 = load i32, i32* %2
%11 = call i32 @pow(i32 %10, i32 3)
%12 = mul nsw i32 2, %11
%13 = load i32, i32* %2
%14 = call i32 @pow(i32 %13, i32 2)
%15 = mul nsw i32 3, %14
%16 = sub nsw i32 %12, %15
%17 = load i32, i32* %2
%18 = add nsw i32 %16, %17
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = sdiv i32 %19, 6
%21 = load i32, i32* %2
%22 = call i32 @pow(i32 %21, i32 2)
%23 = add nsw i32 %20, %22
store i32 %23, i32* %3
%24 = load i32, i32* %3
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %4
26: ; preds = %8
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 %23, label %6
6: ; preds = %0, %6
%7 = phi i32 [ %21, %6 ], [ %4, %0 ]
%8 = call i32 @pow(i32 %7, i32 3)
%9 = shl nsw i32 %8, 1
%10 = load i32, i32* %1
%11 = call i32 @pow(i32 %10, i32 2)
%12 = mul i32 %11, -3
%13 = add i32 %12, %9
%14 = load i32, i32* %1
%15 = add nsw i32 %13, %14
%16 = sdiv i32 %15, 6
%17 = call i32 @pow(i32 %14, i32 2)
%18 = add nsw i32 %16, %17
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%21 = load i32, i32* %1
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %6
23: ; preds = %6, %0
ret i32 0
}