#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int abs(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  FILE *pInputFile = NULL;
  FILE *pOutputFile = NULL;
  int n = 0;
  pInputFile = fopen("Input.txt", "r");
  if (pInputFile == NULL) {
    printf("Can't open the Input.txt file\n");
    return EXIT_FAILURE;
  }
  pOutputFile = fopen("Output.txt", "w");
  if (pOutputFile == NULL) {
    printf("Can't open the Output.txt file\n");
    fclose(pInputFile);
    return EXIT_FAILURE;
  }
  fscanf(pInputFile, "%d", &n);
  fclose(pInputFile);
  if (abs(n) > 10000) {
    printf("The numbers must not exceed the %d\n", 10000);
    fclose(pOutputFile);
  }
  fprintf(pOutputFile, "%d\n",
          n > 0 ? ((n + 1) * n) / 2 : ((n + (-1)) * abs(n)) / 2 + 1);
  fclose(pOutputFile);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xe6c(%rip),%rdi
lea    0xe6f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ce <main+0x6e>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2e1c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12df <main+0x17f>
lea    0xe56(%rip),%rdi
lea    0xe5a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1218 <main+0xb8>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2dd2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12df <main+0x17f>
mov    -0x18(%rbp),%rdi
lea    0xe35(%rip),%rsi
lea    -0x24(%rbp),%rdx
call   1060 <fscanf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x24(%rbp),%edi
call   1030 <abs@plt>
cmp    $0x2710,%eax
jle    1264 <main+0x104>
lea    0xe0c(%rip),%rdi
mov    $0x2710,%esi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    1290 <main+0x130>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
imul   -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x34(%rbp)
jmp    12b7 <main+0x157>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x38(%rbp)
mov    -0x24(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%edx
lea    0xdb6(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2cfe(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xe8d(%rip),%rdi
lea    0xe90(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1209 <main+0xa9>
mov    %rax,%rbx
lea    0xe7a(%rip),%rdi
lea    0xe7e(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     121e <main+0xbe>
mov    %rax,%r14
lea    0xe6c(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
call   1060 <fscanf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x4(%rsp),%eax
mov    %eax,%ecx
neg    %ecx
cmovs  %eax,%ecx
cmp    $0x2711,%ecx
jb     11f4 <main+0x94>
lea    0xe40(%rip),%rdi
mov    $0x2710,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    123b <main+0xdb>
lea    0x1(%rax),%ecx
imul   %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
add    %ecx,%edx
sar    %edx
jmp    1251 <main+0xf1>
lea    0xe4f(%rip),%rdi
call   1030 <puts@plt>
mov    0x2dc4(%rip),%rax
jmp    126f <main+0x10f>
lea    0xe1b(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x2da7(%rip),%rax
jmp    126f <main+0x10f>
mov    $0x1,%ecx
sub    %eax,%ecx
imul   %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
add    %ecx,%edx
sar    %edx
add    $0x1,%edx
lea    0xde4(%rip),%rsi
mov    %r14,%rdi
call   1070 <fprintf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    0x2d69(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [31 x i8] c"Can't open the Input.txt file\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [11 x i8] c"Output.txt\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [32 x i8] c"Can't open the Output.txt file\0A\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [36 x i8] c"The numbers must not exceed the %d\0A\00"
@.str.8 = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i32* null, i32** %7
store i32 0, i32* %8
%9 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %6
%10 = load i32*, i32** %6
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
store i32 %14, i32* %3
br label %60
15: ; preds = %2
%16 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %16, i32** %7
%17 = load i32*, i32** %7
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%21 = load i32*, i32** %6
%22 = call i32 @fclose(i32* %21)
%23 = load i32, i32* @EXIT_FAILURE
store i32 %23, i32* %3
br label %60
24: ; preds = %15
%25 = load i32*, i32** %6
%26 = call i32 @fscanf(i32* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %8)
%27 = load i32*, i32** %6
%28 = call i32 @fclose(i32* %27)
%29 = load i32, i32* %8
%30 = call i32 @abs(i32 %29)
%31 = icmp sgt i32 %30, 10000
br i1 %31, label %32, label %36
32: ; preds = %24
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0), i32 10000)
%34 = load i32*, i32** %7
%35 = call i32 @fclose(i32* %34)
br label %36
36: ; preds = %32, %24
%37 = load i32*, i32** %7
%38 = load i32, i32* %8
%39 = icmp sgt i32 %38, 0
br i1 %39, label %40, label %46
40: ; preds = %36
%41 = load i32, i32* %8
%42 = add nsw i32 %41, 1
%43 = load i32, i32* %8
%44 = mul nsw i32 %42, %43
%45 = sdiv i32 %44, 2
br label %54
46: ; preds = %36
%47 = load i32, i32* %8
%48 = add nsw i32 %47, -1
%49 = load i32, i32* %8
%50 = call i32 @abs(i32 %49)
%51 = mul nsw i32 %48, %50
%52 = sdiv i32 %51, 2
%53 = add nsw i32 %52, 1
br label %54
54: ; preds = %46, %40
%55 = phi i32 [ %45, %40 ], [ %53, %46 ]
%56 = call i32 @fprintf(i32* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %55)
%57 = load i32*, i32** %7
%58 = call i32 @fclose(i32* %57)
%59 = load i32, i32* @EXIT_SUCCESS
store i32 %59, i32* %3
br label %60
60: ; preds = %54, %19, %12
%61 = load i32, i32* %3
ret i32 %61
}

LLVM IR (-O2):
@.str = [10 x i8] c"Input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [11 x i8] c"Output.txt\00"
@.str.4 = [2 x i8] c"w\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [36 x i8] c"The numbers must not exceed the %d\0A\00"
@.str.8 = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [31 x i8] c"Can't open the Output.txt file\00"
@str.9 = [30 x i8] c"Can't open the Input.txt file\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.9, i64 0, i64 0))
br label %41
9: ; preds = %2
%10 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @fclose(i32* %5)
br label %41
15: ; preds = %9
%16 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%17 = call i32 @fclose(i32* %5)
%18 = load i32, i32* %3
%19 = call i32 @llvm.abs.i32(i32 %18, i1 true)
%20 = icmp ugt i32 %19, 10000
br i1 %20, label %21, label %25
21: ; preds = %15
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0), i32 10000)
%23 = call i32 @fclose(i32* %10)
%24 = load i32, i32* %3
br label %25
25: ; preds = %21, %15
%26 = phi i32 [ %24, %21 ], [ %18, %15 ]
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = add nuw nsw i32 %26, 1
%30 = mul nsw i32 %29, %26
%31 = sdiv i32 %30, 2
br label %37
32: ; preds = %25
%33 = sub i32 1, %26
%34 = mul i32 %33, %26
%35 = sdiv i32 %34, 2
%36 = add nsw i32 %35, 1
br label %37
37: ; preds = %32, %28
%38 = phi i32 [ %31, %28 ], [ %36, %32 ]
%39 = call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %38)
%40 = call i32 @fclose(i32* %10)
br label %41
41: ; preds = %37, %12, %7
%42 = phi i32* [ @EXIT_FAILURE, %7 ], [ @EXIT_FAILURE, %12 ], [ @EXIT_SUCCESS, %37 ]
%43 = load i32, i32* %42
ret i32 %43
}