#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(void) {
  int input, sum = 0;
  scanf("%d", &input);
  if (input > 1) {
    while (input != 0) {
      sum += input;
      input--;
    }
    printf("%d", sum);
    return 0;
  } else if (input < 1) {
    while (input != 2) {
      sum += input;
      input++;
    }
    printf("%d", sum);
    return 0;
  }
  printf("%d", input);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jle    1191 <main+0x71>
jmp    1155 <main+0x35>
cmpl   $0x0,-0x8(%rbp)
je     1176 <main+0x56>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1155 <main+0x35>
mov    -0xc(%rbp),%esi
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f7 <main+0xd7>
cmpl   $0x1,-0x8(%rbp)
jge    11dc <main+0xbc>
jmp    11a0 <main+0x80>
cmpl   $0x2,-0x8(%rbp)
je     11c1 <main+0xa1>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a0 <main+0x80>
mov    -0xc(%rbp),%esi
lea    0xe35(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f7 <main+0xd7>
jmp    11e1 <main+0xc1>
mov    -0x8(%rbp),%esi
lea    0xe15(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
jl     115b <main+0x3b>
lea    -0x1(%rax),%ecx
lea    -0x2(%rax),%edx
imul   %rcx,%rdx
mov    %ecx,%esi
imul   %ecx,%esi
shr    %rdx
add    %eax,%esi
sub    %edx,%esi
movl   $0x0,0x4(%rsp)
jmp    1189 <main+0x69>
mov    $0x1,%esi
cmp    $0x1,%eax
je     1189 <main+0x69>
lea    0x1(%rax),%esi
mov    $0x1,%ecx
sub    %eax,%ecx
imul   %ecx,%esi
mov    %eax,%edx
neg    %edx
imul   %rdx,%rcx
shr    %rcx
add    %eax,%esi
add    %ecx,%esi
movl   $0x2,0x4(%rsp)
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\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 = load i32, i32* %1
%5 = icmp sgt i32 %4, 1
br i1 %5, label %6, label %17
6: ; preds = %0
%7 = add nsw i32 %4, -1
%8 = mul i32 %7, %7
%9 = zext i32 %7 to i33
%10 = add nsw i32 %4, -2
%11 = zext i32 %10 to i33
%12 = mul i33 %9, %11
%13 = lshr i33 %12, 1
%14 = trunc i33 %13 to i32
%15 = add i32 %4, %8
%16 = sub i32 %15, %14
store i32 0, i32* %1
br label %31
17: ; preds = %0
%18 = icmp eq i32 %4, 1
br i1 %18, label %31, label %19
19: ; preds = %17
%20 = add nsw i32 %4, 1
%21 = sub i32 1, %4
%22 = mul i32 %20, %21
%23 = sub i32 0, %4
%24 = zext i32 %23 to i33
%25 = zext i32 %21 to i33
%26 = mul i33 %24, %25
%27 = lshr i33 %26, 1
%28 = trunc i33 %27 to i32
%29 = add i32 %4, %22
%30 = add i32 %29, %28
store i32 2, i32* %1
br label %31
31: ; preds = %17, %19, %6
%32 = phi i32 [ %30, %19 ], [ %16, %6 ], [ 1, %17 ]
%33 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %32)
ret i32 0
}