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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    1194 <main+0x74>
cmpq   $0x0,-0x10(%rbp)
jge    1158 <main+0x38>
jmp    1194 <main+0x74>
mov    -0x10(%rbp),%rax
imul   -0x10(%rbp),%rax
add    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe7b(%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    0x8(%rsp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    11a8 <main+0x88>
mov    0x8(%rsp),%rax
test   %rax,%rax
js     11a8 <main+0x88>
lea    0xeb5(%rip),%r14
lea    0xea9(%rip),%r15
lea    0x8(%rsp),%rbx
nopl   0x0(%rax)
mov    %rax,%rcx
imul   %rax,%rcx
lea    (%rax,%rcx,1),%rdx
add    %rcx,%rax
add    $0x2,%rax
shr    $0x3f,%rax
lea    (%rax,%rdx,1),%rsi
add    $0x2,%rsi
sar    %rsi
mov    %rsi,0x8(%rsp)
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    11a8 <main+0x88>
mov    0x8(%rsp),%rax
test   %rax,%rax
jns    1160 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
store i32 0, i32* %1
br label %3
3: ; preds = %10, %0
%4 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %21
6: ; preds = %3
%7 = load i64, i64* %2
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %6
br label %21
10: ; preds = %6
%11 = load i64, i64* %2
%12 = load i64, i64* %2
%13 = mul nsw i64 %11, %12
%14 = load i64, i64* %2
%15 = add nsw i64 %13, %14
%16 = add nsw i64 %15, 2
store i64 %16, i64* %2
%17 = load i64, i64* %2
%18 = sdiv i64 %17, 2
store i64 %18, i64* %2
%19 = load i64, i64* %2
%20 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %19)
br label %3
21: ; preds = %9, %3
ret i32 0
}

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