#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 f(float);
float fabs(float);
float pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
void main() {
  int k = 0, flg = 1;
  float x = 0.25;
  float erro;
  printf("k\tx\tf(x)\tE\n");
  while (flg) {
    erro = fabs((x - f(x)) / f(x));
    printf("%d\t%.4f\t%.4f\t%.4f\n", k, x, f(x), erro);
    x = f(x);
    if (erro <= pow(10, -3))
      flg = 0;
    k++;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movss  0xea2(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     1257 <main+0x117>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <f@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <f@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1050 <fabs@plt>
movss  %xmm0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <f@plt>
mov    -0x24(%rbp),%esi
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
movss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe0f(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
movss  -0xc(%rbp),%xmm0
call   1030 <f@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    $0xa,%edi
mov    $0xfffffffd,%esi
call   1060 <pow@plt>
movss  -0x14(%rbp),%xmm1
ucomiss %xmm1,%xmm0
jb     1249 <main+0x109>
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1171 <main+0x31>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xee5(%rip),%rdi
call   1030 <puts@plt>
movss  0xea5(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
xor    %ebx,%ebx
lea    0xeb6(%rip),%r14
nopw   0x0(%rax,%rax,1)
movss  0x4(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
call   1040 <f@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movss  0x4(%rsp),%xmm0
call   1040 <f@plt>
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
andps  0xe55(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movss  0x4(%rsp),%xmm0
call   1040 <f@plt>
movaps %xmm0,%xmm1
movaps 0x10(%rsp),%xmm0
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
mov    %r14,%rdi
mov    %ebx,%esi
movsd  0x8(%rsp),%xmm0
mov    $0x3,%al
call   1050 <printf@plt>
movss  0x4(%rsp),%xmm0
call   1040 <f@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
mov    $0xa,%edi
mov    $0xfffffffd,%esi
call   1060 <pow@plt>
add    $0x1,%ebx
ucomiss 0x10(%rsp),%xmm0
jb     1170 <main+0x30>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"k\09x\09f(x)\09E\0A\00"
@.str.1 = [19 x i8] c"%d\09%.4f\09%.4f\09%.4f\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
store i32 0, i32* %1
store i32 1, i32* %2
store float 2.500000e-01, float* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %35, %0
%7 = load i32, i32* %2
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %38
9: ; preds = %6
%10 = load float, float* %3
%11 = fpext float %10 to double
%12 = load float, float* %3
%13 = call double @f(float %12)
%14 = fsub double %11, %13
%15 = load float, float* %3
%16 = call double @f(float %15)
%17 = fdiv double %14, %16
%18 = fptrunc double %17 to float
%19 = call float @fabs(float %18)
store float %19, float* %4
%20 = load i32, i32* %1
%21 = load float, float* %3
%22 = fpext float %21 to double
%23 = load float, float* %3
%24 = call double @f(float %23)
%25 = load float, float* %4
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %20, double %22, double %24, double %26)
%28 = load float, float* %3
%29 = call double @f(float %28)
%30 = fptrunc double %29 to float
store float %30, float* %3
%31 = load float, float* %4
%32 = call float @pow(i32 10, i32 -3)
%33 = fcmp ole float %31, %32
br i1 %33, label %34, label %35
34: ; preds = %9
store i32 0, i32* %2
br label %35
35: ; preds = %34, %9
%36 = load i32, i32* %1
%37 = add nsw i32 %36, 1
store i32 %37, i32* %1
br label %6
38: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"%d\09%.4f\09%.4f\09%.4f\0A\00"
@str = [11 x i8] c"k\09x\09f(x)\09E\00"
define void @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %19, %2 ]
%4 = phi float [ 2.500000e-01, %0 ], [ %16, %2 ]
%5 = fpext float %4 to double
%6 = tail call double @f(float %4)
%7 = fsub double %5, %6
%8 = tail call double @f(float %4)
%9 = fdiv double %7, %8
%10 = fptrunc double %9 to float
%11 = tail call float @llvm.fabs.f32(float %10)
%12 = tail call double @f(float %4)
%13 = fpext float %11 to double
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %3, double %5, double %12, double %13)
%15 = tail call double @f(float %4)
%16 = fptrunc double %15 to float
%17 = tail call float @pow(i32 10, i32 -3)
%18 = fcmp ugt float %11, %17
%19 = add nuw nsw i32 %3, 1
br i1 %18, label %2, label %20
20: ; preds = %2
ret void
}