#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);
float fabs(float);
float log(float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
int main() {
  float x0, x1, error, errorold, converge, order;
  int i = 0;
  printf("Input the approximation : ");
  scanf("%f", &x0);
  converge = (((x0 * x0 * x0) - 18) * 6 * x0) / ((3 * x0 * x0) * (3 * x0 * x0));
  if (converge > 1)
    exit(1);
  printf("Ite\tX0\t\tX1\t\tError\t\tOrder\n");
  do {
    errorold = error;
    x1 = x0 - (((x0 * x0 * x0) - 18) / (3 * x0 * x0));
    if (((x1 * x1 * x1) - 18) == 0) {
      break;
    }
    error = fabs(x1 - x0);
    printf("%2d\t%4.6f\t%4.6f\t%4.6f\t", ++i, x0, x1, error);
    if (i == 1 || error == 0 || errorold == 1) {
      printf("-----\n");
    } else {
      order = log(error) / log(errorold);
      printf("%4.6f\n", order);
    }
    x0 = x1;
  } while (error > 0.00005);
  printf("Root is %4.6f", x0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movss  -0x8(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xe6d(%rip),%xmm1
addss  %xmm1,%xmm0
movss  0xe5d(%rip),%xmm1
mulss  %xmm1,%xmm0
mulss  -0x8(%rbp),%xmm0
movss  0xe48(%rip),%xmm1
mulss  -0x8(%rbp),%xmm1
mulss  -0x8(%rbp),%xmm1
movss  0xe36(%rip),%xmm2
mulss  -0x8(%rbp),%xmm2
mulss  -0x8(%rbp),%xmm2
mulss  %xmm2,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  0xe0e(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1205 <main+0xb5>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
mulss  -0x8(%rbp),%xmm1
movss  -0x8(%rbp),%xmm2
mulss  %xmm2,%xmm1
movss  0xdcf(%rip),%xmm2
addss  %xmm2,%xmm1
movss  0xdbb(%rip),%xmm2
mulss  -0x8(%rbp),%xmm2
mulss  -0x8(%rbp),%xmm2
divss  %xmm2,%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xd91(%rip),%xmm1
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1296 <main+0x146>
jp     1296 <main+0x146>
jmp    1397 <main+0x247>
movss  -0xc(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
call   1040 <fabs@plt>
movss  %xmm0,-0x10(%rbp)
mov    -0x20(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x20(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xd7b(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x20(%rbp)
je     131e <main+0x1ce>
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1302 <main+0x1b2>
jp     1302 <main+0x1b2>
jmp    131e <main+0x1ce>
movss  -0x14(%rbp),%xmm0
movss  0xcf1(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    1331 <main+0x1e1>
jp     1331 <main+0x1e1>
lea    0xd42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1372 <main+0x222>
movss  -0x10(%rbp),%xmm0
call   1060 <log@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x14(%rbp),%xmm0
call   1060 <log@plt>
movaps %xmm0,%xmm1
movss  -0x24(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd03(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xc83(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1213 <main+0xc3>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xcce(%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    $0x48,%rsp
lea    0xed6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee3(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
movss  0xc(%rsp),%xmm0
movaps %xmm0,%xmm1
mulss  %xmm0,%xmm1
mulss  %xmm0,%xmm1
addss  0xe6d(%rip),%xmm1
unpcklps %xmm0,%xmm1
mulps  0xe73(%rip),%xmm1
shufps $0x0,%xmm0,%xmm0
mulps  %xmm1,%xmm0
movaps %xmm0,%xmm1
mulps  %xmm0,%xmm1
shufps $0x55,%xmm1,%xmm1
divss  %xmm1,%xmm0
ucomiss 0xe4b(%rip),%xmm0
ja     1350 <main+0x200>
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
movss  0xc(%rsp),%xmm0
lea    0xe79(%rip),%r14
lea    0xeb7(%rip),%r15
lea    0xe82(%rip),%r12
movaps %xmm0,%xmm3
jmp    1229 <main+0xd9>
mov    %r15,%rdi
call   1030 <puts@plt>
movaps 0x30(%rsp),%xmm1
movss  0x14(%rsp),%xmm3
movss  %xmm3,0xc(%rsp)
add    $0x1,%ebx
movsd  0x40(%rsp),%xmm0
ucomisd 0xe16(%rip),%xmm0
movaps %xmm3,%xmm0
movss  %xmm1,0x10(%rsp)
jbe    132e <main+0x1de>
mulss  %xmm3,%xmm3
mulss  %xmm0,%xmm3
movss  0xdc7(%rip),%xmm2
addss  %xmm2,%xmm3
movaps %xmm0,%xmm1
mulss  0xdc0(%rip),%xmm1
mulss  %xmm0,%xmm1
divss  %xmm1,%xmm3
addss  %xmm0,%xmm3
movaps %xmm3,%xmm1
mulss  %xmm3,%xmm1
mulss  %xmm3,%xmm1
addss  %xmm2,%xmm1
ucomiss 0xda2(%rip),%xmm1
jne    1272 <main+0x122>
jnp    1324 <main+0x1d4>
movaps %xmm3,%xmm2
subss  %xmm0,%xmm2
movaps %xmm2,0x20(%rsp)
andps  0xd9b(%rip),%xmm2
cvtss2sd %xmm0,%xmm0
movss  %xmm3,0x14(%rsp)
xorps  %xmm1,%xmm1
cvtss2sd %xmm3,%xmm1
movaps %xmm2,0x30(%rsp)
cvtss2sd %xmm2,%xmm2
mov    %r14,%rdi
mov    %ebx,%esi
movsd  %xmm1,0x18(%rsp)
movsd  %xmm2,0x40(%rsp)
mov    $0x3,%al
call   1040 <printf@plt>
cmp    $0x1,%ebx
je     11f0 <main+0xa0>
movaps 0x20(%rsp),%xmm0
ucomiss 0xd40(%rip),%xmm0
jne    12d4 <main+0x184>
jnp    11f0 <main+0xa0>
movss  0x10(%rsp),%xmm0
ucomiss 0xd23(%rip),%xmm0
jne    12e9 <main+0x199>
jnp    11f0 <main+0xa0>
movaps 0x30(%rsp),%xmm0
call   1060 <log@plt>
movss  %xmm0,0x20(%rsp)
movss  0x10(%rsp),%xmm0
call   1060 <log@plt>
movss  0x20(%rsp),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    11f8 <main+0xa8>
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
lea    0xd3f(%rip),%rdi
movsd  0x18(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"Input the approximation : \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [26 x i8] c"Ite\09X0\09\09X1\09\09Error\09\09Order\0A\00"
@.str.3 = [23 x i8] c"%2d\09%4.6f\09%4.6f\09%4.6f\09\00"
@.str.4 = [7 x i8] c"-----\0A\00"
@.str.5 = [7 x i8] c"%4.6f\0A\00"
@.str.6 = [14 x i8] c"Root is %4.6f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%11 = load float, float* %2
%12 = load float, float* %2
%13 = fmul float %11, %12
%14 = load float, float* %2
%15 = call float @llvm.fmuladd.f32(float %13, float %14, float -1.800000e+01)
%16 = fmul float %15, 6.000000e+00
%17 = load float, float* %2
%18 = fmul float %16, %17
%19 = load float, float* %2
%20 = fmul float 3.000000e+00, %19
%21 = load float, float* %2
%22 = fmul float %20, %21
%23 = load float, float* %2
%24 = fmul float 3.000000e+00, %23
%25 = load float, float* %2
%26 = fmul float %24, %25
%27 = fmul float %22, %26
%28 = fdiv float %18, %27
store float %28, float* %6
%29 = load float, float* %6
%30 = fcmp ogt float %29, 1.000000e+00
br i1 %30, label %31, label %33
31: ; preds = %0
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %0
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %91, %33
%36 = load float, float* %4
store float %36, float* %5
%37 = load float, float* %2
%38 = load float, float* %2
%39 = load float, float* %2
%40 = fmul float %38, %39
%41 = load float, float* %2
%42 = call float @llvm.fmuladd.f32(float %40, float %41, float -1.800000e+01)
%43 = load float, float* %2
%44 = fmul float 3.000000e+00, %43
%45 = load float, float* %2
%46 = fmul float %44, %45
%47 = fdiv float %42, %46
%48 = fsub float %37, %47
store float %48, float* %3
%49 = load float, float* %3
%50 = load float, float* %3
%51 = fmul float %49, %50
%52 = load float, float* %3
%53 = call float @llvm.fmuladd.f32(float %51, float %52, float -1.800000e+01)
%54 = fcmp oeq float %53, 0.000000e+00
br i1 %54, label %55, label %56
55: ; preds = %35
br label %95
56: ; preds = %35
%57 = load float, float* %3
%58 = load float, float* %2
%59 = fsub float %57, %58
%60 = call float @fabs(float %59)
store float %60, float* %4
%61 = load i32, i32* %8
%62 = add nsw i32 %61, 1
store i32 %62, i32* %8
%63 = load float, float* %2
%64 = fpext float %63 to double
%65 = load float, float* %3
%66 = fpext float %65 to double
%67 = load float, float* %4
%68 = fpext float %67 to double
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %62, double %64, double %66, double %68)
%70 = load i32, i32* %8
%71 = icmp eq i32 %70, 1
br i1 %71, label %78, label %72
72: ; preds = %56
%73 = load float, float* %4
%74 = fcmp oeq float %73, 0.000000e+00
br i1 %74, label %78, label %75
75: ; preds = %72
%76 = load float, float* %5
%77 = fcmp oeq float %76, 1.000000e+00
br i1 %77, label %78, label %80
78: ; preds = %75, %72, %56
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %89
80: ; preds = %75
%81 = load float, float* %4
%82 = call float @log(float %81)
%83 = load float, float* %5
%84 = call float @log(float %83)
%85 = fdiv float %82, %84
store float %85, float* %7
%86 = load float, float* %7
%87 = fpext float %86 to double
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), double %87)
br label %89
89: ; preds = %80, %78
%90 = load float, float* %3
store float %90, float* %2
br label %91
91: ; preds = %89
%92 = load float, float* %4
%93 = fpext float %92 to double
%94 = fcmp ogt double %93, 5.000000e-05
br i1 %94, label %35, label %95
95: ; preds = %91, %55
%96 = load float, float* %2
%97 = fpext float %96 to double
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), double %97)
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"Input the approximation : \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.3 = [23 x i8] c"%2d\09%4.6f\09%4.6f\09%4.6f\09\00"
@.str.5 = [7 x i8] c"%4.6f\0A\00"
@.str.6 = [14 x i8] c"Root is %4.6f\00"
@str = [25 x i8] c"Ite\09X0\09\09X1\09\09Error\09\09Order\00"
@str.7 = [6 x i8] c"-----\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%5 = load float, float* %1
%6 = fmul float %5, %5
%7 = call float @llvm.fmuladd.f32(float %6, float %5, float -1.800000e+01)
%8 = insertelement <2 x float> poison, float %7, i64 0
%9 = insertelement <2 x float> %8, float %5, i64 1
%10 = fmul <2 x float> %9, <float 6.000000e+00, float 3.000000e+00>
%11 = insertelement <2 x float> poison, float %5, i64 0
%12 = shufflevector <2 x float> %11, <2 x float> poison, <2 x i32> zeroinitializer
%13 = fmul <2 x float> %12, %10
%14 = fmul <2 x float> %13, %13
%15 = extractelement <2 x float> %14, i64 1
%16 = extractelement <2 x float> %13, i64 0
%17 = fdiv float %16, %15
%18 = fcmp ogt float %17, 1.000000e+00
br i1 %18, label %19, label %21
19: ; preds = %0
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %0
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%23 = load float, float* %1
br label %24
24: ; preds = %60, %21
%25 = phi float [ %23, %21 ], [ %33, %60 ]
%26 = phi float [ undef, %21 ], [ %41, %60 ]
%27 = phi i32 [ 0, %21 ], [ %42, %60 ]
%28 = fmul float %25, %25
%29 = call float @llvm.fmuladd.f32(float %28, float %25, float -1.800000e+01)
%30 = fmul float %25, 3.000000e+00
%31 = fmul float %25, %30
%32 = fdiv float %29, %31
%33 = fsub float %25, %32
%34 = fmul float %33, %33
%35 = call float @llvm.fmuladd.f32(float %34, float %33, float -1.800000e+01)
%36 = fcmp oeq float %35, 0.000000e+00
br i1 %36, label %37, label %39
37: ; preds = %24
%38 = fpext float %25 to double
br label %62
39: ; preds = %24
%40 = fsub float %33, %25
%41 = call float @llvm.fabs.f32(float %40)
%42 = add nuw nsw i32 %27, 1
%43 = fpext float %25 to double
%44 = fpext float %33 to double
%45 = fpext float %41 to double
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %42, double %43, double %44, double %45)
%47 = icmp eq i32 %27, 0
%48 = fcmp oeq float %40, 0.000000e+00
%49 = select i1 %47, i1 true, i1 %48
%50 = fcmp oeq float %26, 1.000000e+00
%51 = select i1 %49, i1 true, i1 %50
br i1 %51, label %52, label %54
52: ; preds = %39
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.7, i64 0, i64 0))
br label %60
54: ; preds = %39
%55 = call float @log(float %41)
%56 = call float @log(float %26)
%57 = fdiv float %55, %56
%58 = fpext float %57 to double
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), double %58)
br label %60
60: ; preds = %54, %52
store float %33, float* %1
%61 = fcmp ogt double %45, 5.000000e-05
br i1 %61, label %24, label %62
62: ; preds = %60, %37
%63 = phi double [ %38, %37 ], [ %44, %60 ]
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), double %63)
ret i32 0
}