#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 power(float, int);
float valor_polinomio(float a[], float x, int n) {
  float valor;
  int i;
  valor = a[1];
  for (i = 2; i <= n + 1; i++) {
    valor += a[i] * (power(x, (i - 1)));
  }
  return valor;
}


x86 assembly (clang, -O0):
<valor_polinomio>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jg     1194 <valor_polinomio+0x84>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0xc(%rbp),%xmm0
mov    -0x18(%rbp),%edi
sub    $0x1,%edi
call   1030 <power@plt>
movaps %xmm0,%xmm2
movss  -0x1c(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1139 <valor_polinomio+0x29>
movss  -0x14(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valor_polinomio>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movaps %xmm0,%xmm1
movss  0x4(%rdi),%xmm0
test   %esi,%esi
jle    1188 <valor_polinomio+0x78>
mov    %esi,%r15d
mov    %rdi,%r14
add    $0x2,%r15d
mov    $0x2,%ebx
movss  %xmm1,0x8(%rsp)
nopw   0x0(%rax,%rax,1)
movss  %xmm0,0x4(%rsp)
movss  (%r14,%rbx,4),%xmm0
movss  %xmm0,0xc(%rsp)
lea    -0x1(%rbx),%edi
movaps %xmm1,%xmm0
call   1030 <power@plt>
mulss  0xc(%rsp),%xmm0
movss  0x4(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
movss  0x8(%rsp),%xmm1
movss  0x4(%rsp),%xmm0
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <valor_polinomio+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define float @valor_polinomio(float* %0, float %1, i32 %2) {
%4 = alloca float*
%5 = alloca float
%6 = alloca i32
%7 = alloca float
%8 = alloca i32
store float* %0, float** %4
store float %1, float* %5
store i32 %2, i32* %6
%9 = load float*, float** %4
%10 = getelementptr inbounds float, float* %9, i64 1
%11 = load float, float* %10
store float %11, float* %7
store i32 2, i32* %8
br label %12
12: ; preds = %29, %3
%13 = load i32, i32* %8
%14 = load i32, i32* %6
%15 = add nsw i32 %14, 1
%16 = icmp sle i32 %13, %15
br i1 %16, label %17, label %32
17: ; preds = %12
%18 = load float*, float** %4
%19 = load i32, i32* %8
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds float, float* %18, i64 %20
%22 = load float, float* %21
%23 = load float, float* %5
%24 = load i32, i32* %8
%25 = sub nsw i32 %24, 1
%26 = call float @power(float %23, i32 %25)
%27 = load float, float* %7
%28 = call float @llvm.fmuladd.f32(float %22, float %26, float %27)
store float %28, float* %7
br label %29
29: ; preds = %17
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
br label %12
32: ; preds = %12
%33 = load float, float* %7
ret float %33
}

LLVM IR (-O2):
define float @valor_polinomio(float* nocapture %0, float %1, i32 %2) {
%4 = getelementptr inbounds float, float* %0, i64 1
%5 = load float, float* %4
%6 = icmp slt i32 %2, 1
br i1 %6, label %21, label %7
7: ; preds = %3
%8 = add nuw i32 %2, 2
%9 = zext i32 %8 to i64
br label %10
10: ; preds = %7, %10
%11 = phi i64 [ 2, %7 ], [ %19, %10 ]
%12 = phi float [ %5, %7 ], [ %18, %10 ]
%13 = getelementptr inbounds float, float* %0, i64 %11
%14 = load float, float* %13
%15 = trunc i64 %11 to i32
%16 = add i32 %15, -1
%17 = tail call float @power(float %1, i32 %16)
%18 = tail call float @llvm.fmuladd.f32(float %14, float %17, float %12)
%19 = add nuw nsw i64 %11, 1
%20 = icmp eq i64 %19, %9
br i1 %20, label %21, label %10
21: ; preds = %10, %3
%22 = phi float [ %5, %3 ], [ %18, %10 ]
ret float %22
}