#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() {
  int A, N, soma = 0;
  scanf(" %d", &A);
  soma = A;
  A++;
  do {
    scanf(" %d", &N);
  } while (N < 1);
  while (N - 1 > 0) {
    soma += A;
    A++;
    N--;
  }
  printf("%d\n", soma);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
lea    0xea4(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0xc(%rbp)
jl     1155 <main+0x35>
jmp    1174 <main+0x54>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cmp    $0x0,%eax
jle    11a3 <main+0x83>
mov    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1174 <main+0x54>
mov    -0x10(%rbp),%esi
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
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),%r15
lea    0x8(%rsp),%rsi
mov    %r15,%rdi
call   1040 <scanf@plt>
mov    0x8(%rsp),%r14d
lea    0x1(%r14),%eax
mov    %eax,0x8(%rsp)
lea    0xc(%rsp),%rbx
nop
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1150 <main+0x30>
cmp    $0x1,%eax
je     11a6 <main+0x86>
mov    0x8(%rsp),%edx
mov    $0x2,%ecx
cmovle %eax,%ecx
mov    %eax,%esi
sub    %ecx,%esi
lea    0x1(%rdx),%edi
imul   %esi,%edi
mov    %ecx,%ebx
not    %ebx
add    %eax,%ebx
imul   %rbx,%rsi
shr    %rsi
add    %edx,%eax
sub    %ecx,%eax
add    $0x1,%eax
add    %edx,%r14d
add    %edi,%r14d
add    %esi,%r14d
add    $0xffffffff,%ecx
mov    %eax,0x8(%rsp)
mov    %ecx,0xc(%rsp)
lea    0xe57(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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