#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 module(double);
double polynomialValue(int, float *, float);
int /*<<< orphan*/ printf(char *, float, double);
float calculatePolynomRoot(int level, float polynomialEquation[],
                           float intervalBeginning, float intervalEnding) {
  float adirissa;
  do {
    adirissa = (intervalBeginning + intervalEnding) / 2;
    if (polynomialValue(level, polynomialEquation, intervalBeginning) *
            polynomialValue(level, polynomialEquation, adirissa) <
        0)
      intervalEnding = adirissa;
    else
      intervalBeginning = adirissa;
    printf("Intervalo de busca:[%f, %f] \n", intervalBeginning, intervalEnding);
    printf("P(%f) = %f\n\n", adirissa,
           polynomialValue(level, polynomialEquation, adirissa));
  } while (module(polynomialValue(level, polynomialEquation, adirissa)) >
           0.000001);
  return adirissa;
}


x86 assembly (clang, -O0):
<calculatePolynomRoot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
movss  %xmm1,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x18(%rbp),%xmm0
movss  0xea5(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
movss  -0x14(%rbp),%xmm0
call   1030 <polynomialValue@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
movss  -0x1c(%rbp),%xmm0
call   1030 <polynomialValue@plt>
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    11b0 <calculatePolynomRoot+0x80>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    11ba <calculatePolynomRoot+0x8a>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe41(%rip),%rdi
call   1040 <printf@plt>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
movss  -0x1c(%rbp),%xmm0
call   1030 <polynomialValue@plt>
movaps %xmm0,%xmm1
movss  -0x2c(%rbp),%xmm0
lea    0xe30(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
movss  -0x1c(%rbp),%xmm0
call   1030 <polynomialValue@plt>
call   1050 <module@plt>
movsd  0xde7(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1149 <calculatePolynomRoot+0x19>
movss  -0x1c(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculatePolynomRoot>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movss  %xmm0,0x4(%rsp)
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xecc(%rip),%r14
lea    0xee3(%rip),%r15
jmp    11bb <calculatePolynomRoot+0x8b>
cs nopw 0x0(%rax,%rax,1)
nop
movss  %xmm1,0x8(%rsp)
cvtss2sd %xmm1,%xmm1
mov    %r14,%rdi
movss  0x4(%rsp),%xmm0
call   1040 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
movss  (%rsp),%xmm0
call   1030 <polynomialValue@plt>
movaps %xmm0,%xmm1
mov    %r15,%rdi
movss  (%rsp),%xmm0
call   1040 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
movss  (%rsp),%xmm0
call   1030 <polynomialValue@plt>
call   1050 <module@plt>
ucomisd 0xe55(%rip),%xmm0
movss  0x8(%rsp),%xmm1
jbe    1225 <calculatePolynomRoot+0xf5>
movss  %xmm1,0x14(%rsp)
movss  0x4(%rsp),%xmm0
addss  %xmm0,%xmm1
mulss  0xe2d(%rip),%xmm1
movss  %xmm1,(%rsp)
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <polynomialValue@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
mov    %rbx,%rsi
movss  (%rsp),%xmm0
call   1030 <polynomialValue@plt>
mulsd  0x8(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
movss  (%rsp),%xmm1
ja     1160 <calculatePolynomRoot+0x30>
movss  0x14(%rsp),%xmm1
movss  (%rsp),%xmm0
movss  %xmm0,0x4(%rsp)
jmp    1160 <calculatePolynomRoot+0x30>
movss  (%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Intervalo de busca:[%f, %f] \0A\00"
@.str.1 = [13 x i8] c"P(%f) = %f\0A\0A\00"
define float @calculatePolynomRoot(i32 %0, float* %1, float %2, float %3) {
%5 = alloca i32
%6 = alloca float*
%7 = alloca float
%8 = alloca float
%9 = alloca float
store i32 %0, i32* %5
store float* %1, float** %6
store float %2, float* %7
store float %3, float* %8
br label %10
10: ; preds = %40, %4
%11 = load float, float* %7
%12 = load float, float* %8
%13 = fadd float %11, %12
%14 = fdiv float %13, 2.000000e+00
store float %14, float* %9
%15 = load i32, i32* %5
%16 = load float*, float** %6
%17 = load float, float* %7
%18 = call double @polynomialValue(i32 %15, float* %16, float %17)
%19 = load i32, i32* %5
%20 = load float*, float** %6
%21 = load float, float* %9
%22 = call double @polynomialValue(i32 %19, float* %20, float %21)
%23 = fmul double %18, %22
%24 = fcmp olt double %23, 0.000000e+00
br i1 %24, label %25, label %27
25: ; preds = %10
%26 = load float, float* %9
store float %26, float* %8
br label %29
27: ; preds = %10
%28 = load float, float* %9
store float %28, float* %7
br label %29
29: ; preds = %27, %25
%30 = load float, float* %7
%31 = load float, float* %8
%32 = fpext float %31 to double
%33 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), float %30, double %32)
%34 = load float, float* %9
%35 = load i32, i32* %5
%36 = load float*, float** %6
%37 = load float, float* %9
%38 = call double @polynomialValue(i32 %35, float* %36, float %37)
%39 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), float %34, double %38)
br label %40
40: ; preds = %29
%41 = load i32, i32* %5
%42 = load float*, float** %6
%43 = load float, float* %9
%44 = call double @polynomialValue(i32 %41, float* %42, float %43)
%45 = call double @module(double %44)
%46 = fcmp ogt double %45, 0x3EB0C6F7A0B5ED8D
br i1 %46, label %10, label %47
47: ; preds = %40
%48 = load float, float* %9
ret float %48
}

LLVM IR (-O2):
@.str = [30 x i8] c"Intervalo de busca:[%f, %f] \0A\00"
@.str.1 = [13 x i8] c"P(%f) = %f\0A\0A\00"
define float @calculatePolynomRoot(i32 %0, float* %1, float %2, float %3) {
br label %5
5: ; preds = %5, %4
%6 = phi float [ %3, %4 ], [ %14, %5 ]
%7 = phi float [ %2, %4 ], [ %15, %5 ]
%8 = fadd float %6, %7
%9 = fmul float %8, 5.000000e-01
%10 = tail call double @polynomialValue(i32 %0, float* %1, float %7)
%11 = tail call double @polynomialValue(i32 %0, float* %1, float %9)
%12 = fmul double %10, %11
%13 = fcmp olt double %12, 0.000000e+00
%14 = select i1 %13, float %9, float %6
%15 = select i1 %13, float %7, float %9
%16 = fpext float %14 to double
%17 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), float %15, double %16)
%18 = tail call double @polynomialValue(i32 %0, float* %1, float %9)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), float %9, double %18)
%20 = tail call double @polynomialValue(i32 %0, float* %1, float %9)
%21 = tail call double @module(double %20)
%22 = fcmp ogt double %21, 0x3EB0C6F7A0B5ED8D
br i1 %22, label %5, label %23
23: ; preds = %5
ret float %9
}