#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*/ exit(int /*<<< orphan*/);
double fabs(double);
int /*<<< orphan*/ printf(char *, double);
int main(void) {
  double a = 1, sum = 0, n = 1;
  while (fabs(a) >= 0.000001) {
    int k;
    if ((int)n % 2 == 0)
      k = 1;
    else
      k = -1;
    a = k * (1 - ((n + 1) * (n + 1)) / ((n + 2) * (n + 2)));
    sum += a;
    n++;
  }
  printf("Сумма ряда: %f\n", sum);
  int i = 10;
  sum = 0, n = 1;
  while (i--) {
    int k;
    if ((int)n % 2 == 0)
      k = 1;
    else
      k = -1;
    a = k * (1 - ((n + 1) * (n + 1)) / ((n + 2) * (n + 2)));
    sum += a;
    n++;
  }
  printf("Сумма первых 10 членов ряда: %f\n", sum);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xeb4(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xec3(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe9f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     121c <main+0xfc>
cvttsd2si -0x20(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1195 <main+0x75>
movl   $0x1,-0x24(%rbp)
jmp    119c <main+0x7c>
movl   $0xffffffff,-0x24(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
movsd  0xe57(%rip),%xmm2
addsd  -0x20(%rbp),%xmm2
movsd  0xe4a(%rip),%xmm1
addsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm2
movsd  0xe49(%rip),%xmm1
addsd  -0x20(%rbp),%xmm1
movsd  0xe3c(%rip),%xmm3
addsd  -0x20(%rbp),%xmm3
mulsd  %xmm3,%xmm1
divsd  %xmm1,%xmm2
movsd  0xe17(%rip),%xmm1
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xdf3(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1151 <main+0x31>
movsd  -0x18(%rbp),%xmm0
lea    0xe08(%rip),%rdi
call   1030 <printf@plt>
movl   $0xa,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xdbc(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x28(%rbp)
cmp    $0x0,%eax
je     1306 <main+0x1e6>
cvttsd2si -0x20(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    127f <main+0x15f>
movl   $0x1,-0x2c(%rbp)
jmp    1286 <main+0x166>
movl   $0xffffffff,-0x2c(%rbp)
cvtsi2sdl -0x2c(%rbp),%xmm0
movsd  0xd6d(%rip),%xmm2
addsd  -0x20(%rbp),%xmm2
movsd  0xd60(%rip),%xmm1
addsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm2
movsd  0xd5f(%rip),%xmm1
addsd  -0x20(%rbp),%xmm1
movsd  0xd52(%rip),%xmm3
addsd  -0x20(%rbp),%xmm3
mulsd  %xmm3,%xmm1
divsd  %xmm1,%xmm2
movsd  0xd2d(%rip),%xmm1
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xd09(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1249 <main+0x129>
movsd  -0x18(%rbp),%xmm0
lea    0xd37(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
xorpd  %xmm0,%xmm0
movsd  0xed3(%rip),%xmm1
movapd 0xeeb(%rip),%xmm2
movapd 0xef2(%rip),%xmm8
movapd 0xefa(%rip),%xmm4
movsd  0xeba(%rip),%xmm5
movapd %xmm1,%xmm6
jmp    116e <main+0x4e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
addsd  %xmm3,%xmm0
andpd  %xmm4,%xmm7
ucomisd %xmm5,%xmm7
jb     11a9 <main+0x89>
cvttsd2si %xmm6,%eax
unpcklpd %xmm6,%xmm6
addpd  %xmm2,%xmm6
movapd %xmm6,%xmm3
mulpd  %xmm6,%xmm3
movapd %xmm3,%xmm7
unpckhpd %xmm3,%xmm7
divsd  %xmm7,%xmm3
movapd %xmm1,%xmm7
subsd  %xmm3,%xmm7
movapd %xmm7,%xmm3
test   $0x1,%al
je     1160 <main+0x40>
movapd %xmm7,%xmm3
xorpd  %xmm8,%xmm3
jmp    1160 <main+0x40>
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
lea    0xead(%rip),%rdi
movsd  0xe4c(%rip),%xmm0
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"\D0\A1\D1\83\D0\BC\D0\BC\D0\B0 \D1\80\D1\8F\D0\B4\D0\B0: %f\0A\00"
@.str.1 = [54 x i8] c"\D0\A1\D1\83\D0\BC\D0\BC\D0\B0 \D0\BF\D0\B5\D1\80\D0\B2\D1\8B\D1\85 10 \D1\87\D0\BB\D0\B5\D0\BD\D0\BE\D0\B2 \D1\80\D1\8F\D0\B4\D0\B0: %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store double 1.000000e+00, double* %2
store double 0.000000e+00, double* %3
store double 1.000000e+00, double* %4
br label %8
8: ; preds = %19, %0
%9 = load double, double* %2
%10 = call double @llvm.fabs.f64(double %9)
%11 = fcmp oge double %10, 0x3EB0C6F7A0B5ED8D
br i1 %11, label %12, label %40
12: ; preds = %8
%13 = load double, double* %4
%14 = fptosi double %13 to i32
%15 = srem i32 %14, 2
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 1, i32* %5
br label %19
18: ; preds = %12
store i32 -1, i32* %5
br label %19
19: ; preds = %18, %17
%20 = load i32, i32* %5
%21 = sitofp i32 %20 to double
%22 = load double, double* %4
%23 = fadd double %22, 1.000000e+00
%24 = load double, double* %4
%25 = fadd double %24, 1.000000e+00
%26 = fmul double %23, %25
%27 = load double, double* %4
%28 = fadd double %27, 2.000000e+00
%29 = load double, double* %4
%30 = fadd double %29, 2.000000e+00
%31 = fmul double %28, %30
%32 = fdiv double %26, %31
%33 = fsub double 1.000000e+00, %32
%34 = fmul double %21, %33
store double %34, double* %2
%35 = load double, double* %2
%36 = load double, double* %3
%37 = fadd double %36, %35
store double %37, double* %3
%38 = load double, double* %4
%39 = fadd double %38, 1.000000e+00
store double %39, double* %4
br label %8
40: ; preds = %8
%41 = load double, double* %3
%42 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %41)
store i32 10, i32* %6
store double 0.000000e+00, double* %3
store double 1.000000e+00, double* %4
br label %43
43: ; preds = %54, %40
%44 = load i32, i32* %6
%45 = add nsw i32 %44, -1
store i32 %45, i32* %6
%46 = icmp ne i32 %44, 0
br i1 %46, label %47, label %75
47: ; preds = %43
%48 = load double, double* %4
%49 = fptosi double %48 to i32
%50 = srem i32 %49, 2
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %47
store i32 1, i32* %7
br label %54
53: ; preds = %47
store i32 -1, i32* %7
br label %54
54: ; preds = %53, %52
%55 = load i32, i32* %7
%56 = sitofp i32 %55 to double
%57 = load double, double* %4
%58 = fadd double %57, 1.000000e+00
%59 = load double, double* %4
%60 = fadd double %59, 1.000000e+00
%61 = fmul double %58, %60
%62 = load double, double* %4
%63 = fadd double %62, 2.000000e+00
%64 = load double, double* %4
%65 = fadd double %64, 2.000000e+00
%66 = fmul double %63, %65
%67 = fdiv double %61, %66
%68 = fsub double 1.000000e+00, %67
%69 = fmul double %56, %68
store double %69, double* %2
%70 = load double, double* %2
%71 = load double, double* %3
%72 = fadd double %71, %70
store double %72, double* %3
%73 = load double, double* %4
%74 = fadd double %73, 1.000000e+00
store double %74, double* %4
br label %43
75: ; preds = %43
%76 = load double, double* %3
%77 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), double %76)
%78 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [25 x i8] c"\D0\A1\D1\83\D0\BC\D0\BC\D0\B0 \D1\80\D1\8F\D0\B4\D0\B0: %f\0A\00"
@.str.1 = [54 x i8] c"\D0\A1\D1\83\D0\BC\D0\BC\D0\B0 \D0\BF\D0\B5\D1\80\D0\B2\D1\8B\D1\85 10 \D1\87\D0\BB\D0\B5\D0\BD\D0\BE\D0\B2 \D1\80\D1\8F\D0\B4\D0\B0: %f\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi double [ 1.000000e+00, %0 ], [ %20, %1 ]
%3 = phi double [ 0.000000e+00, %0 ], [ %17, %1 ]
%4 = fptosi double %2 to i32
%5 = and i32 %4, 1
%6 = icmp eq i32 %5, 0
%7 = insertelement <2 x double> poison, double %2, i64 0
%8 = shufflevector <2 x double> %7, <2 x double> poison, <2 x i32> zeroinitializer
%9 = fadd <2 x double> %8, <double 1.000000e+00, double 2.000000e+00>
%10 = fmul <2 x double> %9, %9
%11 = extractelement <2 x double> %10, i64 0
%12 = extractelement <2 x double> %10, i64 1
%13 = fdiv double %11, %12
%14 = fsub double 1.000000e+00, %13
%15 = fneg double %14
%16 = select i1 %6, double %14, double %15
%17 = fadd double %3, %16
%18 = tail call double @llvm.fabs.f64(double %14)
%19 = fcmp ult double %18, 0x3EB0C6F7A0B5ED8D
%20 = extractelement <2 x double> %9, i64 0
br i1 %19, label %21, label %1
21: ; preds = %1
%22 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %17)
%23 = tail call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), double 0xBFCE5A9379A69D20)
%24 = tail call i32 @exit(i32 0)
unreachable
}