#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 *, ...);
void series2(int n) {
  int sum = 0, i, j;
  for (i = 1; i <= n; i++) {
    printf("(");
    for (j = 1; j <= i; j++) {
      sum += j;
      printf("%d", j);
      if (j != i)
        printf("+");
    }
    printf(")");
    if (i != n)
      printf("+");
  }
  printf("\nSum Of Above Series is %d\n", sum);
}


x86 assembly (clang, -O0):
<series2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11d8 <series2+0xc8>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     119d <series2+0x8d>
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     118a <series2+0x7a>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118f <series2+0x7f>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114a <series2+0x3a>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
je     11c5 <series2+0xb5>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ca <series2+0xba>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1129 <series2+0x19>
mov    -0x8(%rbp),%esi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<series2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edi,%edi
jle    11e0 <series2+0xc0>
mov    %edi,%ebp
lea    0x1(%rbp),%eax
mov    %eax,0x4(%rsp)
mov    $0x1,%r13d
mov    $0x2,%eax
lea    0xeaf(%rip),%r15
xor    %r14d,%r14d
xor    %ebx,%ebx
mov    %rbp,0x8(%rsp)
jmp    1176 <series2+0x56>
nopl   (%rax)
add    $0x1,%r13d
mov    0x10(%rsp),%rcx
lea    0x1(%rcx),%eax
add    $0x1,%r14d
cmp    0x4(%rsp),%ecx
je     11e2 <series2+0xc2>
mov    %rax,0x10(%rsp)
mov    $0x28,%edi
call   1030 <putchar@plt>
xor    %r12d,%r12d
jmp    119e <series2+0x7e>
nopw   0x0(%rax,%rax,1)
add    %r12d,%ebx
add    $0x1,%ebx
mov    %ebp,%r12d
cmp    %ebp,%r13d
je     11c0 <series2+0xa0>
lea    0x1(%r12),%ebp
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r12d,%r14d
je     1190 <series2+0x70>
mov    $0x2b,%edi
call   1030 <putchar@plt>
jmp    1190 <series2+0x70>
mov    $0x29,%edi
call   1030 <putchar@plt>
mov    0x8(%rsp),%rbp
cmp    %ebp,%r13d
je     1160 <series2+0x40>
mov    $0x2b,%edi
call   1030 <putchar@plt>
jmp    1160 <series2+0x40>
xor    %ebx,%ebx
lea    0xe1a(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"(\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"+\00"
@.str.3 = [2 x i8] c")\00"
@.str.4 = [28 x i8] c"\0ASum Of Above Series is %d\0A\00"
define void @series2(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 1, i32* %4
br label %6
6: ; preds = %39, %1
%7 = load i32, i32* %4
%8 = load i32, i32* %2
%9 = icmp sle i32 %7, %8
br i1 %9, label %10, label %42
10: ; preds = %6
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %5
br label %12
12: ; preds = %28, %10
%13 = load i32, i32* %5
%14 = load i32, i32* %4
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %31
16: ; preds = %12
%17 = load i32, i32* %5
%18 = load i32, i32* %3
%19 = add nsw i32 %18, %17
store i32 %19, i32* %3
%20 = load i32, i32* %5
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %5
%23 = load i32, i32* %4
%24 = icmp ne i32 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %16
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %25, %16
br label %28
28: ; preds = %27
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %12
31: ; preds = %12
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%33 = load i32, i32* %4
%34 = load i32, i32* %2
%35 = icmp ne i32 %33, %34
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %38
38: ; preds = %36, %31
br label %39
39: ; preds = %38
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %6
42: ; preds = %6
%43 = load i32, i32* %3
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %43)
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [28 x i8] c"\0ASum Of Above Series is %d\0A\00"
define void @series2(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %30, label %3
3: ; preds = %1
%4 = add i32 %0, 1
br label %5
5: ; preds = %3, %26
%6 = phi i32 [ 2, %3 ], [ %28, %26 ]
%7 = phi i32 [ 1, %3 ], [ %27, %26 ]
%8 = phi i32 [ 0, %3 ], [ %13, %26 ]
%9 = tail call i32 @putchar(i32 40)
br label %10
10: ; preds = %5, %18
%11 = phi i32 [ 1, %5 ], [ %19, %18 ]
%12 = phi i32 [ %8, %5 ], [ %13, %18 ]
%13 = add nsw i32 %11, %12
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%15 = icmp eq i32 %11, %7
br i1 %15, label %18, label %16
16: ; preds = %10
%17 = tail call i32 @putchar(i32 43)
br label %18
18: ; preds = %10, %16
%19 = add nuw i32 %11, 1
%20 = icmp eq i32 %19, %6
br i1 %20, label %21, label %10
21: ; preds = %18
%22 = tail call i32 @putchar(i32 41)
%23 = icmp eq i32 %7, %0
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = tail call i32 @putchar(i32 43)
br label %26
26: ; preds = %21, %24
%27 = add nuw nsw i32 %7, 1
%28 = add nuw i32 %6, 1
%29 = icmp eq i32 %6, %4
br i1 %29, label %30, label %5
30: ; preds = %26, %1
%31 = phi i32 [ 0, %1 ], [ %13, %26 ]
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %31)
ret void
}