#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 *crear_vector(int);
int fabs(double);
int /*<<< orphan*/ lee_vector(double *, int);
int /*<<< orphan*/ polinomial(double *, double *, int, double *, double *,
                              double *, double *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void init_polinomial() {
  int n;
  double *x, *y, a1, a0, syx, r2;
  printf("\n\t\tREGRESION POR MINIMOS CUADRADOS POLINOMINAL");
  printf("\nDar el valor de puntos: ");
  scanf(" %d", &n);
  x = crear_vector(n);
  y = crear_vector(n);
  printf("\nDar los valores de X \n ");
  lee_vector(x, n);
  printf("\nDar los valores de Y \n ");
  lee_vector(y, n);
  polinomial(x, y, n, &a1, &a0, &syx, &r2);
  printf("\nLa ecuacion es: y= %lf + %lfx", a0, a1);
  printf("\nEl error estandar es: %lf", syx);
  printf("\nEl coeficiente de determinacion es: %lf", fabs(r2) * 100);
}


x86 assembly (clang, -O0):
<init_polinomial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebe(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x4(%rbp),%edi
call   1060 <crear_vector@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <crear_vector@plt>
mov    %rax,-0x18(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1080 <lee_vector@plt>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1080 <lee_vector@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x4(%rbp),%edx
lea    -0x20(%rbp),%rcx
lea    -0x28(%rbp),%r8
lea    -0x30(%rbp),%r9
lea    -0x38(%rbp),%rax
mov    %rax,(%rsp)
call   1030 <polinomial@plt>
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xe6a(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  -0x30(%rbp),%xmm0
lea    0xe76(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x38(%rbp),%xmm0
call   1050 <fabs@plt>
imul   $0x64,%eax,%esi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_polinomial>:
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebf(%rip),%rdi
lea    0x14(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x14(%rsp),%edi
call   1060 <crear_vector@plt>
mov    %rax,%r14
mov    0x14(%rsp),%edi
call   1060 <crear_vector@plt>
mov    %rax,%rbx
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
mov    %r14,%rdi
call   1080 <lee_vector@plt>
lea    0xe99(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
call   1080 <lee_vector@plt>
mov    0x14(%rsp),%edx
lea    0x18(%rsp),%rax
mov    %rax,(%rsp)
lea    0x30(%rsp),%rcx
lea    0x28(%rsp),%r8
lea    0x20(%rsp),%r9
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <polinomial@plt>
movsd  0x28(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
lea    0xe65(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  0x20(%rsp),%xmm0
lea    0xe70(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x18(%rsp),%xmm0
call   1050 <fabs@plt>
imul   $0x64,%eax,%esi
lea    0xe6f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [47 x i8] c"\0A\09\09REGRESION POR MINIMOS CUADRADOS POLINOMINAL\00"
@.str.1 = [26 x i8] c"\0ADar el valor de puntos: \00"
@.str.2 = [4 x i8] c" %d\00"
@.str.3 = [25 x i8] c"\0ADar los valores de X \0A \00"
@.str.4 = [25 x i8] c"\0ADar los valores de Y \0A \00"
@.str.5 = [31 x i8] c"\0ALa ecuacion es: y= %lf + %lfx\00"
@.str.6 = [27 x i8] c"\0AEl error estandar es: %lf\00"
@.str.7 = [41 x i8] c"\0AEl coeficiente de determinacion es: %lf\00"
define void @init_polinomial() {
%1 = alloca i32
%2 = alloca double*
%3 = alloca double*
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = call double* @crear_vector(i32 %11)
store double* %12, double** %2
%13 = load i32, i32* %1
%14 = call double* @crear_vector(i32 %13)
store double* %14, double** %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%16 = load double*, double** %2
%17 = load i32, i32* %1
%18 = call i32 @lee_vector(double* %16, i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%20 = load double*, double** %3
%21 = load i32, i32* %1
%22 = call i32 @lee_vector(double* %20, i32 %21)
%23 = load double*, double** %2
%24 = load double*, double** %3
%25 = load i32, i32* %1
%26 = call i32 @polinomial(double* %23, double* %24, i32 %25, double* %4, double* %5, double* %6, double* %7)
%27 = load double, double* %5
%28 = load double, double* %4
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), double %27, double %28)
%30 = load double, double* %6
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), double %30)
%32 = load double, double* %7
%33 = call i32 @fabs(double %32)
%34 = mul nsw i32 %33, 100
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i32 %34)
ret void
}

LLVM IR (-O2):
@.str = [47 x i8] c"\0A\09\09REGRESION POR MINIMOS CUADRADOS POLINOMINAL\00"
@.str.1 = [26 x i8] c"\0ADar el valor de puntos: \00"
@.str.2 = [4 x i8] c" %d\00"
@.str.3 = [25 x i8] c"\0ADar los valores de X \0A \00"
@.str.4 = [25 x i8] c"\0ADar los valores de Y \0A \00"
@.str.5 = [31 x i8] c"\0ALa ecuacion es: y= %lf + %lfx\00"
@.str.6 = [27 x i8] c"\0AEl error estandar es: %lf\00"
@.str.7 = [41 x i8] c"\0AEl coeficiente de determinacion es: %lf\00"
define void @init_polinomial() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = bitcast i32* %1 to i8*
%7 = bitcast double* %2 to i8*
%8 = bitcast double* %3 to i8*
%9 = bitcast double* %4 to i8*
%10 = bitcast double* %5 to i8*
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%14 = load i32, i32* %1
%15 = call double* @crear_vector(i32 %14)
%16 = load i32, i32* %1
%17 = call double* @crear_vector(i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%19 = load i32, i32* %1
%20 = call i32 @lee_vector(double* %15, i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%22 = load i32, i32* %1
%23 = call i32 @lee_vector(double* %17, i32 %22)
%24 = load i32, i32* %1
%25 = call i32 @polinomial(double* %15, double* %17, i32 %24, double* %2, double* %3, double* %4, double* %5)
%26 = load double, double* %3
%27 = load double, double* %2
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), double %26, double %27)
%29 = load double, double* %4
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), double %29)
%31 = load double, double* %5
%32 = call i32 @fabs(double %31)
%33 = mul nsw i32 %32, 100
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i32 %33)
ret void
}