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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ae <main+0x8e>
mov    -0xc(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
cvtsi2ss %eax,%xmm0
mov    -0xc(%rbp),%eax
add    $0x3,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1163 <main+0x43>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe74(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef9(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%ecx
test   %ecx,%ecx
jle    115f <main+0x3f>
cmp    $0x1,%ecx
jne    1167 <main+0x47>
mov    $0x2,%eax
xorps  %xmm0,%xmm0
test   $0x1,%cl
jne    11ce <main+0xae>
jmp    11ef <main+0xcf>
xorps  %xmm0,%xmm0
jmp    11f3 <main+0xd3>
mov    %ecx,%edx
and    $0xfffffffe,%edx
xorps  %xmm0,%xmm0
mov    $0x7,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    -0x5(%rax),%esi
lea    -0x4(%rax),%edi
imul   %esi,%edi
xorps  %xmm1,%xmm1
cvtsi2ss %edi,%xmm1
lea    -0x2(%rax),%esi
xorps  %xmm2,%xmm2
cvtsi2ss %esi,%xmm2
divss  %xmm2,%xmm1
addss  %xmm0,%xmm1
lea    -0x3(%rax),%edi
imul   %esi,%edi
xorps  %xmm0,%xmm0
cvtsi2ss %edi,%xmm0
xorps  %xmm2,%xmm2
cvtsi2ss %eax,%xmm2
divss  %xmm2,%xmm0
addss  %xmm1,%xmm0
add    $0x4,%eax
add    $0xfffffffe,%edx
jne    1180 <main+0x60>
add    $0xfffffffb,%eax
test   $0x1,%cl
je     11ef <main+0xcf>
mov    %eax,%ecx
or     $0x1,%ecx
imul   %eax,%ecx
xorps  %xmm1,%xmm1
cvtsi2ss %ecx,%xmm1
add    $0x3,%eax
xorps  %xmm2,%xmm2
cvtsi2ss %eax,%xmm2
divss  %xmm2,%xmm1
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe38(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
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 = [31 x i8] c"\0AThe sum of the series is %.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca i32
store i32 0, i32* %1
store i32 2, i32* %3
store float 0.000000e+00, float* %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 = %26, %0
%9 = load i32, i32* %5
%10 = load i32, i32* %2
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %29
12: ; preds = %8
%13 = load i32, i32* %3
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
%16 = mul nsw i32 %13, %15
%17 = sitofp i32 %16 to float
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 3
%20 = sitofp i32 %19 to float
%21 = fdiv float %17, %20
%22 = load float, float* %4
%23 = fadd float %22, %21
store float %23, float* %4
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 2
store i32 %25, i32* %3
br label %26
26: ; preds = %12
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %8
29: ; preds = %8
%30 = load float, float* %4
%31 = fpext float %30 to double
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), double %31)
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 = [31 x i8] c"\0AThe sum of the series is %.2f\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 %28
7: ; preds = %0
%8 = and i32 %5, 1
%9 = icmp eq i32 %5, 1
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = and i32 %5, -2
br label %31
12: ; preds = %31, %7
%13 = phi float [ undef, %7 ], [ %49, %31 ]
%14 = phi float [ 0.000000e+00, %7 ], [ %49, %31 ]
%15 = phi i32 [ 2, %7 ], [ %50, %31 ]
%16 = icmp eq i32 %8, 0
br i1 %16, label %25, label %17
17: ; preds = %12
%18 = or i32 %15, 1
%19 = mul nsw i32 %18, %15
%20 = sitofp i32 %19 to float
%21 = add nuw nsw i32 %15, 3
%22 = sitofp i32 %21 to float
%23 = fdiv float %20, %22
%24 = fadd float %14, %23
br label %25
25: ; preds = %12, %17
%26 = phi float [ %13, %12 ], [ %24, %17 ]
%27 = fpext float %26 to double
br label %28
28: ; preds = %25, %0
%29 = phi double [ 0.000000e+00, %0 ], [ %27, %25 ]
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), double %29)
ret i32 0
31: ; preds = %31, %10
%32 = phi float [ 0.000000e+00, %10 ], [ %49, %31 ]
%33 = phi i32 [ 2, %10 ], [ %50, %31 ]
%34 = phi i32 [ 0, %10 ], [ %51, %31 ]
%35 = or i32 %33, 1
%36 = mul nsw i32 %35, %33
%37 = sitofp i32 %36 to float
%38 = add nuw nsw i32 %33, 3
%39 = sitofp i32 %38 to float
%40 = fdiv float %37, %39
%41 = fadd float %32, %40
%42 = add nuw nsw i32 %33, 2
%43 = or i32 %42, 1
%44 = mul nsw i32 %43, %42
%45 = sitofp i32 %44 to float
%46 = add nuw nsw i32 %33, 5
%47 = sitofp i32 %46 to float
%48 = fdiv float %45, %47
%49 = fadd float %41, %48
%50 = add nuw nsw i32 %33, 4
%51 = add i32 %34, 2
%52 = icmp eq i32 %51, %11
br i1 %52, label %12, label %31
}