#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
double fabs(float);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, float, int, float);
int pow(double, float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
int main() {
  FILE *fp1 = fopen("nRaph1.txt", "w"), *fp2 = fopen("nRaphP1.txt", "w");
  float x, x_n;
  int count = 0;
  printf("\nEnter the value of x_0:\t");
  scanf("%f", &x_n);
  printf("Iteration.No.\tx_i\t\tf(x_i)\t\tx_(i+1)\t\tAbs. Error.\n");
  do {
    x = x_n;
    x_n = x - (pow(2.718281828, x) - (2 * x) - 1) / (pow(2.718281828, x) - 2);
    printf("\t%d\t%f\t%f\t%f\t%f\n", count, x,
           (pow(2.718281828, x) - (2 * x) - 1), x_n, fabs(x_n - x));
    fprintf(fp1, "%f %f\n%f 0\n\n", x, (pow(2.718281828, x) - (2 * x) - 1),
            x_n);
    fprintf(fp2, "%f %f\n%f 0\n\n", x, (pow(2.718281828, x) - (2 * x) - 1), x);
    count++;
  } while (fabs(x - x_n) > 0.0000005);
  printf("\n\tRoot = %f\n\n", x);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea2(%rip),%rdi
lea    0xea6(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe98(%rip),%rdi
lea    0xe8f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe92(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x60(%rbp)
movss  -0x1c(%rbp),%xmm1
movsd  0xe17(%rip),%xmm0
call   1080 <pow@plt>
cvtsi2ss %eax,%xmm0
movss  -0x1c(%rbp),%xmm1
addss  %xmm1,%xmm1
subss  %xmm1,%xmm0
movss  0xdf1(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x64(%rbp)
movss  -0x1c(%rbp),%xmm1
movsd  0xde3(%rip),%xmm0
call   1080 <pow@plt>
movss  -0x64(%rbp),%xmm1
movss  -0x60(%rbp),%xmm0
sub    $0x2,%eax
cvtsi2ss %eax,%xmm2
divss  %xmm2,%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x5c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movss  -0x1c(%rbp),%xmm1
movsd  0xd9f(%rip),%xmm0
call   1080 <pow@plt>
cvtsi2ss %eax,%xmm0
movss  -0x1c(%rbp),%xmm1
addss  %xmm1,%xmm1
subss  %xmm1,%xmm0
movss  0xd79(%rip),%xmm1
subss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movss  -0x20(%rbp),%xmm0
subss  -0x1c(%rbp),%xmm0
call   1040 <fabs@plt>
mov    -0x5c(%rbp),%esi
movsd  -0x58(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x48(%rbp),%xmm0
lea    0xdb2(%rip),%rdi
mov    $0x4,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x1c(%rbp),%xmm1
movsd  0xd15(%rip),%xmm0
call   1080 <pow@plt>
mov    -0x40(%rbp),%rdi
movss  -0x34(%rbp),%xmm0
cvtsi2ss %eax,%xmm1
movss  -0x1c(%rbp),%xmm2
addss  %xmm2,%xmm2
subss  %xmm2,%xmm1
movss  0xce6(%rip),%xmm2
subss  %xmm2,%xmm1
cvttss2si %xmm1,%edx
movss  -0x20(%rbp),%xmm1
lea    0xd62(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x1c(%rbp),%xmm1
movsd  0xcb6(%rip),%xmm0
call   1080 <pow@plt>
mov    -0x30(%rbp),%rdi
movss  -0x28(%rbp),%xmm0
cvtsi2ss %eax,%xmm1
movss  -0x1c(%rbp),%xmm2
addss  %xmm2,%xmm2
subss  %xmm2,%xmm1
movss  0xc87(%rip),%xmm2
subss  %xmm2,%xmm1
cvttss2si %xmm1,%edx
movss  -0x1c(%rbp),%xmm1
lea    0xd03(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movss  -0x1c(%rbp),%xmm0
subss  -0x20(%rbp),%xmm0
call   1040 <fabs@plt>
movsd  0xc5e(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     11d0 <main+0x70>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xcd1(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
lea    0xe95(%rip),%rdi
lea    0xe99(%rip),%rbx
mov    %rbx,%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0xe89(%rip),%rdi
mov    %rbx,%rsi
call   1080 <fopen@plt>
mov    %rax,%r12
lea    0xe83(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8d(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1070 <scanf@plt>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
lea    0xe73(%rip),%r15
lea    0xe7d(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movss  0x10(%rsp),%xmm1
movss  %xmm1,0xc(%rsp)
movsd  0xdfc(%rip),%xmm0
call   1090 <pow@plt>
xorps  %xmm2,%xmm2
cvtsi2ss %eax,%xmm2
movss  0xc(%rsp),%xmm1
movaps %xmm1,%xmm0
mulss  0xdef(%rip),%xmm0
movss  %xmm0,0x14(%rsp)
addss  %xmm0,%xmm2
movss  0xde1(%rip),%xmm0
addss  %xmm0,%xmm2
movss  %xmm2,0x18(%rsp)
movsd  0xdbb(%rip),%xmm0
call   1090 <pow@plt>
add    $0xfffffffe,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0x18(%rsp),%xmm2
divss  %xmm0,%xmm2
movss  0xc(%rsp),%xmm1
movaps %xmm1,%xmm0
subss  %xmm2,%xmm0
movss  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0xd7a(%rip),%xmm0
call   1090 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  0x14(%rsp),%xmm0
addss  0xd74(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x28(%rsp)
movss  0x10(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
subss  0xc(%rsp),%xmm0
call   1050 <fabs@plt>
movaps %xmm0,%xmm3
mov    %r15,%rdi
mov    %ebp,%esi
movsd  0x18(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
mov    $0x4,%al
call   1040 <printf@plt>
movsd  0xd0f(%rip),%xmm0
movss  0xc(%rsp),%xmm1
call   1090 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  0x14(%rsp),%xmm0
addss  0xd03(%rip),%xmm0
cvttss2si %xmm0,%edx
movss  0x10(%rsp),%xmm1
mov    %r14,%rdi
mov    %rbx,%rsi
movss  0xc(%rsp),%xmm0
call   1060 <fprintf@plt>
movsd  0xccc(%rip),%xmm0
movss  0xc(%rsp),%xmm1
call   1090 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  0x14(%rsp),%xmm0
addss  0xcc0(%rip),%xmm0
cvttss2si %xmm0,%edx
mov    %r12,%rdi
mov    %rbx,%rsi
movss  0xc(%rsp),%xmm0
movaps %xmm0,%xmm1
call   1060 <fprintf@plt>
add    $0x1,%ebp
movss  0xc(%rsp),%xmm0
subss  0x10(%rsp),%xmm0
call   1050 <fabs@plt>
ucomisd 0xc80(%rip),%xmm0
ja     11f0 <main+0x80>
lea    0xcd7(%rip),%rdi
movsd  0x18(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"nRaph1.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [12 x i8] c"nRaphP1.txt\00"
@.str.3 = [26 x i8] c"\0AEnter the value of x_0:\09\00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [49 x i8] c"Iteration.No.\09x_i\09\09f(x_i)\09\09x_(i+1)\09\09Abs. Error.\0A\00"
@.str.6 = [17 x i8] c"\09%d\09%f\09%f\09%f\09%f\0A\00"
@.str.7 = [13 x i8] c"%f %f\0A%f 0\0A\0A\00"
@.str.8 = [14 x i8] c"\0A\09Root = %f\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca float
%5 = alloca float
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %2
%8 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %3
store i32 0, i32* %6
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %5)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
br label %12
12: ; preds = %68, %0
%13 = load float, float* %5
store float %13, float* %4
%14 = load float, float* %4
%15 = load float, float* %4
%16 = call i32 @pow(double 0x4005BF0A8B04919B, float %15)
%17 = sitofp i32 %16 to float
%18 = load float, float* %4
%19 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %18, float %17)
%20 = fsub float %19, 1.000000e+00
%21 = load float, float* %4
%22 = call i32 @pow(double 0x4005BF0A8B04919B, float %21)
%23 = sub nsw i32 %22, 2
%24 = sitofp i32 %23 to float
%25 = fdiv float %20, %24
%26 = fsub float %14, %25
store float %26, float* %5
%27 = load i32, i32* %6
%28 = load float, float* %4
%29 = fpext float %28 to double
%30 = load float, float* %4
%31 = call i32 @pow(double 0x4005BF0A8B04919B, float %30)
%32 = sitofp i32 %31 to float
%33 = load float, float* %4
%34 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %33, float %32)
%35 = fsub float %34, 1.000000e+00
%36 = fpext float %35 to double
%37 = load float, float* %5
%38 = fpext float %37 to double
%39 = load float, float* %5
%40 = load float, float* %4
%41 = fsub float %39, %40
%42 = call double @fabs(float %41)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %27, double %29, double %36, double %38, double %42)
%44 = load i32*, i32** %2
%45 = load float, float* %4
%46 = load float, float* %4
%47 = call i32 @pow(double 0x4005BF0A8B04919B, float %46)
%48 = sitofp i32 %47 to float
%49 = load float, float* %4
%50 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %49, float %48)
%51 = fsub float %50, 1.000000e+00
%52 = fptosi float %51 to i32
%53 = load float, float* %5
%54 = call i32 @fprintf(i32* %44, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), float %45, i32 %52, float %53)
%55 = load i32*, i32** %3
%56 = load float, float* %4
%57 = load float, float* %4
%58 = call i32 @pow(double 0x4005BF0A8B04919B, float %57)
%59 = sitofp i32 %58 to float
%60 = load float, float* %4
%61 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %60, float %59)
%62 = fsub float %61, 1.000000e+00
%63 = fptosi float %62 to i32
%64 = load float, float* %4
%65 = call i32 @fprintf(i32* %55, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), float %56, i32 %63, float %64)
%66 = load i32, i32* %6
%67 = add nsw i32 %66, 1
store i32 %67, i32* %6
br label %68
68: ; preds = %12
%69 = load float, float* %4
%70 = load float, float* %5
%71 = fsub float %69, %70
%72 = call double @fabs(float %71)
%73 = fcmp ogt double %72, 5.000000e-07
br i1 %73, label %12, label %74
74: ; preds = %68
%75 = load float, float* %4
%76 = fpext float %75 to double
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), double %76)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"nRaph1.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [12 x i8] c"nRaphP1.txt\00"
@.str.3 = [26 x i8] c"\0AEnter the value of x_0:\09\00"
@.str.4 = [3 x i8] c"%f\00"
@.str.6 = [17 x i8] c"\09%d\09%f\09%f\09%f\09%f\0A\00"
@.str.7 = [13 x i8] c"%f %f\0A%f 0\0A\0A\00"
@.str.8 = [14 x i8] c"\0A\09Root = %f\0A\0A\00"
@str = [48 x i8] c"Iteration.No.\09x_i\09\09f(x_i)\09\09x_(i+1)\09\09Abs. Error.\00"
define i32 @main() {
%1 = alloca float
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = bitcast float* %1 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %1)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
br label %8
8: ; preds = %8, %0
%9 = phi i32 [ 0, %0 ], [ %44, %8 ]
%10 = load float, float* %1
%11 = call i32 @pow(double 0x4005BF0A8B04919B, float %10)
%12 = sitofp i32 %11 to float
%13 = call float @llvm.fmuladd.f32(float %10, float -2.000000e+00, float %12)
%14 = fadd float %13, -1.000000e+00
%15 = call i32 @pow(double 0x4005BF0A8B04919B, float %10)
%16 = add nsw i32 %15, -2
%17 = sitofp i32 %16 to float
%18 = fdiv float %14, %17
%19 = fsub float %10, %18
store float %19, float* %1
%20 = fpext float %10 to double
%21 = call i32 @pow(double 0x4005BF0A8B04919B, float %10)
%22 = sitofp i32 %21 to float
%23 = call float @llvm.fmuladd.f32(float %10, float -2.000000e+00, float %22)
%24 = fadd float %23, -1.000000e+00
%25 = fpext float %24 to double
%26 = load float, float* %1
%27 = fpext float %26 to double
%28 = fsub float %26, %10
%29 = call double @fabs(float %28)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %9, double %20, double %25, double %27, double %29)
%31 = call i32 @pow(double 0x4005BF0A8B04919B, float %10)
%32 = sitofp i32 %31 to float
%33 = call float @llvm.fmuladd.f32(float %10, float -2.000000e+00, float %32)
%34 = fadd float %33, -1.000000e+00
%35 = fptosi float %34 to i32
%36 = load float, float* %1
%37 = call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), float %10, i32 %35, float %36)
%38 = call i32 @pow(double 0x4005BF0A8B04919B, float %10)
%39 = sitofp i32 %38 to float
%40 = call float @llvm.fmuladd.f32(float %10, float -2.000000e+00, float %39)
%41 = fadd float %40, -1.000000e+00
%42 = fptosi float %41 to i32
%43 = call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), float %10, i32 %42, float %10)
%44 = add nuw nsw i32 %9, 1
%45 = load float, float* %1
%46 = fsub float %10, %45
%47 = call double @fabs(float %46)
%48 = fcmp ogt double %47, 5.000000e-07
br i1 %48, label %8, label %49
49: ; preds = %8
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), double %20)
ret i32 0
}