#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() {
  printf("Funcao: (x+1)^2*e^(x^2-2)-1\n");
  int k = 0, flg = 1;
  float xAnt, xAtual, xProx;
  float erro;
  xAnt = -2;
  xAtual = -1;
  while (flg == 1) {
    if (k == 0) {
      xProx = ((xAnt * f(xAtual)) - (xAtual * f(xAnt))) / (f(xAtual) - f(xAnt));
      printf("%d\t%f\t%f\t%f\t%f\t%f\t%f\t------\n", k, xAnt, f(xAnt), xAtual,
             f(xAtual), xProx, f(xProx));
    } else {
      if (f(xAtual) * f(xProx) > 0) {
        xAtual = xProx;
        xProx =
            ((xAnt * f(xAtual)) - (xAtual * f(xAnt))) / (f(xAtual) - f(xAnt));
        erro = fabs((xAtual - xProx) / xProx);
        if (erro <= pow(10, -2))
          flg = 0;
        printf("%d\t%f\t%f\t%f\t%f\t%f\t%f\t%f\n", k, xAnt, f(xAnt), xAtual,
               f(xAtual), xProx, f(xProx), erro);
      }
    }
    k++;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movss  0xe95(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xe84(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    14d1 <main+0x391>
cmpl   $0x0,-0x4(%rbp)
jne    12c5 <main+0x185>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
movss  -0x10(%rbp),%xmm0
call   1030 <f@plt>
movsd  %xmm0,-0x68(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x70(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <f@plt>
movsd  -0x70(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movss  -0x10(%rbp),%xmm0
call   1030 <f@plt>
movsd  %xmm0,-0x58(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <f@plt>
movsd  -0x58(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x44(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <f@plt>
movsd  %xmm0,-0x40(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movss  -0x10(%rbp),%xmm0
call   1030 <f@plt>
movsd  %xmm0,-0x30(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movss  -0x14(%rbp),%xmm0
call   1030 <f@plt>
mov    -0x44(%rbp),%esi
movsd  -0x40(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
movsd  -0x28(%rbp),%xmm4
movaps %xmm0,%xmm5
movsd  -0x20(%rbp),%xmm0
lea    0xd6c(%rip),%rdi
mov    $0x6,%al
call   1040 <printf@plt>
jmp    14c3 <main+0x383>
movss  -0x10(%rbp),%xmm0
call   1030 <f@plt>
movsd  %xmm0,-0x78(%rbp)
movss  -0x14(%rbp),%xmm0
call   1030 <f@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    14be <main+0x37e>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movss  -0x10(%rbp),%xmm0
call   1030 <f@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movss  -0xc(%rbp),%xmm0
call   1030 <f@plt>
movsd  -0xa8(%rbp),%xmm1
ff
movsd  -0xa0(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0x98(%rbp),%xmm0
ff
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movss  -0x10(%rbp),%xmm0
call   1030 <f@plt>
movsd  %xmm0,-0x90(%rbp)
ff
movss  -0xc(%rbp),%xmm0
call   1030 <f@plt>
movsd  -0x90(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x88(%rbp),%xmm0
ff
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
divss  -0x14(%rbp),%xmm0
call   1050 <fabs@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x7c(%rbp)
mov    $0xa,%edi
mov    $0xfffffffe,%esi
call   1060 <pow@plt>
movss  -0x7c(%rbp),%xmm1
ucomiss %xmm1,%xmm0
jb     140c <main+0x2cc>
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xd4(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movss  -0xc(%rbp),%xmm0
call   1030 <f@plt>
movsd  %xmm0,-0xd0(%rbp)
ff
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movss  -0x10(%rbp),%xmm0
call   1030 <f@plt>
movsd  %xmm0,-0xc0(%rbp)
ff
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movss  -0x14(%rbp),%xmm0
call   1030 <f@plt>
mov    -0xd4(%rbp),%esi
movsd  -0xd0(%rbp),%xmm1
ff
movsd  -0xc8(%rbp),%xmm2
ff
movsd  -0xc0(%rbp),%xmm3
ff
movsd  -0xb8(%rbp),%xmm4
ff
movaps %xmm0,%xmm5
movsd  -0xb0(%rbp),%xmm0
ff
movss  -0x18(%rbp),%xmm6
cvtss2sd %xmm6,%xmm6
lea    0xb8b(%rip),%rdi
mov    $0x7,%al
call   1040 <printf@plt>
jmp    14c3 <main+0x383>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1181 <main+0x41>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
lea    0xf15(%rip),%rdi
call   1030 <puts@plt>
movss  0xea2(%rip),%xmm1
xor    %ebx,%ebx
lea    0xec9(%rip),%r14
lea    0xedf(%rip),%r15
jmp    127f <main+0x13f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  0x20(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
movss  0xe6c(%rip),%xmm0
call   1040 <f@plt>
mulsd  0x18(%rsp),%xmm0
movsd  0xe5d(%rip),%xmm1
movsd  0x10(%rsp),%xmm2
mulsd  %xmm1,%xmm2
subsd  %xmm0,%xmm2
movsd  %xmm2,0x10(%rsp)
movss  0x20(%rsp),%xmm0
call   1040 <f@plt>
movsd  %xmm0,0x8(%rsp)
movss  0xe2c(%rip),%xmm0
call   1040 <f@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
movss  0xe01(%rip),%xmm0
call   1040 <f@plt>
movsd  %xmm0,0x10(%rsp)
movss  0x20(%rsp),%xmm0
call   1040 <f@plt>
movsd  %xmm0,0x38(%rsp)
movss  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movsd  %xmm0,0x30(%rsp)
movaps %xmm1,%xmm0
call   1040 <f@plt>
movaps %xmm0,%xmm5
mov    %r14,%rdi
xor    %esi,%esi
movsd  0xdbe(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0x38(%rsp),%xmm3
movsd  0x30(%rsp),%xmm4
mov    $0x6,%al
call   1050 <printf@plt>
mov    $0x1,%ebp
movss  0x20(%rsp),%xmm1
add    $0x1,%ebx
test   %ebp,%ebp
je     140d <main+0x2cd>
movss  %xmm1,0x20(%rsp)
movaps %xmm1,%xmm0
call   1040 <f@plt>
test   %ebx,%ebx
movsd  %xmm0,0x10(%rsp)
je     1180 <main+0x40>
movss  0x8(%rsp),%xmm0
call   1040 <f@plt>
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
mov    $0x1,%ebp
ucomisd 0xd53(%rip),%xmm1
jbe    126e <main+0x12e>
movss  0x8(%rsp),%xmm0
call   1040 <f@plt>
movsd  %xmm0,0x20(%rsp)
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
movss  0xd1c(%rip),%xmm0
call   1040 <f@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0xd0d(%rip),%xmm1
movsd  0x20(%rsp),%xmm2
mulsd  %xmm1,%xmm2
subsd  %xmm0,%xmm2
movsd  %xmm2,0x20(%rsp)
movss  0x8(%rsp),%xmm0
call   1040 <f@plt>
movsd  %xmm0,0x18(%rsp)
movss  0xcdc(%rip),%xmm0
call   1040 <f@plt>
movsd  0x18(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0x20(%rsp),%xmm0
divsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsd2ss %xmm0,%xmm1
movss  %xmm1,0x18(%rsp)
movss  0x8(%rsp),%xmm0
subss  %xmm1,%xmm0
divss  %xmm1,%xmm0
andps  0xcbd(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    $0xa,%edi
mov    $0xfffffffe,%esi
call   1060 <pow@plt>
xor    %ebp,%ebp
ucomiss 0x20(%rsp),%xmm0
setb   %bpl
movss  0xc7a(%rip),%xmm0
call   1040 <f@plt>
movsd  %xmm0,0x38(%rsp)
movss  0x8(%rsp),%xmm0
call   1040 <f@plt>
movsd  %xmm0,0x30(%rsp)
movss  0x18(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  %xmm1,0x40(%rsp)
call   1040 <f@plt>
movaps %xmm0,%xmm5
movaps 0x20(%rsp),%xmm0
cvtss2sd %xmm0,%xmm6
mov    %r15,%rdi
mov    %ebx,%esi
movsd  0xc31(%rip),%xmm0
movsd  0x38(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
movsd  0x30(%rsp),%xmm3
movsd  0x40(%rsp),%xmm4
mov    $0x7,%al
call   1050 <printf@plt>
movss  0x8(%rsp),%xmm1
movss  0x18(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
jmp    1274 <main+0x134>
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [29 x i8] c"%d\09%f\09%f\09%f\09%f\09%f\09%f\09------\0A\00"
@.str.2 = [25 x i8] c"%d\09%f\09%f\09%f\09%f\09%f\09%f\09%f\0A\00"
@str = [28 x i8] c"Funcao: (x+1)^2*e^(x^2-2)-1\00"
define void @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %52
%3 = phi i32 [ 0, %0 ], [ %56, %52 ]
%4 = phi float [ undef, %0 ], [ %55, %52 ]
%5 = phi float [ -1.000000e+00, %0 ], [ %54, %52 ]
%6 = icmp eq i32 %3, 0
%7 = tail call double @f(float %5)
br i1 %6, label %8, label %24
8: ; preds = %2
%9 = fpext float %5 to double
%10 = tail call double @f(float -2.000000e+00)
%11 = fneg double %10
%12 = fmul double %9, %11
%13 = tail call double @llvm.fmuladd.f64(double %7, double -2.000000e+00, double %12)
%14 = tail call double @f(float %5)
%15 = tail call double @f(float -2.000000e+00)
%16 = fsub double %14, %15
%17 = fdiv double %13, %16
%18 = fptrunc double %17 to float
%19 = tail call double @f(float -2.000000e+00)
%20 = tail call double @f(float %5)
%21 = fpext float %18 to double
%22 = tail call double @f(float %18)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 0, double -2.000000e+00, double %19, double %9, double %20, double %21, double %22)
br label %52
24: ; preds = %2
%25 = tail call double @f(float %4)
%26 = fmul double %7, %25
%27 = fcmp ogt double %26, 0.000000e+00
br i1 %27, label %28, label %52
28: ; preds = %24
%29 = tail call double @f(float %4)
%30 = fpext float %4 to double
%31 = tail call double @f(float -2.000000e+00)
%32 = fneg double %31
%33 = fmul double %30, %32
%34 = tail call double @llvm.fmuladd.f64(double %29, double -2.000000e+00, double %33)
%35 = tail call double @f(float %4)
%36 = tail call double @f(float -2.000000e+00)
%37 = fsub double %35, %36
%38 = fdiv double %34, %37
%39 = fptrunc double %38 to float
%40 = fsub float %4, %39
%41 = fdiv float %40, %39
%42 = tail call float @llvm.fabs.f32(float %41)
%43 = tail call float @pow(i32 10, i32 -2)
%44 = fcmp ugt float %42, %43
%45 = zext i1 %44 to i32
%46 = tail call double @f(float -2.000000e+00)
%47 = tail call double @f(float %4)
%48 = fpext float %39 to double
%49 = tail call double @f(float %39)
%50 = fpext float %42 to double
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %3, double -2.000000e+00, double %46, double %30, double %47, double %48, double %49, double %50)
br label %52
52: ; preds = %24, %28, %8
%53 = phi i32 [ 1, %8 ], [ %45, %28 ], [ 1, %24 ]
%54 = phi float [ %5, %8 ], [ %4, %28 ], [ %5, %24 ]
%55 = phi float [ %18, %8 ], [ %39, %28 ], [ %4, %24 ]
%56 = add nuw nsw i32 %3, 1
%57 = icmp eq i32 %53, 1
br i1 %57, label %2, label %58
58: ; preds = %52
ret void
}