#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 series6(int n) {
  double sum = 0.0;
  int i;
  for (i = 1; i <= n; i++) {
    if (i % 2 != 0) {
      printf("(1/%d)", i);
      sum += 1.0 / i;
    } else {
      printf("(-1/%d)", i);
      sum -= 1.0 / i;
    }
    i != n ? printf("+") : printf(".\n");
  }
  printf("Sum Of The Above series is %f\n", sum);
}


x86 assembly (clang, -O0):
<series6>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11e6 <series6+0xd6>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     117b <series6+0x6b>
mov    -0x14(%rbp),%esi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xe98(%rip),%xmm0
divsd  %xmm1,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11ab <series6+0x9b>
mov    -0x14(%rbp),%esi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xe67(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
je     11ca <series6+0xba>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d8 <series6+0xc8>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112a <series6+0x1a>
movsd  -0x10(%rbp),%xmm0
lea    0xe2a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<series6>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    1204 <series6+0xd4>
mov    %edi,%r15d
neg    %r15d
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
mov    $0x1,%ebx
lea    0xeb9(%rip),%r14
lea    0xed9(%rip),%r12
lea    0xea4(%rip),%r13
jmp    118f <series6+0x5f>
xchg   %ax,%ax
mov    %r12,%rdi
call   1040 <puts@plt>
lea    (%r15,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
je     120d <series6+0xdd>
lea    (%r15,%rbx,1),%ebp
test   $0x1,%bl
jne    11c0 <series6+0x90>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  0xe55(%rip),%xmm1
jmp    11db <series6+0xab>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  0xe25(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
test   %ebp,%ebp
je     1170 <series6+0x40>
mov    $0x2b,%edi
call   1030 <putchar@plt>
jmp    1178 <series6+0x48>
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
lea    0xe0b(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <printf@plt>

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

LLVM IR (-O2):
@.str = [7 x i8] c"(1/%d)\00"
@.str.1 = [8 x i8] c"(-1/%d)\00"
@.str.4 = [31 x i8] c"Sum Of The Above series is %f\0A\00"
@str = [2 x i8] c".\00"
define void @series6(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %28, label %3
3: ; preds = %1, %25
%4 = phi i32 [ %26, %25 ], [ 1, %1 ]
%5 = phi double [ %19, %25 ], [ 0.000000e+00, %1 ]
%6 = and i32 %4, 1
%7 = icmp eq i32 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %3
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %4)
%10 = sitofp i32 %4 to double
%11 = fdiv double 1.000000e+00, %10
%12 = fadd double %5, %11
br label %18
13: ; preds = %3
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%15 = sitofp i32 %4 to double
%16 = fdiv double 1.000000e+00, %15
%17 = fsub double %5, %16
br label %18
18: ; preds = %13, %8
%19 = phi double [ %12, %8 ], [ %17, %13 ]
%20 = icmp eq i32 %4, %0
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = tail call i32 @putchar(i32 43)
br label %25
23: ; preds = %18
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %25
25: ; preds = %21, %23
%26 = add nuw i32 %4, 1
%27 = icmp eq i32 %4, %0
br i1 %27, label %28, label %3
28: ; preds = %25, %1
%29 = phi double [ 0.000000e+00, %1 ], [ %19, %25 ]
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), double %29)
ret void
}