#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, float, float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
int main() {
  FILE *fp1 = fopen("nRaph.txt", "w"), *fp2 = fopen("nRaphP.txt", "w");
  float x, x_n;
  int count = 0;
  printf("Enter the value of x_0:\t");
  scanf("%f", &x_n);
  do {
    x = x_n;
    printf("x_%d  =  %f\n", count, x);
    x_n = x - ((x * x) - x - 6) / (2 * x - 1);
    fprintf(fp1, "%f %f\n%f 0\n\n", x, ((x * x) - x - 6), x_n);
    fprintf(fp2, "%f %f\n%f 0\n\n", x, ((x * x) - x - 6), x);
  } while (fabs(x - x_n) > 0.0000005);
  printf("\n\tRoot = %f\n", x);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xead(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe9f(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe97(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <scanf@plt>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x24(%rbp),%esi
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe74(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x1c(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm3
movss  -0x1c(%rbp),%xmm2
movd   %xmm2,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm2
mulss  %xmm3,%xmm1
addss  %xmm2,%xmm1
movss  0xdf9(%rip),%xmm2
subss  %xmm2,%xmm1
movss  -0x1c(%rbp),%xmm2
addss  %xmm2,%xmm2
movss  0xde8(%rip),%xmm3
addss  %xmm3,%xmm2
divss  %xmm2,%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
movss  -0x1c(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm3
movss  -0x1c(%rbp),%xmm2
movd   %xmm2,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm2
mulss  %xmm3,%xmm1
addss  %xmm2,%xmm1
movss  0xd9e(%rip),%xmm2
subss  %xmm2,%xmm1
movss  -0x20(%rbp),%xmm2
lea    0xdde(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
movss  -0x1c(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm3
movss  -0x1c(%rbp),%xmm2
movd   %xmm2,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm2
mulss  %xmm3,%xmm1
addss  %xmm2,%xmm1
movss  0xd54(%rip),%xmm2
subss  %xmm2,%xmm1
movss  -0x1c(%rbp),%xmm2
lea    0xd94(%rip),%rsi
call   1050 <fprintf@plt>
movss  -0x1c(%rbp),%xmm0
subss  -0x20(%rbp),%xmm0
call   1040 <fabs@plt>
movsd  0xd30(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     11b2 <main+0x62>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd6b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeae(%rip),%rdi
lea    0xeb1(%rip),%rbx
mov    %rbx,%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
lea    0xea1(%rip),%rdi
mov    %rbx,%rsi
call   1070 <fopen@plt>
mov    %rax,%r12
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xea5(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
lea    0xe97(%rip),%r15
lea    0xe9d(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  0x8(%rsp),%xmm0
movss  %xmm0,0x4(%rsp)
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
xor    %esi,%esi
movsd  %xmm0,0x10(%rsp)
mov    $0x1,%al
call   1030 <printf@plt>
movss  0x4(%rsp),%xmm0
movaps %xmm0,%xmm3
mulss  %xmm0,%xmm3
subss  %xmm0,%xmm3
addss  0xe05(%rip),%xmm3
movaps %xmm0,%xmm2
addss  %xmm0,%xmm2
addss  0xdfa(%rip),%xmm2
movaps %xmm3,%xmm1
movss  %xmm3,0xc(%rsp)
divss  %xmm2,%xmm1
movaps %xmm0,%xmm2
subss  %xmm1,%xmm2
movss  %xmm2,0x8(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
movaps %xmm3,%xmm1
call   1050 <fprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
movss  0x4(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
movaps %xmm0,%xmm2
call   1050 <fprintf@plt>
movss  0x4(%rsp),%xmm0
subss  0x8(%rsp),%xmm0
call   1040 <fabs@plt>
ucomisd 0xda3(%rip),%xmm0
ja     11c0 <main+0x70>
lea    0xdeb(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"nRaph.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [11 x i8] c"nRaphP.txt\00"
@.str.3 = [25 x i8] c"Enter the value of x_0:\09\00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [13 x i8] c"x_%d = %f\0A\00"
@.str.6 = [13 x i8] c"%f %f\0A%f 0\0A\0A\00"
@.str.7 = [13 x i8] c"\0A\09Root = %f\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 ([10 x i8], [10 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 ([11 x i8], [11 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 ([25 x i8], [25 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)
br label %11
11: ; preds = %48, %0
%12 = load float, float* %5
store float %12, float* %4
%13 = load i32, i32* %6
%14 = load float, float* %4
%15 = fpext float %14 to double
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %13, double %15)
%17 = load float, float* %4
%18 = load float, float* %4
%19 = load float, float* %4
%20 = load float, float* %4
%21 = fneg float %20
%22 = call float @llvm.fmuladd.f32(float %18, float %19, float %21)
%23 = fsub float %22, 6.000000e+00
%24 = load float, float* %4
%25 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %24, float -1.000000e+00)
%26 = fdiv float %23, %25
%27 = fsub float %17, %26
store float %27, float* %5
%28 = load i32*, i32** %2
%29 = load float, float* %4
%30 = load float, float* %4
%31 = load float, float* %4
%32 = load float, float* %4
%33 = fneg float %32
%34 = call float @llvm.fmuladd.f32(float %30, float %31, float %33)
%35 = fsub float %34, 6.000000e+00
%36 = load float, float* %5
%37 = call i32 @fprintf(i32* %28, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), float %29, float %35, float %36)
%38 = load i32*, i32** %3
%39 = load float, float* %4
%40 = load float, float* %4
%41 = load float, float* %4
%42 = load float, float* %4
%43 = fneg float %42
%44 = call float @llvm.fmuladd.f32(float %40, float %41, float %43)
%45 = fsub float %44, 6.000000e+00
%46 = load float, float* %4
%47 = call i32 @fprintf(i32* %38, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), float %39, float %45, float %46)
br label %48
48: ; preds = %11
%49 = load float, float* %4
%50 = load float, float* %5
%51 = fsub float %49, %50
%52 = call double @fabs(float %51)
%53 = fcmp ogt double %52, 5.000000e-07
br i1 %53, label %11, label %54
54: ; preds = %48
%55 = load float, float* %4
%56 = fpext float %55 to double
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), double %56)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"nRaph.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [11 x i8] c"nRaphP.txt\00"
@.str.3 = [25 x i8] c"Enter the value of x_0:\09\00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [13 x i8] c"x_%d = %f\0A\00"
@.str.6 = [13 x i8] c"%f %f\0A%f 0\0A\0A\00"
@.str.7 = [13 x i8] c"\0A\09Root = %f\0A\00"
define i32 @main() {
%1 = alloca float
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 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 ([11 x i8], [11 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 ([25 x i8], [25 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)
br label %7
7: ; preds = %7, %0
%8 = load float, float* %1
%9 = fpext float %8 to double
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 0, double %9)
%11 = fneg float %8
%12 = call float @llvm.fmuladd.f32(float %8, float %8, float %11)
%13 = fadd float %12, -6.000000e+00
%14 = call float @llvm.fmuladd.f32(float %8, float 2.000000e+00, float -1.000000e+00)
%15 = fdiv float %13, %14
%16 = fsub float %8, %15
store float %16, float* %1
%17 = call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), float %8, float %13, float %16)
%18 = call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), float %8, float %13, float %8)
%19 = load float, float* %1
%20 = fsub float %8, %19
%21 = call double @fabs(float %20)
%22 = fcmp ogt double %21, 5.000000e-07
br i1 %22, label %7, label %23
23: ; preds = %7
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), double %9)
ret i32 0
}