#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_s(char *, int *);
int /*<<< orphan*/ system(char *);
main() {
  int number, i;
  double sum = 0, A = 0, B = 0;
  printf("Enter a number : ");
  scanf_s("%d", &number);
  for (i = 1; i <= number; i++) {
    if (i % 2 == 1)
      A = A + (double)1 / (double)(i * i);
    else
      B = B + (double)1 / (double)(i * i);
  }
  sum = A - B;
  printf("\n Sum is : %.2f \n", sum);
  printf("\n");
  system("pause");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeae(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf_s@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11fe <main+0xce>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    11c6 <main+0x96>
movsd  -0x20(%rbp),%xmm0
mov    -0xc(%rbp),%eax
imul   -0xc(%rbp),%eax
cvtsi2sd %eax,%xmm2
movsd  0xe4c(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11eb <main+0xbb>
movsd  -0x28(%rbp),%xmm0
mov    -0xc(%rbp),%eax
imul   -0xc(%rbp),%eax
cvtsi2sd %eax,%xmm2
movsd  0xe22(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11f0 <main+0xc0>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117c <main+0x4c>
movsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe04(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdfa(%rip),%rdi
call   1030 <system@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xecc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf_s@plt>
mov    0x4(%rsp),%r8d
test   %r8d,%r8d
jle    117f <main+0x3f>
cmp    $0x1,%r8d
jne    1188 <main+0x48>
mov    $0x1,%edx
xorpd  %xmm1,%xmm1
xorpd  %xmm0,%xmm0
jmp    11f1 <main+0xb1>
xorpd  %xmm0,%xmm0
jmp    1236 <main+0xf6>
mov    %r8d,%ecx
and    $0xfffffffe,%ecx
neg    %ecx
mov    $0x1,%esi
xorpd  %xmm1,%xmm1
movsd  0xe5f(%rip),%xmm2
xorpd  %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x1(%rsi),%edi
mov    %esi,%edx
lea    (%rcx,%rsi,1),%eax
add    $0x2,%eax
imul   %esi,%esi
xorps  %xmm3,%xmm3
cvtsi2sd %esi,%xmm3
movapd %xmm2,%xmm4
divsd  %xmm3,%xmm4
addsd  %xmm4,%xmm0
imul   %edi,%edi
xorps  %xmm3,%xmm3
cvtsi2sd %edi,%xmm3
movapd %xmm2,%xmm4
divsd  %xmm3,%xmm4
addsd  %xmm4,%xmm1
add    $0x2,%edx
mov    %edx,%esi
cmp    $0x1,%eax
jne    11b0 <main+0x70>
test   $0x1,%r8b
je     1232 <main+0xf2>
mov    %edx,%eax
imul   %edx,%eax
xorps  %xmm3,%xmm3
cvtsi2sd %eax,%xmm3
movsd  0xdf5(%rip),%xmm2
divsd  %xmm3,%xmm2
movsd  0xdf1(%rip),%xmm4
movapd %xmm4,%xmm3
test   $0x1,%dl
je     1224 <main+0xe4>
movapd %xmm2,%xmm3
je     122a <main+0xea>
movapd %xmm4,%xmm2
addsd  %xmm2,%xmm1
addsd  %xmm3,%xmm0
subsd  %xmm1,%xmm0
lea    0xde8(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xde2(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [18 x i8] c"Enter a number : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"\0A Sum is : %.2f \0A\00"
@.str.4 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf_s(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 1
br i1 %6, label %50, label %7
7: ; preds = %0
%8 = and i32 %5, 1
%9 = icmp eq i32 %5, 1
br i1 %9, label %29, label %10
10: ; preds = %7
%11 = and i32 %5, -2
br label %12
12: ; preds = %12, %10
%13 = phi double [ 0.000000e+00, %10 ], [ %25, %12 ]
%14 = phi double [ 0.000000e+00, %10 ], [ %20, %12 ]
%15 = phi i32 [ 1, %10 ], [ %26, %12 ]
%16 = phi i32 [ 0, %10 ], [ %27, %12 ]
%17 = mul nsw i32 %15, %15
%18 = sitofp i32 %17 to double
%19 = fdiv double 1.000000e+00, %18
%20 = fadd double %14, %19
%21 = add nuw i32 %15, 1
%22 = mul nsw i32 %21, %21
%23 = sitofp i32 %22 to double
%24 = fdiv double 1.000000e+00, %23
%25 = fadd double %13, %24
%26 = add nuw i32 %15, 2
%27 = add i32 %16, 2
%28 = icmp eq i32 %27, %11
br i1 %28, label %29, label %12
29: ; preds = %12, %7
%30 = phi double [ undef, %7 ], [ %20, %12 ]
%31 = phi double [ undef, %7 ], [ %25, %12 ]
%32 = phi double [ 0.000000e+00, %7 ], [ %25, %12 ]
%33 = phi double [ 0.000000e+00, %7 ], [ %20, %12 ]
%34 = phi i32 [ 1, %7 ], [ %26, %12 ]
%35 = icmp eq i32 %8, 0
br i1 %35, label %46, label %36
36: ; preds = %29
%37 = and i32 %34, 1
%38 = icmp eq i32 %37, 0
%39 = mul nsw i32 %34, %34
%40 = sitofp i32 %39 to double
%41 = fdiv double 1.000000e+00, %40
%42 = select i1 %38, double -0.000000e+00, double %41
%43 = fadd double %33, %42
%44 = select i1 %38, double %41, double -0.000000e+00
%45 = fadd double %32, %44
br label %46
46: ; preds = %29, %36
%47 = phi double [ %30, %29 ], [ %43, %36 ]
%48 = phi double [ %31, %29 ], [ %45, %36 ]
%49 = fsub double %47, %48
br label %50
50: ; preds = %46, %0
%51 = phi double [ %49, %46 ], [ 0.000000e+00, %0 ]
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), double %51)
%53 = call i32 @putchar(i32 10)
%54 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}