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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x0,%rax
je     1181 <main+0x61>
cmpq   $0x0,-0x8(%rbp)
jge    1152 <main+0x32>
jmp    1181 <main+0x61>
mov    -0x8(%rbp),%rax
imul   -0x8(%rbp),%rax
add    -0x8(%rbp),%rax
add    $0x2,%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rsi
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
jmp    1128 <main+0x8>
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>
test   %rax,%rax
je     11a3 <main+0x83>
mov    0x8(%rsp),%rax
test   %rax,%rax
js     11a3 <main+0x83>
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    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
test   %rax,%rax
je     11a3 <main+0x83>
mov    0x8(%rsp),%rax
test   %rax,%rax
jns    1160 <main+0x40>
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 void @main() {
%1 = alloca i64
br label %2
2: ; preds = %9, %0
%3 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %18
5: ; preds = %2
%6 = load i64, i64* %1
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %5
br label %18
9: ; preds = %5
%10 = load i64, i64* %1
%11 = load i64, i64* %1
%12 = mul nsw i64 %10, %11
%13 = load i64, i64* %1
%14 = add nsw i64 %12, %13
%15 = add nsw i64 %14, 2
%16 = sdiv i64 %15, 2
%17 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %16)
br label %2
18: ; preds = %8, %2
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [6 x i8] c"%lld\0A\00"
define void @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%4 = icmp eq i64 %3, 0
%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
%14 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %13)
%15 = call i64 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%16 = icmp eq i64 %15, 0
%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 void
}