#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 /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int n, sum = 0, num = 1;
  printf("Enter the number of terms you want to sum up: ");
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    sum += (num * (num + 1));
    num += 2;
  }
  printf("\nThe sum of the series is %d", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1197 <main+0x77>
mov    -0x10(%rbp),%eax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1162 <main+0x42>
mov    -0xc(%rbp),%esi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf0d(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    117a <main+0x5a>
lea    -0x1(%rax),%ecx
lea    -0x2(%rax),%edx
imul   %rcx,%rdx
lea    -0x3(%rax),%ecx
imul   %rdx,%rcx
shr    %rcx
imul   $0x55555558,%ecx,%ecx
shr    %rdx
lea    (%rdx,%rdx,8),%edx
lea    (%rcx,%rdx,2),%ecx
lea    (%rax,%rax,2),%eax
lea    (%rcx,%rax,4),%ebx
add    $0xfffffff6,%ebx
lea    0xeae(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Enter the number of terms you want to sum up: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [29 x i8] c"\0AThe sum of the series is %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 1, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 0, i32* %5
br label %8
8: ; preds = %21, %0
%9 = load i32, i32* %5
%10 = load i32, i32* %2
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %24
12: ; preds = %8
%13 = load i32, i32* %4
%14 = load i32, i32* %4
%15 = add nsw i32 %14, 1
%16 = mul nsw i32 %13, %15
%17 = load i32, i32* %3
%18 = add nsw i32 %17, %16
store i32 %18, i32* %3
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 2
store i32 %20, i32* %4
br label %21
21: ; preds = %12
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %8
24: ; preds = %8
%25 = load i32, i32* %3
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [47 x i8] c"Enter the number of terms you want to sum up: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [29 x i8] c"\0AThe sum of the series is %d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %26
7: ; preds = %0
%8 = add nsw i32 %5, -1
%9 = zext i32 %8 to i33
%10 = add nsw i32 %5, -2
%11 = zext i32 %10 to i33
%12 = mul i33 %9, %11
%13 = add nsw i32 %5, -3
%14 = zext i32 %13 to i33
%15 = mul i33 %12, %14
%16 = lshr i33 %15, 1
%17 = trunc i33 %16 to i32
%18 = mul i32 %17, 1431655768
%19 = lshr i33 %12, 1
%20 = trunc i33 %19 to i32
%21 = mul i32 %20, 18
%22 = add i32 %18, %21
%23 = mul i32 %5, 12
%24 = add i32 %22, %23
%25 = add i32 %24, -10
br label %26
26: ; preds = %7, %0
%27 = phi i32 [ 0, %0 ], [ %25, %7 ]
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %27)
ret i32 0
}