#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 */
float fabs(float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
int main() {
  int count = 0;
  float x0 = 0, x1 = 0, error = 0;
  char iffound = 0;
  printf("Please enter the initial value: ");
  scanf("%f", &x0);
  do {
    x1 = (1 + (6 / x0));
    error = fabs(x1 - x0);
    if (count == 0) {
      if (((-1) * 6 / (x0 * x0)) > 1) {
        printf("\nThe equation is not convergent");
        iffound = 1;
        break;
      } else {
        printf("\n   i	  xi	  f(xi)	         error");
        printf("\n-------------------------------------------");
      }
    }
    printf("\n %3d	%3.5f	 %3.5f	%3.5f", count, x0, (x0 * x0 - x0 - 6),
           count == 0 ? -1 : error);
    x0 = x1;
    count++;
  } while (error > 0.0005 && count < 5000);
  if (!iffound)
    printf("\nThe required root is: %f\n", x0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movb   $0x0,-0x15(%rbp)
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec2(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
movss  0xe7c(%rip),%xmm1
divss  -0xc(%rbp),%xmm1
movss  0xe6b(%rip),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
call   1040 <fabs@plt>
movss  %xmm0,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    121b <main+0xeb>
movss  -0xc(%rbp),%xmm1
mulss  -0xc(%rbp),%xmm1
movss  0xe3a(%rip),%xmm0
divss  %xmm1,%xmm0
movss  0xe26(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    11fa <main+0xca>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x1,-0x15(%rbp)
jmp    12fd <main+0x1cd>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121b <main+0xeb>
mov    -0x8(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
movss  -0xc(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  0xda9(%rip),%xmm1
subss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1284 <main+0x154>
movss  0xd92(%rip),%xmm0
movss  %xmm0,-0x30(%rbp)
jmp    128e <main+0x15e>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
mov    -0x2c(%rbp),%esi
movss  -0x30(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe00(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xor    %eax,%eax
movsd  0xd38(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x31(%rbp)
jbe    12f2 <main+0x1c2>
cmpl   $0x1388,-0x8(%rbp)
setl   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1180 <main+0x50>
cmpb   $0x0,-0x15(%rbp)
jne    131e <main+0x1ee>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdad(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
movl   $0x0,0x8(%rsp)
lea    0xeee(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf01(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
movss  0x8(%rsp),%xmm1
movss  0xea4(%rip),%xmm2
lea    0xf05(%rip),%r14
lea    0xf20(%rip),%r15
lea    0xf46(%rip),%r12
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movss  0xe78(%rip),%xmm3
divss  %xmm1,%xmm3
addss  %xmm2,%xmm3
movaps %xmm3,%xmm4
subss  %xmm1,%xmm4
andps  0xe72(%rip),%xmm4
test   %ebx,%ebx
movss  %xmm3,0xc(%rsp)
movaps %xmm4,0x10(%rsp)
je     11c0 <main+0xa0>
movaps %xmm4,%xmm2
jmp    11fb <main+0xdb>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mulss  %xmm1,%xmm1
movss  0xe3c(%rip),%xmm0
divss  %xmm1,%xmm0
ucomiss %xmm2,%xmm0
ja     127e <main+0x15e>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movss  0x8(%rsp),%xmm1
movss  0xe11(%rip),%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movaps %xmm1,%xmm3
mulss  %xmm1,%xmm3
subss  %xmm1,%xmm3
addss  0xdf3(%rip),%xmm3
xorps  %xmm1,%xmm1
cvtss2sd %xmm3,%xmm1
cvtss2sd %xmm2,%xmm2
mov    %r12,%rdi
mov    %ebx,%esi
mov    $0x3,%al
call   1030 <printf@plt>
movss  0xc(%rsp),%xmm3
movss  %xmm3,0x8(%rsp)
movaps 0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
ucomisd 0xdd7(%rip),%xmm0
movss  0xdb3(%rip),%xmm2
jbe    1267 <main+0x147>
lea    0x1(%rbx),%eax
movaps %xmm3,%xmm1
cmp    $0x1387,%ebx
mov    %eax,%ebx
jb     1180 <main+0x60>
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
lea    0xe5f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    128c <main+0x16c>
lea    0xdc7(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Please enter the initial value: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [32 x i8] c"\0AThe equation is not convergent\00"
@.str.3 = [34 x i8] c"\0A i\09 xi\09 f(xi)\09 error\00"
@.str.4 = [45 x i8] c"\0A-------------------------------------------\00"
@.str.5 = [25 x i8] c"\0A %3d\09%3.5f\09 %3.5f\09%3.5f\00"
@.str.6 = [27 x i8] c"\0AThe required root is: %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %2
store float 0.000000e+00, float* %3
store float 0.000000e+00, float* %4
store float 0.000000e+00, float* %5
store i8 0, i8* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
br label %9
9: ; preds = %61, %0
%10 = load float, float* %3
%11 = fdiv float 6.000000e+00, %10
%12 = fadd float 1.000000e+00, %11
store float %12, float* %4
%13 = load float, float* %4
%14 = load float, float* %3
%15 = fsub float %13, %14
%16 = call float @fabs(float %15)
store float %16, float* %5
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %31
19: ; preds = %9
%20 = load float, float* %3
%21 = load float, float* %3
%22 = fmul float %20, %21
%23 = fdiv float -6.000000e+00, %22
%24 = fcmp ogt float %23, 1.000000e+00
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
store i8 1, i8* %6
br label %63
27: ; preds = %19
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
br label %30
30: ; preds = %27
br label %31
31: ; preds = %30, %9
%32 = load i32, i32* %2
%33 = load float, float* %3
%34 = fpext float %33 to double
%35 = load float, float* %3
%36 = load float, float* %3
%37 = load float, float* %3
%38 = fneg float %37
%39 = call float @llvm.fmuladd.f32(float %35, float %36, float %38)
%40 = fsub float %39, 6.000000e+00
%41 = fpext float %40 to double
%42 = load i32, i32* %2
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %31
br label %47
45: ; preds = %31
%46 = load float, float* %5
br label %47
47: ; preds = %45, %44
%48 = phi float [ -1.000000e+00, %44 ], [ %46, %45 ]
%49 = fpext float %48 to double
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %32, double %34, double %41, double %49)
%51 = load float, float* %4
store float %51, float* %3
%52 = load i32, i32* %2
%53 = add nsw i32 %52, 1
store i32 %53, i32* %2
br label %54
54: ; preds = %47
%55 = load float, float* %5
%56 = fpext float %55 to double
%57 = fcmp ogt double %56, 5.000000e-04
br i1 %57, label %58, label %61
58: ; preds = %54
%59 = load i32, i32* %2
%60 = icmp slt i32 %59, 5000
br label %61
61: ; preds = %58, %54
%62 = phi i1 [ false, %54 ], [ %60, %58 ]
br i1 %62, label %9, label %63
63: ; preds = %61, %25
%64 = load i8, i8* %6
%65 = icmp ne i8 %64, 0
br i1 %65, label %70, label %66
66: ; preds = %63
%67 = load float, float* %3
%68 = fpext float %67 to double
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), double %68)
br label %70
70: ; preds = %66, %63
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"Please enter the initial value: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [32 x i8] c"\0AThe equation is not convergent\00"
@.str.3 = [34 x i8] c"\0A i\09 xi\09 f(xi)\09 error\00"
@.str.4 = [45 x i8] c"\0A-------------------------------------------\00"
@.str.5 = [25 x i8] c"\0A %3d\09%3.5f\09 %3.5f\09%3.5f\00"
@.str.6 = [27 x i8] c"\0AThe required root is: %f\0A\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
store float 0.000000e+00, float* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 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
br label %6
6: ; preds = %24, %0
%7 = phi float [ %5, %0 ], [ %10, %24 ]
%8 = phi i32 [ 0, %0 ], [ %34, %24 ]
%9 = fdiv float 6.000000e+00, %7
%10 = fadd float %9, 1.000000e+00
%11 = fsub float %10, %7
%12 = call float @llvm.fabs.f32(float %11)
%13 = icmp eq i32 %8, 0
br i1 %13, label %14, label %24
14: ; preds = %6
%15 = fmul float %7, %7
%16 = fdiv float -6.000000e+00, %15
%17 = fcmp ogt float %16, 1.000000e+00
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %42
20: ; preds = %14
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
%23 = load float, float* %1
br label %24
24: ; preds = %20, %6
%25 = phi float [ %23, %20 ], [ %7, %6 ]
%26 = phi float [ -1.000000e+00, %20 ], [ %12, %6 ]
%27 = fpext float %25 to double
%28 = fneg float %25
%29 = call float @llvm.fmuladd.f32(float %25, float %25, float %28)
%30 = fadd float %29, -6.000000e+00
%31 = fpext float %30 to double
%32 = fpext float %26 to double
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %8, double %27, double %31, double %32)
store float %10, float* %1
%34 = add nuw nsw i32 %8, 1
%35 = fpext float %12 to double
%36 = fcmp ogt double %35, 5.000000e-04
%37 = icmp ult i32 %8, 4999
%38 = select i1 %36, i1 %37, i1 false
br i1 %38, label %6, label %39
39: ; preds = %24
%40 = fpext float %10 to double
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), double %40)
br label %42
42: ; preds = %18, %39
ret i32 0
}