#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 i, c, t;
  while (scanf("%d", &i) == 1) {
    t = 0;
    if (i == 0)
      break;
    for (c = 1; c <= i; c++)
      t += (c * c);
    printf("%d\n", t);
  }
  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    11a0 <main+0x80>
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    115e <main+0x3e>
jmp    11a0 <main+0x80>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     118c <main+0x6c>
mov    -0xc(%rbp),%eax
imul   -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1165 <main+0x45>
mov    -0x10(%rbp),%esi
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
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    11b2 <main+0x92>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     11b2 <main+0x92>
lea    0xeb5(%rip),%r14
lea    0xeab(%rip),%r15
lea    0xc(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
test   %eax,%eax
jle    1190 <main+0x70>
lea    -0x1(%rax),%ecx
lea    -0x2(%rax),%edx
imul   %rcx,%rdx
lea    -0x3(%rax),%ecx
imul   %rdx,%rcx
shr    %rcx
imul   $0x55555556,%ecx,%ecx
shr    %rdx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
lea    (%rdx,%rax,4),%esi
add    $0xfffffffd,%esi
jmp    1192 <main+0x72>
xchg   %ax,%ax
xor    %esi,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    11b2 <main+0x92>
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
%4 = alloca i32
store i32 0, i32* %1
br label %5
5: ; preds = %26, %0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %29
8: ; preds = %5
store i32 0, i32* %4
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %8
br label %29
12: ; preds = %8
store i32 1, i32* %3
br label %13
13: ; preds = %23, %12
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %26
17: ; preds = %13
%18 = load i32, i32* %3
%19 = load i32, i32* %3
%20 = mul nsw i32 %18, %19
%21 = load i32, i32* %4
%22 = add nsw i32 %21, %20
store i32 %22, i32* %4
br label %23
23: ; preds = %17
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %13
26: ; preds = %13
%27 = load i32, i32* %4
%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 = %11, %5
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 ne i32 %3, 1
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 0
%7 = select i1 %4, i1 true, i1 %6
br i1 %7, label %38, label %8
8: ; preds = %0, %30
%9 = phi i32 [ %35, %30 ], [ %5, %0 ]
%10 = icmp slt i32 %9, 1
br i1 %10, label %30, label %11
11: ; preds = %8
%12 = add nsw i32 %9, -1
%13 = zext i32 %12 to i33
%14 = add nsw i32 %9, -2
%15 = zext i32 %14 to i33
%16 = mul i33 %13, %15
%17 = add nsw i32 %9, -3
%18 = zext i32 %17 to i33
%19 = mul i33 %16, %18
%20 = lshr i33 %19, 1
%21 = trunc i33 %20 to i32
%22 = mul i32 %21, 1431655766
%23 = lshr i33 %16, 1
%24 = trunc i33 %23 to i32
%25 = mul i32 %24, 5
%26 = shl i32 %9, 2
%27 = add i32 %22, -3
%28 = add i32 %27, %25
%29 = add i32 %28, %26
br label %30
30: ; preds = %11, %8
%31 = phi i32 [ 0, %8 ], [ %29, %11 ]
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%34 = icmp ne i32 %33, 1
%35 = load i32, i32* %1
%36 = icmp eq i32 %35, 0
%37 = select i1 %34, i1 true, i1 %36
br i1 %37, label %38, label %8
38: ; preds = %30, %0
ret i32 0
}