#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 dAccumulate(double *, int);
double dInnerProduct(double *, double *, int);
int /*<<< orphan*/ printf(char *, double, ...);
main() {
  double dXArray[7] = {1, 2, 3, 4, 5, 6, 7};
  double dYArray[7] = {167, 173, 186, 187, 201, 202, 210};
  double dX = dAccumulate(dXArray, 7);
  double dY = dAccumulate(dYArray, 7);
  double dProductXY = dInnerProduct(dXArray, dYArray, 7);
  double dProductXX = dInnerProduct(dXArray, dXArray, 7);
  double dSlope = (7 * dProductXY - dX * dY) / (7 * dProductXX - dX * dX);
  printf("dSlope=%lf dProductXY=%lf dProductXX=%lf dX=%lf dY=%lf\n", dSlope,
         dProductXY, dProductXX, dX, dY);
  double dAX = dX / 7;
  double dAY = dY / 7;
  double dIntercept = dAY - (dSlope * dAX);
  printf("dIntercept=%lf\n", dIntercept);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
lea    -0x40(%rbp),%rdi
lea    0xeba(%rip),%rsi
mov    $0x38,%edx
call   1050 <memcpy@plt>
lea    -0x80(%rbp),%rdi
lea    0xee5(%rip),%rsi
mov    $0x38,%edx
call   1050 <memcpy@plt>
lea    -0x40(%rbp),%rdi
mov    $0x7,%esi
call   1030 <dAccumulate@plt>
movsd  %xmm0,-0x88(%rbp)
ff
lea    -0x80(%rbp),%rdi
mov    $0x7,%esi
call   1030 <dAccumulate@plt>
movsd  %xmm0,-0x90(%rbp)
ff
lea    -0x40(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x7,%edx
call   1060 <dInnerProduct@plt>
movsd  %xmm0,-0x98(%rbp)
ff
lea    -0x40(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x7,%edx
call   1060 <dInnerProduct@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
movsd  -0x88(%rbp),%xmm1
ff
mulsd  -0x90(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xdf4(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0xa0(%rbp),%xmm1
ff
movsd  -0x88(%rbp),%xmm2
ff
mulsd  -0x88(%rbp),%xmm2
ff
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
movsd  0xdb5(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0xa8(%rbp),%xmm0
ff
movsd  -0x98(%rbp),%xmm1
ff
movsd  -0xa0(%rbp),%xmm2
ff
movsd  -0x88(%rbp),%xmm3
ff
movsd  -0x90(%rbp),%xmm4
ff
lea    0xdfa(%rip),%rdi
mov    $0x5,%al
call   1040 <printf@plt>
movsd  -0x88(%rbp),%xmm0
ff
movsd  0xd5b(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
movsd  0xd3f(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0xb8(%rbp),%xmm1
ff
movsd  -0xa8(%rbp),%xmm0
ff
movsd  -0xb0(%rbp),%xmm2
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0xc0(%rbp),%xmm0
ff
lea    0xda5(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xb8,%rsp
mov    0xf0f(%rip),%rax
mov    %rax,0xb0(%rsp)
movaps 0xef0(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xed1(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xeb2(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
mov    0xf13(%rip),%rax
mov    %rax,0x70(%rsp)
movaps 0xef7(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xedb(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movapd 0xebe(%rip),%xmm0
movapd %xmm0,0x40(%rsp)
lea    0x80(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x7,%esi
call   1030 <dAccumulate@plt>
movapd %xmm0,0x10(%rsp)
lea    0x40(%rsp),%r14
mov    %r14,%rdi
mov    $0x7,%esi
call   1030 <dAccumulate@plt>
movapd %xmm0,(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
call   1050 <dInnerProduct@plt>
movapd %xmm0,0x30(%rsp)
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    $0x7,%edx
call   1050 <dInnerProduct@plt>
movapd %xmm0,%xmm2
movapd (%rsp),%xmm4
movapd %xmm4,%xmm6
movapd 0x10(%rsp),%xmm3
unpcklpd %xmm3,%xmm6
movapd %xmm3,%xmm5
unpcklpd %xmm3,%xmm5
movapd 0x30(%rsp),%xmm1
movapd %xmm1,%xmm0
unpcklpd %xmm2,%xmm0
mulpd  0xdcb(%rip),%xmm0
mulpd  %xmm6,%xmm5
subpd  %xmm5,%xmm0
movapd %xmm0,%xmm5
unpckhpd %xmm0,%xmm5
divsd  %xmm5,%xmm0
movapd %xmm0,0x20(%rsp)
lea    0xe42(%rip),%rdi
mov    $0x5,%al
call   1040 <printf@plt>
movsd  0xdab(%rip),%xmm0
movapd 0x10(%rsp),%xmm2
divsd  %xmm0,%xmm2
movapd (%rsp),%xmm1
divsd  %xmm0,%xmm1
mulsd  0x20(%rsp),%xmm2
subsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
lea    0xe43(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.dXArray = [7 x double] [double 1.000000e+00, double 2.000000e+00, double 3.000000e+00, double 4.000000e+00, double 5.000000e+00, double 6.000000e+00, double 7.000000e+00]
@__const.main.dYArray = [7 x double] [double 1.670000e+02, double 1.730000e+02, double 1.860000e+02, double 1.870000e+02, double 2.010000e+02, double 2.020000e+02, double 2.100000e+02]
@.str = [56 x i8] c"dSlope=%lf dProductXY=%lf dProductXX=%lf dX=%lf dY=%lf\0A\00"
@.str.1 = [16 x i8] c"dIntercept=%lf\0A\00"
define i32 @main() {
%1 = alloca [7 x double]
%2 = alloca [7 x double]
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = bitcast [7 x double]* %1 to i8*
%12 = bitcast [7 x double]* %2 to i8*
%13 = getelementptr inbounds [7 x double], [7 x double]* %1, i64 0, i64 0
%14 = call double @dAccumulate(double* %13, i32 7)
store double %14, double* %3
%15 = getelementptr inbounds [7 x double], [7 x double]* %2, i64 0, i64 0
%16 = call double @dAccumulate(double* %15, i32 7)
store double %16, double* %4
%17 = getelementptr inbounds [7 x double], [7 x double]* %1, i64 0, i64 0
%18 = getelementptr inbounds [7 x double], [7 x double]* %2, i64 0, i64 0
%19 = call double @dInnerProduct(double* %17, double* %18, i32 7)
store double %19, double* %5
%20 = getelementptr inbounds [7 x double], [7 x double]* %1, i64 0, i64 0
%21 = getelementptr inbounds [7 x double], [7 x double]* %1, i64 0, i64 0
%22 = call double @dInnerProduct(double* %20, double* %21, i32 7)
store double %22, double* %6
%23 = load double, double* %5
%24 = load double, double* %3
%25 = load double, double* %4
%26 = fmul double %24, %25
%27 = fneg double %26
%28 = call double @llvm.fmuladd.f64(double 7.000000e+00, double %23, double %27)
%29 = load double, double* %6
%30 = load double, double* %3
%31 = load double, double* %3
%32 = fmul double %30, %31
%33 = fneg double %32
%34 = call double @llvm.fmuladd.f64(double 7.000000e+00, double %29, double %33)
%35 = fdiv double %28, %34
store double %35, double* %7
%36 = load double, double* %7
%37 = load double, double* %5
%38 = load double, double* %6
%39 = load double, double* %3
%40 = load double, double* %4
%41 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), double %36, double %37, double %38, double %39, double %40)
%42 = load double, double* %3
%43 = fdiv double %42, 7.000000e+00
store double %43, double* %8
%44 = load double, double* %4
%45 = fdiv double %44, 7.000000e+00
store double %45, double* %9
%46 = load double, double* %9
%47 = load double, double* %7
%48 = load double, double* %8
%49 = fneg double %47
%50 = call double @llvm.fmuladd.f64(double %49, double %48, double %46)
store double %50, double* %10
%51 = load double, double* %10
%52 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double %51)
ret i32 0
}

LLVM IR (-O2):
@__const.main.dXArray = [7 x double] [double 1.000000e+00, double 2.000000e+00, double 3.000000e+00, double 4.000000e+00, double 5.000000e+00, double 6.000000e+00, double 7.000000e+00]
@__const.main.dYArray = [7 x double] [double 1.670000e+02, double 1.730000e+02, double 1.860000e+02, double 1.870000e+02, double 2.010000e+02, double 2.020000e+02, double 2.100000e+02]
@.str = [56 x i8] c"dSlope=%lf dProductXY=%lf dProductXX=%lf dX=%lf dY=%lf\0A\00"
@.str.1 = [16 x i8] c"dIntercept=%lf\0A\00"
define i32 @main() {
%1 = alloca [7 x double]
%2 = alloca [7 x double]
%3 = bitcast [7 x double]* %1 to i8*
%4 = bitcast [7 x double]* %2 to i8*
%5 = getelementptr inbounds [7 x double], [7 x double]* %1, i64 0, i64 0
%6 = call double @dAccumulate(double* %5, i32 7)
%7 = getelementptr inbounds [7 x double], [7 x double]* %2, i64 0, i64 0
%8 = call double @dAccumulate(double* %7, i32 7)
%9 = call double @dInnerProduct(double* %5, double* %7, i32 7)
%10 = call double @dInnerProduct(double* %5, double* %5, i32 7)
%11 = fneg double %6
%12 = insertelement <2 x double> poison, double %8, i64 0
%13 = insertelement <2 x double> %12, double %6, i64 1
%14 = insertelement <2 x double> poison, double %11, i64 0
%15 = shufflevector <2 x double> %14, <2 x double> poison, <2 x i32> zeroinitializer
%16 = fmul <2 x double> %13, %15
%17 = insertelement <2 x double> poison, double %9, i64 0
%18 = insertelement <2 x double> %17, double %10, i64 1
%19 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %18, <2 x double> <double 7.000000e+00, double 7.000000e+00>, <2 x double> %16)
%20 = extractelement <2 x double> %19, i64 0
%21 = extractelement <2 x double> %19, i64 1
%22 = fdiv double %20, %21
%23 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), double %22, double %9, double %10, double %6, double %8)
%24 = fdiv double %6, 7.000000e+00
%25 = fdiv double %8, 7.000000e+00
%26 = fneg double %22
%27 = call double @llvm.fmuladd.f64(double %26, double %24, double %25)
%28 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double %27)
ret i32 0
}