#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 */
int /*<<< orphan*/ printf(char *, float);
double promedio(float *, int);
int main() {
  float X[5] = {1, 2, 3, 4, 5};
  float Y[5] = {1, 2, 3, 4, 5};
  float X2[5] = {0, 0, 0, 0, 0};
  float XY[5] = {0, 0, 0, 0, 0};
  char i;
  for (i = 0; i < 5; i++) {
    X2[i] = X[i] * X[i];
    XY[i] = X[i] * Y[i];
  }
  float prom_X = promedio(X, 5);
  float prom_Y = promedio(Y, 5);
  float prom_X2 = promedio(X2, 5);
  float prom_XY = promedio(XY, 5);
  printf("Promedio de X:  %f\n", promedio(X, 5));
  printf("Promedio de Y:  %f\n", promedio(Y, 5));
  printf("Promedio de X2: %f\n", promedio(X2, 5));
  printf("Promedio de XY: %f\n", promedio(XY, 5));
  float A =
      ((prom_XY * 1) - (prom_Y * prom_X)) / ((prom_X2 * 1) - (prom_X * prom_X));
  float B = ((prom_X2 * prom_Y) - (prom_X * prom_XY)) /
            ((prom_X2 * 1) - (prom_X * prom_X));
  ;
  printf("La pendiente es : %f\n", A);
  printf("La ordenada de origen es : %f\n", B);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb4(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb2(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xeb8(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xeb5(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xeb3(%rip),%eax
mov    %eax,-0x30(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
movb   $0x0,-0x81(%rbp)
movsbl -0x81(%rbp),%eax
cmp    $0x5,%eax
jge    121e <main+0xee>
movsbq -0x81(%rbp),%rax
ff
movss  -0x20(%rbp,%rax,4),%xmm0
movsbq -0x81(%rbp),%rax
ff
mulss  -0x20(%rbp,%rax,4),%xmm0
movsbq -0x81(%rbp),%rax
ff
movss  %xmm0,-0x60(%rbp,%rax,4)
movsbq -0x81(%rbp),%rax
ff
movss  -0x20(%rbp,%rax,4),%xmm0
movsbq -0x81(%rbp),%rax
ff
mulss  -0x40(%rbp,%rax,4),%xmm0
movsbq -0x81(%rbp),%rax
ff
movss  %xmm0,-0x80(%rbp,%rax,4)
mov    -0x81(%rbp),%al
add    $0x1,%al
mov    %al,-0x81(%rbp)
jmp    11a7 <main+0x77>
lea    -0x20(%rbp),%rdi
mov    $0x5,%esi
call   1050 <promedio@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x88(%rbp)
ff
lea    -0x40(%rbp),%rdi
mov    $0x5,%esi
call   1050 <promedio@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8c(%rbp)
ff
lea    -0x60(%rbp),%rdi
mov    $0x5,%esi
call   1050 <promedio@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x90(%rbp)
ff
lea    -0x80(%rbp),%rdi
mov    $0x5,%esi
call   1050 <promedio@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x94(%rbp)
ff
lea    -0x20(%rbp),%rdi
mov    $0x5,%esi
call   1050 <promedio@plt>
cvtsd2ss %xmm0,%xmm0
lea    0xd95(%rip),%rdi
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    $0x5,%esi
call   1050 <promedio@plt>
cvtsd2ss %xmm0,%xmm0
lea    0xd8b(%rip),%rdi
call   1030 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    $0x5,%esi
call   1050 <promedio@plt>
cvtsd2ss %xmm0,%xmm0
lea    0xd81(%rip),%rdi
call   1030 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    $0x5,%esi
call   1050 <promedio@plt>
cvtsd2ss %xmm0,%xmm0
lea    0xd77(%rip),%rdi
call   1030 <printf@plt>
movss  -0x94(%rbp),%xmm0
ff
movss  -0x8c(%rbp),%xmm1
ff
mulss  -0x88(%rbp),%xmm1
ff
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
addss  %xmm1,%xmm0
movss  -0x90(%rbp),%xmm1
ff
movss  -0x88(%rbp),%xmm2
ff
mulss  -0x88(%rbp),%xmm2
ff
movd   %xmm2,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm2
addss  %xmm2,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x98(%rbp)
ff
movss  -0x90(%rbp),%xmm0
ff
movss  -0x8c(%rbp),%xmm2
ff
movss  -0x88(%rbp),%xmm1
ff
mulss  -0x94(%rbp),%xmm1
ff
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x90(%rbp),%xmm1
ff
movss  -0x88(%rbp),%xmm2
ff
mulss  -0x88(%rbp),%xmm2
ff
movd   %xmm2,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm2
addss  %xmm2,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x9c(%rbp)
ff
movss  -0x98(%rbp),%xmm0
ff
lea    0xcaf(%rip),%rdi
call   1030 <printf@plt>
movss  -0x9c(%rbp),%xmm0
ff
lea    0xcb1(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    0xeec(%rip),%eax
mov    %eax,0x80(%rsp)
movaps 0xece(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
mov    %eax,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps 0xea9(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x41c80000,0x40(%rsp)
41
movl   $0x41c80000,0x20(%rsp)
41
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1040 <promedio@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
lea    0x50(%rsp),%r12
mov    %r12,%rdi
mov    $0x5,%esi
call   1040 <promedio@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
lea    0x30(%rsp),%r15
mov    %r15,%rdi
mov    $0x5,%esi
call   1040 <promedio@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rsp)
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x5,%esi
call   1040 <promedio@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
mov    %rbx,%rdi
mov    $0x5,%esi
call   1040 <promedio@plt>
cvtsd2ss %xmm0,%xmm0
lea    0xe2c(%rip),%rdi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    $0x5,%esi
call   1040 <promedio@plt>
cvtsd2ss %xmm0,%xmm0
lea    0xe23(%rip),%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    $0x5,%esi
call   1040 <promedio@plt>
cvtsd2ss %xmm0,%xmm0
lea    0xe1a(%rip),%rdi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x5,%esi
call   1040 <promedio@plt>
cvtsd2ss %xmm0,%xmm0
lea    0xe11(%rip),%rdi
call   1030 <printf@plt>
movss  0xc(%rsp),%xmm3
movaps %xmm3,%xmm1
movss  0x8(%rsp),%xmm4
mulss  %xmm4,%xmm1
movss  0x4(%rsp),%xmm6
movaps %xmm6,%xmm0
subss  %xmm1,%xmm0
movaps %xmm3,%xmm1
mulss  %xmm3,%xmm1
movss  (%rsp),%xmm5
movaps %xmm5,%xmm2
subss  %xmm1,%xmm2
divss  %xmm2,%xmm0
mulss  %xmm6,%xmm3
movaps %xmm5,%xmm1
mulss  %xmm4,%xmm1
subss  %xmm3,%xmm1
divss  %xmm2,%xmm1
movss  %xmm1,(%rsp)
lea    0xdca(%rip),%rdi
call   1030 <printf@plt>
lea    0xdd4(%rip),%rdi
movss  (%rsp),%xmm0
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.X = [5 x float] [float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00, float 5.000000e+00]
@__const.main.Y = [5 x float] [float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00, float 5.000000e+00]
@.str = [20 x i8] c"Promedio de X: %f\0A\00"
@.str.1 = [20 x i8] c"Promedio de Y: %f\0A\00"
@.str.2 = [20 x i8] c"Promedio de X2: %f\0A\00"
@.str.3 = [20 x i8] c"Promedio de XY: %f\0A\00"
@.str.4 = [22 x i8] c"La pendiente es : %f\0A\00"
@.str.5 = [31 x i8] c"La ordenada de origen es : %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x float]
%3 = alloca [5 x float]
%4 = alloca [5 x float]
%5 = alloca [5 x float]
%6 = alloca i8
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
store i32 0, i32* %1
%13 = bitcast [5 x float]* %2 to i8*
%14 = bitcast [5 x float]* %3 to i8*
%15 = bitcast [5 x float]* %4 to i8*
%16 = bitcast [5 x float]* %5 to i8*
store i8 0, i8* %6
br label %17
17: ; preds = %46, %0
%18 = load i8, i8* %6
%19 = sext i8 %18 to i32
%20 = icmp slt i32 %19, 5
br i1 %20, label %21, label %49
21: ; preds = %17
%22 = load i8, i8* %6
%23 = sext i8 %22 to i64
%24 = getelementptr inbounds [5 x float], [5 x float]* %2, i64 0, i64 %23
%25 = load float, float* %24
%26 = load i8, i8* %6
%27 = sext i8 %26 to i64
%28 = getelementptr inbounds [5 x float], [5 x float]* %2, i64 0, i64 %27
%29 = load float, float* %28
%30 = fmul float %25, %29
%31 = load i8, i8* %6
%32 = sext i8 %31 to i64
%33 = getelementptr inbounds [5 x float], [5 x float]* %4, i64 0, i64 %32
store float %30, float* %33
%34 = load i8, i8* %6
%35 = sext i8 %34 to i64
%36 = getelementptr inbounds [5 x float], [5 x float]* %2, i64 0, i64 %35
%37 = load float, float* %36
%38 = load i8, i8* %6
%39 = sext i8 %38 to i64
%40 = getelementptr inbounds [5 x float], [5 x float]* %3, i64 0, i64 %39
%41 = load float, float* %40
%42 = fmul float %37, %41
%43 = load i8, i8* %6
%44 = sext i8 %43 to i64
%45 = getelementptr inbounds [5 x float], [5 x float]* %5, i64 0, i64 %44
store float %42, float* %45
br label %46
46: ; preds = %21
%47 = load i8, i8* %6
%48 = add i8 %47, 1
store i8 %48, i8* %6
br label %17
49: ; preds = %17
%50 = getelementptr inbounds [5 x float], [5 x float]* %2, i64 0, i64 0
%51 = call double @promedio(float* %50, i32 5)
%52 = fptrunc double %51 to float
store float %52, float* %7
%53 = getelementptr inbounds [5 x float], [5 x float]* %3, i64 0, i64 0
%54 = call double @promedio(float* %53, i32 5)
%55 = fptrunc double %54 to float
store float %55, float* %8
%56 = getelementptr inbounds [5 x float], [5 x float]* %4, i64 0, i64 0
%57 = call double @promedio(float* %56, i32 5)
%58 = fptrunc double %57 to float
store float %58, float* %9
%59 = getelementptr inbounds [5 x float], [5 x float]* %5, i64 0, i64 0
%60 = call double @promedio(float* %59, i32 5)
%61 = fptrunc double %60 to float
store float %61, float* %10
%62 = getelementptr inbounds [5 x float], [5 x float]* %2, i64 0, i64 0
%63 = call double @promedio(float* %62, i32 5)
%64 = fptrunc double %63 to float
%65 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), float %64)
%66 = getelementptr inbounds [5 x float], [5 x float]* %3, i64 0, i64 0
%67 = call double @promedio(float* %66, i32 5)
%68 = fptrunc double %67 to float
%69 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), float %68)
%70 = getelementptr inbounds [5 x float], [5 x float]* %4, i64 0, i64 0
%71 = call double @promedio(float* %70, i32 5)
%72 = fptrunc double %71 to float
%73 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), float %72)
%74 = getelementptr inbounds [5 x float], [5 x float]* %5, i64 0, i64 0
%75 = call double @promedio(float* %74, i32 5)
%76 = fptrunc double %75 to float
%77 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), float %76)
%78 = load float, float* %10
%79 = load float, float* %8
%80 = load float, float* %7
%81 = fmul float %79, %80
%82 = fneg float %81
%83 = call float @llvm.fmuladd.f32(float %78, float 1.000000e+00, float %82)
%84 = load float, float* %9
%85 = load float, float* %7
%86 = load float, float* %7
%87 = fmul float %85, %86
%88 = fneg float %87
%89 = call float @llvm.fmuladd.f32(float %84, float 1.000000e+00, float %88)
%90 = fdiv float %83, %89
store float %90, float* %11
%91 = load float, float* %9
%92 = load float, float* %8
%93 = load float, float* %7
%94 = load float, float* %10
%95 = fmul float %93, %94
%96 = fneg float %95
%97 = call float @llvm.fmuladd.f32(float %91, float %92, float %96)
%98 = load float, float* %9
%99 = load float, float* %7
%100 = load float, float* %7
%101 = fmul float %99, %100
%102 = fneg float %101
%103 = call float @llvm.fmuladd.f32(float %98, float 1.000000e+00, float %102)
%104 = fdiv float %97, %103
store float %104, float* %12
%105 = load float, float* %11
%106 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), float %105)
%107 = load float, float* %12
%108 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), float %107)
ret i32 0
}

