#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i = 1, n, sum = 0, x;
  for (; n >= 0, i <= n; i++) {
    scanf("%d", &n);
    x = i * (n - i + 1);
    sum = sum + x;
  }
  printf("%d", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1182 <main+0x62>
lea    0xeb0(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x8(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113d <main+0x1d>
mov    -0x10(%rbp),%esi
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %ebx,%ebx
lea    0xecb(%rip),%r14
lea    0xc(%rsp),%r15
xor    %ebp,%ebp
xor    %r12d,%r12d
nop
add    $0x1,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
lea    (%rbx,%rax,1),%ecx
imul   %ebp,%ecx
add    %ecx,%r12d
add    $0xffffffff,%ebx
cmp    %eax,%ebp
jl     1140 <main+0x20>
lea    0xe97(%rip),%rdi
mov    %r12d,%esi
call   1030 <printf@plt>
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"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
store i32 0, i32* %4
br label %6
6: ; preds = %24, %0
%7 = load i32, i32* %3
%8 = icmp sge i32 %7, 0
%9 = zext i1 %8 to i32
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %27
13: ; preds = %6
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = load i32, i32* %2
%18 = sub nsw i32 %16, %17
%19 = add nsw i32 %18, 1
%20 = mul nsw i32 %15, %19
store i32 %20, i32* %5
%21 = load i32, i32* %4
%22 = load i32, i32* %5
%23 = add nsw i32 %21, %22
store i32 %23, i32* %4
br label %24
24: ; preds = %13
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
br label %6
27: ; preds = %6
%28 = load i32, i32* %4
%29 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %28)
ret i32 0
}

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