#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 fabs(double);
double next_element(double, double, double);
int powf(double, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
int /*<<< orphan*/ setbuf(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ stdout;
int main(void) {
  setbuf(stdout, NULL);
  double eps;
  double x;
  double element = 1.0;
  double summ = 0.0;
  double i = 2.0;
  double func;
  printf("Input x: \n");
  scanf("%lf", &x);
  printf("Input eps: \n");
  scanf("%lf", &eps);
  if (fabs(x) >= 1.0) {
    printf("Incorrect x");
    return 0;
  }
  while (fabs(element) > eps) {
    summ += element;
    element = next_element(element, x, i);
    i++;
    printf("%lf\n", element);
  }
  func = 1 / powf((x + 1.0), 3.0);
  printf("%lf %lf %lf %lf", summ, func, fabs(func - summ),
         fabs((func - summ) / func));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <setbuf@plt>
movsd  0xe87(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe7a(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xebd(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe9f(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <scanf@plt>
movsd  -0x18(%rbp),%xmm0
movaps 0xe45(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe19(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     120b <main+0xbb>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f8 <main+0x1a8>
jmp    1210 <main+0xc0>
movsd  -0x20(%rbp),%xmm0
movaps 0xe04(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    127d <main+0x12d>
movsd  -0x20(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
call   1060 <next_element@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xda5(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xde3(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    1210 <main+0xc0>
movsd  0xd7b(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  0xd7e(%rip),%xmm1
call   1030 <powf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
subsd  -0x28(%rbp),%xmm2
movaps 0xd5b(%rip),%xmm3
pand   %xmm3,%xmm2
movsd  -0x38(%rbp),%xmm3
subsd  -0x28(%rbp),%xmm3
divsd  -0x38(%rbp),%xmm3
movaps 0xd41(%rip),%xmm4
pand   %xmm4,%xmm3
lea    0xd6f(%rip),%rdi
mov    $0x4,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1050 <setbuf@plt>
lea    0xecd(%rip),%rdi
call   1030 <puts@plt>
lea    0xebd(%rip),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
movsd  (%rsp),%xmm3
movapd 0xe47(%rip),%xmm0
andpd  %xmm3,%xmm0
ucomisd 0xe4b(%rip),%xmm0
jae    12b3 <main+0x153>
movsd  0xe3d(%rip),%xmm0
ucomisd 0x8(%rsp),%xmm0
jbe    12c3 <main+0x163>
movsd  0xe31(%rip),%xmm2
movsd  0xe21(%rip),%xmm0
movapd %xmm3,%xmm1
movsd  %xmm2,0x20(%rsp)
call   1070 <next_element@plt>
movaps %xmm0,0x10(%rsp)
lea    0xe2a(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movapd 0x10(%rsp),%xmm3
movapd 0xde1(%rip),%xmm0
andpd  %xmm3,%xmm0
ucomisd 0x8(%rsp),%xmm0
movsd  0xddf(%rip),%xmm0
jbe    12ac <main+0x14c>
movsd  0xdd5(%rip),%xmm0
lea    0xdf2(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  0x20(%rsp),%xmm2
addsd  0xdb2(%rip),%xmm2
movsd  (%rsp),%xmm1
addsd  %xmm3,%xmm0
movsd  %xmm0,0x28(%rsp)
movapd %xmm3,%xmm0
movsd  %xmm2,0x20(%rsp)
call   1070 <next_element@plt>
movapd %xmm0,0x10(%rsp)
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movapd 0x10(%rsp),%xmm3
movapd %xmm3,%xmm0
andpd  0xd62(%rip),%xmm0
ucomisd 0x8(%rsp),%xmm0
movsd  0x28(%rsp),%xmm0
ja     1250 <main+0xf0>
movsd  (%rsp),%xmm3
jmp    12c7 <main+0x167>
lea    0xd6e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    132c <main+0x1cc>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
addsd  0xd3b(%rip),%xmm3
movsd  0xd43(%rip),%xmm1
movapd %xmm3,%xmm0
call   1040 <powf@plt>
lea    0x1(%rax),%ecx
xor    %edx,%edx
cmp    $0x3,%ecx
cmovb  %eax,%edx
xorps  %xmm1,%xmm1
cvtsi2sd %edx,%xmm1
movapd %xmm1,%xmm3
movsd  0x10(%rsp),%xmm0
subsd  %xmm0,%xmm3
movapd 0xcf2(%rip),%xmm4
movapd %xmm3,%xmm2
andpd  %xmm4,%xmm2
divsd  %xmm1,%xmm3
andpd  %xmm4,%xmm3
lea    0xd14(%rip),%rdi
mov    $0x4,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [11 x i8] c"Input x: \0A\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [13 x i8] c"Input eps: \0A\00"
@.str.3 = [12 x i8] c"Incorrect x\00"
@.str.4 = [5 x i8] c"%lf\0A\00"
@.str.5 = [16 x i8] c"%lf %lf %lf %lf\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i32 0, i32* %1
%8 = load i32, i32* @stdout
%9 = call i32 @setbuf(i32 %8, i32* null)
store double 1.000000e+00, double* %4
store double 0.000000e+00, double* %5
store double 2.000000e+00, double* %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%14 = load double, double* %3
%15 = call double @llvm.fabs.f64(double %14)
%16 = fcmp oge double %15, 1.000000e+00
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %56
19: ; preds = %0
br label %20
20: ; preds = %25, %19
%21 = load double, double* %4
%22 = call double @llvm.fabs.f64(double %21)
%23 = load double, double* %2
%24 = fcmp ogt double %22, %23
br i1 %24, label %25, label %37
25: ; preds = %20
%26 = load double, double* %4
%27 = load double, double* %5
%28 = fadd double %27, %26
store double %28, double* %5
%29 = load double, double* %4
%30 = load double, double* %3
%31 = load double, double* %6
%32 = call double @next_element(double %29, double %30, double %31)
store double %32, double* %4
%33 = load double, double* %6
%34 = fadd double %33, 1.000000e+00
store double %34, double* %6
%35 = load double, double* %4
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), double %35)
br label %20
37: ; preds = %20
%38 = load double, double* %3
%39 = fadd double %38, 1.000000e+00
%40 = call i32 @powf(double %39, double 3.000000e+00)
%41 = sdiv i32 1, %40
%42 = sitofp i32 %41 to double
store double %42, double* %7
%43 = load double, double* %5
%44 = load double, double* %7
%45 = load double, double* %7
%46 = load double, double* %5
%47 = fsub double %45, %46
%48 = call double @llvm.fabs.f64(double %47)
%49 = load double, double* %7
%50 = load double, double* %5
%51 = fsub double %49, %50
%52 = load double, double* %7
%53 = fdiv double %51, %52
%54 = call double @llvm.fabs.f64(double %53)
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), double %43, double %44, double %48, double %54)
store i32 0, i32* %1
br label %56
56: ; preds = %37, %17
%57 = load i32, i32* %1
ret i32 %57
}

LLVM IR (-O2):
@stdout = global i32 0
@.str.1 = [4 x i8] c"%lf\00"
@.str.3 = [12 x i8] c"Incorrect x\00"
@.str.4 = [5 x i8] c"%lf\0A\00"
@.str.5 = [16 x i8] c"%lf %lf %lf %lf\00"
@str = [10 x i8] c"Input x: \00"
@str.6 = [12 x i8] c"Input eps: \00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = load i32, i32* @stdout
%4 = tail call i32 @setbuf(i32 %3, i32* null)
%5 = bitcast double* %1 to i8*
%6 = bitcast double* %2 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.6, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%11 = load double, double* %2
%12 = call double @llvm.fabs.f64(double %11)
%13 = fcmp ult double %12, 1.000000e+00
br i1 %13, label %14, label %23
14: ; preds = %0
%15 = load double, double* %1
%16 = fcmp olt double %15, 1.000000e+00
br i1 %16, label %17, label %40
17: ; preds = %14
%18 = call double @next_element(double 1.000000e+00, double %11, double 2.000000e+00)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), double %18)
%20 = call double @llvm.fabs.f64(double %18)
%21 = load double, double* %1
%22 = fcmp ogt double %20, %21
br i1 %22, label %25, label %37
23: ; preds = %0
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %54
25: ; preds = %17, %25
%26 = phi double [ %32, %25 ], [ %18, %17 ]
%27 = phi double [ %31, %25 ], [ 1.000000e+00, %17 ]
%28 = phi double [ %29, %25 ], [ 2.000000e+00, %17 ]
%29 = fadd double %28, 1.000000e+00
%30 = load double, double* %2
%31 = fadd double %26, %27
%32 = call double @next_element(double %26, double %30, double %29)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), double %32)
%34 = call double @llvm.fabs.f64(double %32)
%35 = load double, double* %1
%36 = fcmp ogt double %34, %35
br i1 %36, label %25, label %37
37: ; preds = %25, %17
%38 = phi double [ 1.000000e+00, %17 ], [ %31, %25 ]
%39 = load double, double* %2
br label %40
40: ; preds = %37, %14
%41 = phi double [ %11, %14 ], [ %39, %37 ]
%42 = phi double [ 0.000000e+00, %14 ], [ %38, %37 ]
%43 = fadd double %41, 1.000000e+00
%44 = call i32 @powf(double %43, double 3.000000e+00)
%45 = add i32 %44, 1
%46 = icmp ult i32 %45, 3
%47 = select i1 %46, i32 %44, i32 0
%48 = sitofp i32 %47 to double
%49 = fsub double %48, %42
%50 = call double @llvm.fabs.f64(double %49)
%51 = fdiv double %49, %48
%52 = call double @llvm.fabs.f64(double %51)
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), double %42, double %48, double %50, double %52)
br label %54
54: ; preds = %40, %23
ret i32 0
}