#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__ EOF;
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, int *);
int main() {
  int n;
  long long sum = 0;
  while (scanf("%d", &n) != EOF) {
    if (n == 0 || n == 1) {
      printf("1\n");
      continue;
    }
    if (n == -1) {
      printf("0\n");
      continue;
    }
    int sign = n < 0;
    if (sign) {
      n *= -1;
    }
    sum = n * (n + 1) / 2;
    if (sign) {
      sum--;
      sum *= -1;
    }
    printf("%lld\n", sum);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xec2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    0x2e9a(%rip),%rcx
cmp    (%rcx),%rax
je     120b <main+0xeb>
cmpl   $0x0,-0x8(%rbp)
je     116b <main+0x4b>
cmpl   $0x1,-0x8(%rbp)
jne    117e <main+0x5e>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1137 <main+0x17>
cmpl   $0xffffffff,-0x8(%rbp)
jne    119b <main+0x7b>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1137 <main+0x17>
cmpl   $0x0,-0x8(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11bb <main+0x9b>
imul   $0xffffffff,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11f4 <main+0xd4>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
imul   $0xffffffffffffffff,-0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1137 <main+0x17>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x2e95(%rip),%rbp
cmp    0x0(%rbp),%rax
jne    116a <main+0x3a>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe9a(%rip),%r14
lea    0xe88(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xe85(%rip),%r12
lea    0xe78(%rip),%r13
jmp    11cb <main+0x9b>
nopl   (%rax)
lea    0x1(%rcx),%edx
imul   %ecx,%edx
mov    %edx,%ecx
shr    $0x1f,%ecx
add    %edx,%ecx
sar    %ecx
movslq %ecx,%rcx
mov    $0x1,%esi
sub    %rcx,%rsi
test   %eax,%eax
cmovns %rcx,%rsi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmp    0x0(%rbp),%rax
je     1159 <main+0x29>
mov    0x4(%rsp),%eax
cmp    $0x1,%eax
ja     11e0 <main+0xb0>
mov    %r14,%rdi
jmp    11f8 <main+0xc8>
nopl   0x0(%rax)
cmp    $0xffffffff,%eax
je     11f5 <main+0xc5>
mov    %eax,%ecx
test   %eax,%eax
jns    1190 <main+0x60>
mov    %eax,%ecx
neg    %ecx
mov    %ecx,0x4(%rsp)
jmp    1190 <main+0x60>
mov    %r12,%rdi
call   1030 <puts@plt>
jmp    11ba <main+0x8a>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [3 x i8] c"1\0A\00"
@.str.2 = [3 x i8] c"0\0A\00"
@.str.3 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = alloca i32
store i32 0, i32* %1
store i64 0, i64* %3
br label %5
5: ; preds = %45, %20, %15, %0
%6 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%7 = load i64, i64* @EOF
%8 = icmp ne i64 %6, %7
br i1 %8, label %9, label %48
9: ; preds = %5
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %17
15: ; preds = %12, %9
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %5
17: ; preds = %12
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %5
22: ; preds = %17
%23 = load i32, i32* %2
%24 = icmp slt i32 %23, 0
%25 = zext i1 %24 to i32
store i32 %25, i32* %4
%26 = load i32, i32* %4
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = load i32, i32* %2
%30 = mul nsw i32 %29, -1
store i32 %30, i32* %2
br label %31
31: ; preds = %28, %22
%32 = load i32, i32* %2
%33 = load i32, i32* %2
%34 = add nsw i32 %33, 1
%35 = mul nsw i32 %32, %34
%36 = sdiv i32 %35, 2
%37 = sext i32 %36 to i64
store i64 %37, i64* %3
%38 = load i32, i32* %4
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %45
40: ; preds = %31
%41 = load i64, i64* %3
%42 = add nsw i64 %41, -1
store i64 %42, i64* %3
%43 = load i64, i64* %3
%44 = mul nsw i64 %43, -1
store i64 %44, i64* %3
br label %45
45: ; preds = %40, %31
%46 = load i64, i64* %3
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %46)
br label %5
48: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.3 = [6 x i8] c"%lld\0A\00"
@str = [2 x i8] c"0\00"
@str.4 = [2 x i8] c"1\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i64, i64* @EOF
%5 = icmp eq i64 %3, %4
br i1 %5, label %32, label %6
6: ; preds = %0, %11
%7 = load i32, i32* %1
%8 = icmp ult i32 %7, 2
br i1 %8, label %9, label %15
9: ; preds = %6
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.4, i64 0, i64 0))
br label %11
11: ; preds = %9, %17, %23
%12 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%13 = load i64, i64* @EOF
%14 = icmp eq i64 %12, %13
br i1 %14, label %32, label %6
15: ; preds = %6
%16 = icmp eq i32 %7, -1
br i1 %16, label %17, label %19
17: ; preds = %15
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %11
19: ; preds = %15
%20 = icmp slt i32 %7, 0
br i1 %20, label %21, label %23
21: ; preds = %19
%22 = sub nsw i32 0, %7
store i32 %22, i32* %1
br label %23
23: ; preds = %21, %19
%24 = phi i32 [ %22, %21 ], [ %7, %19 ]
%25 = add nuw nsw i32 %24, 1
%26 = mul nsw i32 %25, %24
%27 = sdiv i32 %26, 2
%28 = sext i32 %27 to i64
%29 = sub nsw i64 1, %28
%30 = select i1 %20, i64 %29, i64 %28
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %30)
br label %11
32: ; preds = %11, %0
ret i32 0
}