LLVM IR (-O2):
@__const.main.Y = [5 x float] [float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00, float 5.000000e+00]
@.str = [20 x i8] c"Promedio de X: %f\0A\00"
@.str.1 = [20 x i8] c"Promedio de Y: %f\0A\00"
@.str.2 = [20 x i8] c"Promedio de X2: %f\0A\00"
@.str.3 = [20 x i8] c"Promedio de XY: %f\0A\00"
@.str.4 = [22 x i8] c"La pendiente es : %f\0A\00"
@.str.5 = [31 x i8] c"La ordenada de origen es : %f\0A\00"
define i32 @main() {
%1 = alloca [5 x float]
%2 = alloca [5 x float]
%3 = alloca [5 x float]
%4 = alloca [5 x float]
%5 = bitcast [5 x float]* %1 to i8*
%6 = bitcast [5 x float]* %2 to i8*
%7 = bitcast [5 x float]* %3 to i8*
%8 = bitcast [5 x float]* %4 to i8*
%9 = getelementptr inbounds [5 x float], [5 x float]* %1, i64 0, i64 0
%10 = getelementptr inbounds [5 x float], [5 x float]* %3, i64 0, i64 0
%11 = getelementptr inbounds [5 x float], [5 x float]* %2, i64 0, i64 0
%12 = getelementptr inbounds [5 x float], [5 x float]* %4, i64 0, i64 0
%13 = bitcast [5 x float]* %3 to <4 x float>*
store <4 x float> <float 1.000000e+00, float 4.000000e+00, float 9.000000e+00, float 1.600000e+01>, <4 x float>* %13
%14 = bitcast [5 x float]* %4 to <4 x float>*
store <4 x float> <float 1.000000e+00, float 4.000000e+00, float 9.000000e+00, float 1.600000e+01>, <4 x float>* %14
%15 = getelementptr inbounds [5 x float], [5 x float]* %3, i64 0, i64 4
store float 2.500000e+01, float* %15
%16 = getelementptr inbounds [5 x float], [5 x float]* %4, i64 0, i64 4
store float 2.500000e+01, float* %16
%17 = call double @promedio(float* %9, i32 5)
%18 = fptrunc double %17 to float
%19 = call double @promedio(float* %11, i32 5)
%20 = fptrunc double %19 to float
%21 = call double @promedio(float* %10, i32 5)
%22 = fptrunc double %21 to float
%23 = call double @promedio(float* %12, i32 5)
%24 = fptrunc double %23 to float
%25 = call double @promedio(float* %9, i32 5)
%26 = fptrunc double %25 to float
%27 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), float %26)
%28 = call double @promedio(float* %11, i32 5)
%29 = fptrunc double %28 to float
%30 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), float %29)
%31 = call double @promedio(float* %10, i32 5)
%32 = fptrunc double %31 to float
%33 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), float %32)
%34 = call double @promedio(float* %12, i32 5)
%35 = fptrunc double %34 to float
%36 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), float %35)
%37 = fmul float %18, %20
%38 = fsub float %24, %37
%39 = fmul float %18, %18
%40 = fsub float %22, %39
%41 = fdiv float %38, %40
%42 = fneg float %18
%43 = fmul float %42, %24
%44 = call float @llvm.fmuladd.f32(float %22, float %20, float %43)
%45 = fdiv float %44, %40
%46 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), float %41)
%47 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), float %45)
ret i32 0
}