#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 argc, const char *argv[]) {
  int n, sum = 0, i, j = 2;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    sum += j;
    j += 3;
  }
  printf("%d\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x2,-0x20(%rbp)
lea    0xeb5(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1187 <main+0x67>
mov    -0x20(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115b <main+0x3b>
mov    -0x18(%rbp),%esi
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%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
test   %eax,%eax
jle    1155 <main+0x35>
lea    (%rax,%rax,4),%ecx
lea    -0x1(%rax),%edx
add    $0xfffffffe,%eax
imul   %rdx,%rax
shr    %rax
lea    (%rax,%rax,2),%eax
lea    (%rcx,%rax,1),%esi
add    $0xfffffffd,%esi
jmp    1157 <main+0x37>
xor    %esi,%esi
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = load i32, i32* %3
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %2
%9 = mul i32 %6, 5
%10 = add nsw i32 %6, -1
%11 = zext i32 %10 to i33
%12 = add nsw i32 %6, -2
%13 = zext i32 %12 to i33
%14 = mul i33 %11, %13
%15 = lshr i33 %14, 1
%16 = trunc i33 %15 to i32
%17 = mul i32 %16, 3
%18 = add i32 %9, %17
%19 = add i32 %18, -3
br label %20
20: ; preds = %8, %2
%21 = phi i32 [ 0, %2 ], [ %19, %8 ]
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
ret i32 0
}