#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 */
typedef int /*<<< orphan*/ x_values;
typedef int /*<<< orphan*/ actuals_array;

/* Variables and functions */
float *lin_reg(int *, int, int *, int);
float mean(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int sum(int *, int);
int main() {
  int actuals_array[10] = {1, 4, 9, 16, 25, 36, 49, 64, 81, 100};
  int errors_array[10];
  int x_values[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  int actuals_sum;
  float actuals_mean;
  int x_values_size = sizeof(x_values) / sizeof(x_values[0]);
  int actuals_array_size = sizeof(actuals_array) / sizeof(actuals_array[0]);
  float *lin_reg_coeffs;
  if (x_values_size == actuals_array_size) {
    printf("The actual size of the array is %d\n", actuals_array_size);
    actuals_sum = sum(actuals_array, actuals_array_size);
    printf("The sum of the array values is %d\n", actuals_sum);
    actuals_mean = mean(actuals_array, actuals_array_size);
    printf("The mean of the array values is %.6f\n", actuals_mean);
    lin_reg_coeffs = lin_reg(x_values, actuals_array_size, actuals_array,
                             actuals_array_size);
    printf("The slope of the regression line is %.6f\n", lin_reg_coeffs[0]);
    printf("The intercept of the regression line is %.6f\n", lin_reg_coeffs[1]);
    return 0;
  } else {
    printf("The two arrays provided are not the same size!");
    return 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe93(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
lea    -0x90(%rbp),%rdi
lea    0xeab(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
movl   $0xa,-0x9c(%rbp)
movl   $0xa,-0xa0(%rbp)
mov    -0x9c(%rbp),%eax
cmp    -0xa0(%rbp),%eax
jne    128d <main+0x13d>
mov    -0xa0(%rbp),%esi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    -0xa0(%rbp),%esi
call   1060 <sum@plt>
mov    %eax,-0x94(%rbp)
mov    -0x94(%rbp),%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    -0xa0(%rbp),%esi
call   1070 <mean@plt>
movss  %xmm0,-0x98(%rbp)
ff
movss  -0x98(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xe83(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    -0xa0(%rbp),%esi
lea    -0x30(%rbp),%rdx
mov    -0xa0(%rbp),%ecx
call   1040 <lin_reg@plt>
mov    %rax,-0xa8(%rbp)
mov    -0xa8(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe69(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0xa8(%rbp),%rax
movss  0x4(%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe75(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12a2 <main+0x152>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
mov    0xed4(%rip),%rax
mov    %rax,0x50(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe9c(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
mov    0xee0(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea8(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xec5(%rip),%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <sum@plt>
lea    0xec4(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1060 <mean@plt>
cvtss2sd %xmm0,%xmm0
lea    0xec6(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    %rsp,%rdi
mov    $0xa,%esi
mov    %rbx,%rdx
mov    $0xa,%ecx
call   1040 <lin_reg@plt>
mov    %rax,%rbx
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xebe(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  0x4(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xed1(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.actuals_array = [10 x i32] [i32 1, i32 4, i32 9, i32 16, i32 25, i32 36, i32 49, i32 64, i32 81, i32 100]
@__const.main.x_values = [10 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10]
@.str = [36 x i8] c"The actual size of the array is %d\0A\00"
@.str.1 = [35 x i8] c"The sum of the array values is %d\0A\00"
@.str.2 = [38 x i8] c"The mean of the array values is %.6f\0A\00"
@.str.3 = [42 x i8] c"The slope of the regression line is %.6f\0A\00"
@.str.4 = [46 x i8] c"The intercept of the regression line is %.6f\0A\00"
@.str.5 = [47 x i8] c"The two arrays provided are not the same size!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca [10 x i32]
%4 = alloca [10 x i32]
%5 = alloca i32
%6 = alloca float
%7 = alloca i32
%8 = alloca i32
%9 = alloca float*
store i32 0, i32* %1
%10 = bitcast [10 x i32]* %2 to i8*
%11 = bitcast [10 x i32]* %4 to i8*
store i32 10, i32* %7
store i32 10, i32* %8
%12 = load i32, i32* %7
%13 = load i32, i32* %8
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %44
15: ; preds = %0
%16 = load i32, i32* %8
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%19 = load i32, i32* %8
%20 = call i32 @sum(i32* %18, i32 %19)
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%24 = load i32, i32* %8
%25 = call float @mean(i32* %23, i32 %24)
store float %25, float* %6
%26 = load float, float* %6
%27 = fpext float %26 to double
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), double %27)
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%30 = load i32, i32* %8
%31 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%32 = load i32, i32* %8
%33 = call float* @lin_reg(i32* %29, i32 %30, i32* %31, i32 %32)
store float* %33, float** %9
%34 = load float*, float** %9
%35 = getelementptr inbounds float, float* %34, i64 0
%36 = load float, float* %35
%37 = fpext float %36 to double
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), double %37)
%39 = load float*, float** %9
%40 = getelementptr inbounds float, float* %39, i64 1
%41 = load float, float* %40
%42 = fpext float %41 to double
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), double %42)
store i32 0, i32* %1
br label %46
44: ; preds = %0
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %1
br label %46
46: ; preds = %44, %15
%47 = load i32, i32* %1
ret i32 %47
}

LLVM IR (-O2):
@__const.main.actuals_array = [10 x i32] [i32 1, i32 4, i32 9, i32 16, i32 25, i32 36, i32 49, i32 64, i32 81, i32 100]
@__const.main.x_values = [10 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10]
@.str = [36 x i8] c"The actual size of the array is %d\0A\00"
@.str.1 = [35 x i8] c"The sum of the array values is %d\0A\00"
@.str.2 = [38 x i8] c"The mean of the array values is %.6f\0A\00"
@.str.3 = [42 x i8] c"The slope of the regression line is %.6f\0A\00"
@.str.4 = [46 x i8] c"The intercept of the regression line is %.6f\0A\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = alloca [10 x i32]
%3 = bitcast [10 x i32]* %1 to i8*
%4 = bitcast [10 x i32]* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 10)
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%7 = call i32 @sum(i32* %6, i32 10)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = call float @mean(i32* %6, i32 10)
%10 = fpext float %9 to double
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), double %10)
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%13 = call float* @lin_reg(i32* %12, i32 10, i32* %6, i32 10)
%14 = load float, float* %13
%15 = fpext float %14 to double
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), double %15)
%17 = getelementptr inbounds float, float* %13, i64 1
%18 = load float, float* %17
%19 = fpext float %18 to double
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), double %19)
ret i32 0
}