#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 calculatePolynomRoot(int, float *, float, float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  int level, currentCoefficient;
  float polynomialEquation[15], intervalBeginning, intervalEnding;
  printf("Grau do polinomio: ");
  scanf("%d", &level);
  if (level < 15) {
    printf("Coeficientes do polinomio: ");
    for (currentCoefficient = 0; currentCoefficient <= level;
         currentCoefficient++)
      scanf("%f", &polynomialEquation[currentCoefficient]);
  } else
    printf("Grau do polinomio muito elevado!");
  printf("\nIntervalo Desejado: ");
  scanf("%f %f", &intervalBeginning, &intervalEnding);
  printf("\nA raiz no intervalo e: %f",
         calculatePolynomRoot(level, polynomialEquation, intervalBeginning,
                              intervalEnding));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0xf,-0x8(%rbp)
jge    11ba <main+0x8a>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11b5 <main+0x85>
movslq -0xc(%rbp),%rax
lea    -0x50(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xee8(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117e <main+0x4e>
jmp    11c8 <main+0x98>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8d(%rip),%rdi
lea    -0x54(%rbp),%rsi
lea    -0x58(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%edi
lea    -0x50(%rbp),%rsi
movss  -0x54(%rbp),%xmm0
movss  -0x58(%rbp),%xmm1
call   1050 <calculatePolynomRoot@plt>
lea    0xe67(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
lea    0xec0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0xe,0x4(%rsp)
jg     11b1 <main+0x81>
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x0,0x4(%rsp)
js     11bf <main+0x8f>
mov    $0xffffffffffffffff,%r15
lea    0x10(%rsp),%rbx
lea    0xeff(%rip),%r14
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movslq 0x4(%rsp),%rax
add    $0x1,%r15
add    $0x4,%rbx
cmp    %rax,%r15
jl     1190 <main+0x60>
jmp    11bf <main+0x8f>
lea    0xe7b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe8e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe96(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x4(%rsp),%edi
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
lea    0x10(%rsp),%rsi
call   1050 <calculatePolynomRoot@plt>
lea    0xe6a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Grau do polinomio: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [28 x i8] c"Coeficientes do polinomio: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [33 x i8] c"Grau do polinomio muito elevado!\00"
@.str.5 = [22 x i8] c"\0AIntervalo Desejado: \00"
@.str.6 = [6 x i8] c"%f %f\00"
@.str.7 = [27 x i8] c"\0AA raiz no intervalo e: %f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [15 x float]
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 15
br i1 %10, label %11, label %26
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %13
13: ; preds = %22, %11
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [15 x float], [15 x float]* %4, i64 0, i64 %19
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %20)
br label %22
22: ; preds = %17
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %13
25: ; preds = %13
br label %28
26: ; preds = %0
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
br label %28
28: ; preds = %26, %25
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%30 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), float* %5, float* %6)
%31 = load i32, i32* %2
%32 = getelementptr inbounds [15 x float], [15 x float]* %4, i64 0, i64 0
%33 = load float, float* %5
%34 = load float, float* %6
%35 = call double @calculatePolynomRoot(i32 %31, float* %32, float %33, float %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), double %35)
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"Grau do polinomio: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [28 x i8] c"Coeficientes do polinomio: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [33 x i8] c"Grau do polinomio muito elevado!\00"
@.str.5 = [22 x i8] c"\0AIntervalo Desejado: \00"
@.str.6 = [6 x i8] c"%f %f\00"
@.str.7 = [27 x i8] c"\0AA raiz no intervalo e: %f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [15 x float]
%3 = alloca float
%4 = alloca float
%5 = bitcast i32* %1 to i8*
%6 = bitcast [15 x float]* %2 to i8*
%7 = bitcast float* %3 to i8*
%8 = bitcast float* %4 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = icmp slt i32 %11, 15
br i1 %12, label %13, label %25
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* %1
%16 = icmp slt i32 %15, 0
br i1 %16, label %27, label %17
17: ; preds = %13, %17
%18 = phi i64 [ %21, %17 ], [ 0, %13 ]
%19 = getelementptr inbounds [15 x float], [15 x float]* %2, i64 0, i64 %18
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %19)
%21 = add nuw nsw i64 %18, 1
%22 = load i32, i32* %1
%23 = sext i32 %22 to i64
%24 = icmp slt i64 %18, %23
br i1 %24, label %17, label %27
25: ; preds = %0
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
br label %27
27: ; preds = %17, %13, %25
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), float* %3, float* %4)
%30 = load i32, i32* %1
%31 = getelementptr inbounds [15 x float], [15 x float]* %2, i64 0, i64 0
%32 = load float, float* %3
%33 = load float, float* %4
%34 = call double @calculatePolynomRoot(i32 %30, float* %31, float %32, float %33)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), double %34)
ret i32 0
}