#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 /*<<< orphan*/ destruye_vector(double *);
double fabs(double);
int /*<<< orphan*/ lee_vector(double *, int);
int /*<<< orphan*/ lineal(double *, double *, int, double *, double *, double *,
                          double *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void init_lineal() {
  double *X, *Y, a1, a0, syx, r2;
  int n;
  printf("Regresion Lineal\n");
  printf("Introduce el numero de puntos: ");
  scanf("%d", &n);
  X = crear_vector(n);
  Y = crear_vector(n);
  printf("\n Introduce X[i]: \n");
  lee_vector(X, n);
  printf("\n INTRODUCE Y[i]: \n");
  lee_vector(Y, n);
  lineal(X, Y, n, &a1, &a0, &syx, &r2);
  printf("\n Error: %lf", syx);
  printf("\n Coeficiente de determinacion: %lf", fabs(r2));
  destruye_vector(X);
  destruye_vector(Y);
}


x86 assembly (clang, -O0):
<init_lineal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb7(%rip),%rdi
lea    -0x34(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x34(%rbp),%edi
call   1060 <crear_vector@plt>
mov    %rax,-0x8(%rbp)
mov    -0x34(%rbp),%edi
call   1060 <crear_vector@plt>
mov    %rax,-0x10(%rbp)
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1080 <lee_vector@plt>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1080 <lee_vector@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x34(%rbp),%edx
lea    -0x18(%rbp),%rcx
lea    -0x20(%rbp),%r8
lea    -0x28(%rbp),%r9
lea    -0x30(%rbp),%rax
mov    %rax,(%rsp)
call   1050 <lineal@plt>
movsd  -0x28(%rbp),%xmm0
lea    0xe5d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
movaps 0xddd(%rip),%xmm1
pand   %xmm1,%xmm0
lea    0xe4c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <destruye_vector@plt>
mov    -0x10(%rbp),%rdi
call   1040 <destruye_vector@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_lineal>:
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0xee6(%rip),%rdi
call   1030 <puts@plt>
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe98(%rip),%rdi
lea    0x14(%rsp),%rsi
call   1080 <scanf@plt>
mov    0x14(%rsp),%edi
call   1070 <crear_vector@plt>
mov    %rax,%r14
mov    0x14(%rsp),%edi
call   1070 <crear_vector@plt>
mov    %rax,%rbx
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
mov    0x14(%rsp),%esi
mov    %r14,%rdi
call   1090 <lee_vector@plt>
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
call   1090 <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   1060 <lineal@plt>
movsd  0x20(%rsp),%xmm0
lea    0xe15(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x18(%rsp),%xmm0
andps  0xdce(%rip),%xmm0
lea    0xe07(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r14,%rdi
call   1050 <destruye_vector@plt>
mov    %rbx,%rdi
call   1050 <destruye_vector@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Regresion Lineal\0A\00"
@.str.1 = [32 x i8] c"Introduce el numero de puntos: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [20 x i8] c"\0A Introduce X[i]: \0A\00"
@.str.4 = [20 x i8] c"\0A INTRODUCE Y[i]: \0A\00"
@.str.5 = [13 x i8] c"\0A Error: %lf\00"
@.str.6 = [36 x i8] c"\0A Coeficiente de determinacion: %lf\00"
define void @init_lineal() {
%1 = alloca double*
%2 = alloca double*
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%11 = load i32, i32* %7
%12 = call double* @crear_vector(i32 %11)
store double* %12, double** %1
%13 = load i32, i32* %7
%14 = call double* @crear_vector(i32 %13)
store double* %14, double** %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%16 = load double*, double** %1
%17 = load i32, i32* %7
%18 = call i32 @lee_vector(double* %16, i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%20 = load double*, double** %2
%21 = load i32, i32* %7
%22 = call i32 @lee_vector(double* %20, i32 %21)
%23 = load double*, double** %1
%24 = load double*, double** %2
%25 = load i32, i32* %7
%26 = call i32 @lineal(double* %23, double* %24, i32 %25, double* %3, double* %4, double* %5, double* %6)
%27 = load double, double* %5
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), double %27)
%29 = load double, double* %6
%30 = call double @llvm.fabs.f64(double %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), double %30)
%32 = load double*, double** %1
%33 = call i32 @destruye_vector(double* %32)
%34 = load double*, double** %2
%35 = call i32 @destruye_vector(double* %34)
ret void
}

LLVM IR (-O2):
@.str.1 = [32 x i8] c"Introduce el numero de puntos: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.5 = [13 x i8] c"\0A Error: %lf\00"
@.str.6 = [36 x i8] c"\0A Coeficiente de determinacion: %lf\00"
@str = [17 x i8] c"Regresion Lineal\00"
@str.7 = [19 x i8] c"\0A Introduce X[i]: \00"
@str.8 = [19 x i8] c"\0A INTRODUCE Y[i]: \00"
define void @init_lineal() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = bitcast double* %1 to i8*
%7 = bitcast double* %2 to i8*
%8 = bitcast double* %3 to i8*
%9 = bitcast double* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%14 = load i32, i32* %5
%15 = call double* @crear_vector(i32 %14)
%16 = load i32, i32* %5
%17 = call double* @crear_vector(i32 %16)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0))
%19 = load i32, i32* %5
%20 = call i32 @lee_vector(double* %15, i32 %19)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.8, i64 0, i64 0))
%22 = load i32, i32* %5
%23 = call i32 @lee_vector(double* %17, i32 %22)
%24 = load i32, i32* %5
%25 = call i32 @lineal(double* %15, double* %17, i32 %24, double* %1, double* %2, double* %3, double* %4)
%26 = load double, double* %3
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), double %26)
%28 = load double, double* %4
%29 = call double @llvm.fabs.f64(double %28)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), double %29)
%31 = call i32 @destruye_vector(double* %15)
%32 = call i32 @destruye_vector(double* %17)
ret void
}