#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 calculateNext(double, int);
double fabs(double);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ scanf(char *, double *, double *);
int main() {
  double x, error;
  scanf("%lf %lf", &x, &error);
  int n = 1;
  double result = x;
  for (;;) {
    double next = result + calculateNext(x, ++n);
    if (fabs(next - result) < error) {
      break;
    }
    result = next;
  }
  printf("%lf\n", result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <scanf@plt>
movl   $0x1,-0x1c(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x1c(%rbp),%edi
add    $0x1,%edi
mov    %edi,-0x1c(%rbp)
call   1050 <calculateNext@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
subsd  -0x28(%rbp),%xmm1
movaps 0xe5d(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11bb <main+0x8b>
jmp    11ca <main+0x9a>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1164 <main+0x34>
movsd  -0x28(%rbp),%xmm0
lea    0xe42(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xed4(%rip),%rdi
lea    0x18(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1040 <scanf@plt>
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0x2,%edi
call   1050 <calculateNext@plt>
movsd  0x8(%rsp),%xmm3
addsd  %xmm3,%xmm0
movapd %xmm0,%xmm1
subsd  %xmm3,%xmm1
andpd  0xe85(%rip),%xmm1
movsd  0x10(%rsp),%xmm2
ucomisd %xmm1,%xmm2
ja     11cc <main+0x9c>
mov    $0x3,%ebx
nopl   0x0(%rax)
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
mov    %ebx,%edi
call   1050 <calculateNext@plt>
movsd  0x8(%rsp),%xmm3
addsd  %xmm3,%xmm0
movapd %xmm0,%xmm1
subsd  %xmm3,%xmm1
andpd  0xe43(%rip),%xmm1
movsd  0x10(%rsp),%xmm2
add    $0x1,%ebx
ucomisd %xmm1,%xmm2
jbe    1190 <main+0x60>
lea    0xe45(%rip),%rdi
movapd %xmm3,%xmm0
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%lf %lf\00"
@.str.1 = [5 x i8] c"%lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca double
store i32 0, i32* %1
%7 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double* %2, double* %3)
store i32 1, i32* %4
%8 = load double, double* %2
store double %8, double* %5
br label %9
9: ; preds = %23, %0
%10 = load double, double* %5
%11 = load double, double* %2
%12 = load i32, i32* %4
%13 = add nsw i32 %12, 1
store i32 %13, i32* %4
%14 = call double @calculateNext(double %11, i32 %13)
%15 = fadd double %10, %14
store double %15, double* %6
%16 = load double, double* %6
%17 = load double, double* %5
%18 = fsub double %16, %17
%19 = call double @llvm.fabs.f64(double %18)
%20 = load double, double* %3
%21 = fcmp olt double %19, %20
br i1 %21, label %22, label %23
22: ; preds = %9
br label %25
23: ; preds = %9
%24 = load double, double* %6
store double %24, double* %5
br label %9
25: ; preds = %22
%26 = load double, double* %5
%27 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"%lf %lf\00"
@.str.1 = [5 x i8] c"%lf\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = bitcast double* %1 to i8*
%4 = bitcast double* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double* %1, double* %2)
%6 = load double, double* %1
%7 = call double @calculateNext(double %6, i32 2)
%8 = fadd double %6, %7
%9 = fsub double %8, %6
%10 = call double @llvm.fabs.f64(double %9)
%11 = load double, double* %2
%12 = fcmp olt double %10, %11
br i1 %12, label %24, label %13
13: ; preds = %0, %13
%14 = phi double [ %19, %13 ], [ %8, %0 ]
%15 = phi i32 [ %17, %13 ], [ 2, %0 ]
%16 = load double, double* %1
%17 = add nuw nsw i32 %15, 1
%18 = call double @calculateNext(double %16, i32 %17)
%19 = fadd double %14, %18
%20 = fsub double %19, %14
%21 = call double @llvm.fabs.f64(double %20)
%22 = load double, double* %2
%23 = fcmp olt double %21, %22
br i1 %23, label %24, label %13
24: ; preds = %13, %0
%25 = phi double [ %6, %0 ], [ %14, %13 ]
%26 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %25)
ret i32 0
}