#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 */
double pow(int, int);
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++) {
    sum = sum + pow(-1, i + 1) * (double)1 / (double)(i * i);
  }
  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    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf_s@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11ec <main+0xac>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0xc(%rbp),%esi
add    $0x1,%esi
mov    $0xffffffff,%edi
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  0xe3e(%rip),%xmm2
mulsd  %xmm2,%xmm1
mov    -0xc(%rbp),%eax
imul   -0xc(%rbp),%eax
cvtsi2sd %eax,%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118c <main+0x4c>
movsd  -0x18(%rbp),%xmm0
lea    0xe25(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe1b(%rip),%rdi
call   1030 <system@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
lea    0xea3(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea5(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf_s@plt>
cmpl   $0x0,0xc(%rsp)
jle    11d8 <main+0x88>
xorpd  %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm0,0x10(%rsp)
lea    0x1(%rbx),%ebp
add    $0x2,%ebx
mov    $0xffffffff,%edi
mov    %ebx,%esi
call   1070 <pow@plt>
mov    %ebp,%eax
imul   %ebp,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x10(%rsp),%xmm0
mov    %ebp,%ebx
cmp    0xc(%rsp),%ebp
jl     1190 <main+0x40>
jmp    11dc <main+0x8c>
xorpd  %xmm0,%xmm0
lea    0xe32(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe2c(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
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 = %25, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %28
13: ; preds = %9
%14 = load double, double* %4
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
%17 = call double @pow(i32 -1, i32 %16)
%18 = fmul double %17, 1.000000e+00
%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 %18, %22
%24 = fadd double %14, %23
store double %24, double* %4
br label %25
25: ; preds = %13
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %9
28: ; preds = %9
%29 = load double, double* %4
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), double %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%32 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%33 = load i32, i32* %1
ret i32 %33
}

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 %18, label %7
7: ; preds = %0, %7
%8 = phi i32 [ %10, %7 ], [ 1, %0 ]
%9 = phi double [ %15, %7 ], [ 0.000000e+00, %0 ]
%10 = add nuw nsw i32 %8, 1
%11 = call double @pow(i32 -1, i32 %10)
%12 = mul nsw i32 %8, %8
%13 = sitofp i32 %12 to double
%14 = fdiv double %11, %13
%15 = fadd double %9, %14
%16 = load i32, i32* %1
%17 = icmp slt i32 %8, %16
br i1 %17, label %7, label %18
18: ; preds = %7, %0
%19 = phi double [ 0.000000e+00, %0 ], [ %15, %7 ]
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), double %19)
%21 = call i32 @putchar(i32 10)
%22 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}