#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  double *x, *y;
  double SUMx, SUMy, SUMxy, SUMxx, SUMres, res, slope, y_intercept, y_estimate;
  int i, n;
  FILE *infile;
  infile = fopen(argv[1], "r");
  if (infile == NULL)
    printf("error opening file '%s'\n", argv[1]);
  fscanf(infile, "%d", &n);
  x = (double *)malloc(n * sizeof(double));
  y = (double *)malloc(n * sizeof(double));
  SUMx = 0;
  SUMy = 0;
  SUMxy = 0;
  SUMxx = 0;
  for (i = 0; i < n; i++) {
    fscanf(infile, "%lf %lf", &x[i], &y[i]);
    SUMx = SUMx + x[i];
    SUMy = SUMy + y[i];
    SUMxy = SUMxy + x[i] * y[i];
    SUMxx = SUMxx + x[i] * x[i];
  }
  slope = (SUMx * SUMy - n * SUMxy) / (SUMx * SUMx - n * SUMxx);
  y_intercept = (SUMy - slope * SUMx) / n;
  printf("\n");
  printf("The linear equation that best fits the given data:\n");
  printf("       y = %6.2lfx + %6.2lf\n", slope, y_intercept);
  printf("--------------------------------------------------\n");
  printf("   Original (x,y)     Estimated y     Residual\n");
  printf("--------------------------------------------------\n");
  SUMres = 0;
  for (i = 0; i < n; i++) {
    y_estimate = slope * x[i] + y_intercept;
    res = y[i] - y_estimate;
    SUMres = SUMres + res * res;
    printf("   (%6.2lf %6.2lf)      %6.2lf       %6.2lf\n", x[i], y[i],
           y_estimate, res);
  }
  printf("--------------------------------------------------\n");
  printf("Residual sum = %6.2lf\n", SUMres);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe98(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    1192 <main+0x52>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x78(%rbp),%rdi
lea    0xe7e(%rip),%rsi
lea    -0x70(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
movslq -0x70(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movslq -0x70(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x70(%rbp),%eax
jge    12c5 <main+0x185>
mov    -0x78(%rbp),%rdi
mov    -0x18(%rbp),%rdx
movslq -0x6c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x20(%rbp),%rcx
movslq -0x6c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rcx
lea    0xdf4(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x6c(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x6c(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x38(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    11f5 <main+0xb5>
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
cvtsi2sdl -0x70(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm3
cvtsi2sdl -0x70(%rbp),%xmm2
mulsd  -0x40(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsi2sdl -0x70(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
lea    0xca2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xca1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x58(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
lea    0xcbd(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
lea    0xccc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xcf2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xcb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x70(%rbp),%eax
jge    1480 <main+0x340>
movsd  -0x58(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x60(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x68(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm3
lea    0xc70(%rip),%rdi
mov    $0x4,%al
call   1030 <printf@plt>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    13dd <main+0x29d>
lea    0xbf0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x48(%rbp),%xmm0
lea    0xc6e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe84(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r13
test   %rax,%rax
jne    119b <main+0x3b>
mov    0x8(%rbx),%rsi
lea    0xe6e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe79(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %r13,%rdi
xor    %eax,%eax
call   1060 <fscanf@plt>
mov    0xc(%rsp),%edi
shl    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    0xc(%rsp),%edi
shl    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    126d <main+0x10d>
xorpd  %xmm1,%xmm1
lea    0xe38(%rip),%r12
mov    %r14,0x20(%rsp)
mov    %r14,%rbx
mov    %r15,%rbp
xor    %r14d,%r14d
xorpd  %xmm3,%xmm3
nopl   0x0(%rax,%rax,1)
movapd %xmm3,0x30(%rsp)
movapd %xmm1,0x10(%rsp)
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   1060 <fscanf@plt>
movapd 0x10(%rsp),%xmm2
movapd 0x30(%rsp),%xmm3
movsd  (%rbx),%xmm0
movapd %xmm0,%xmm1
movhpd 0x0(%rbp),%xmm1
addpd  %xmm1,%xmm3
unpcklpd %xmm0,%xmm0
mulpd  %xmm1,%xmm0
movapd %xmm0,%xmm1
addpd  %xmm2,%xmm1
add    $0x1,%r14
movslq 0xc(%rsp),%rax
add    $0x8,%rbp
add    $0x8,%rbx
cmp    %rax,%r14
jl     1200 <main+0xa0>
addpd  %xmm2,%xmm0
mov    0x20(%rsp),%r14
jmp    1275 <main+0x115>
xorpd  %xmm0,%xmm0
xorpd  %xmm3,%xmm3
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movapd %xmm1,%xmm2
unpcklpd %xmm1,%xmm2
mulpd  %xmm0,%xmm2
movapd %xmm3,%xmm0
unpcklpd %xmm3,%xmm0
mulpd  %xmm3,%xmm0
subpd  %xmm2,%xmm0
movapd %xmm0,%xmm2
unpckhpd %xmm0,%xmm2
divsd  %xmm0,%xmm2
movapd %xmm2,0x20(%rsp)
movapd %xmm2,%xmm0
mulsd  %xmm3,%xmm0
unpckhpd %xmm3,%xmm3
subsd  %xmm0,%xmm3
divsd  %xmm1,%xmm3
movapd %xmm3,0x30(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdb2(%rip),%rdi
call   1040 <puts@plt>
lea    0xd45(%rip),%rdi
movapd 0x20(%rsp),%xmm0
movapd 0x30(%rsp),%xmm1
mov    $0x2,%al
call   1050 <printf@plt>
lea    0xdee(%rip),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xdb0(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    1396 <main+0x236>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %ebp,%ebp
lea    0xd12(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%r14,%rbp,8),%xmm0
movapd 0x20(%rsp),%xmm2
mulsd  %xmm0,%xmm2
addsd  0x30(%rsp),%xmm2
movsd  (%r15,%rbp,8),%xmm1
movapd %xmm1,%xmm3
subsd  %xmm2,%xmm3
movapd %xmm3,%xmm4
mulsd  %xmm3,%xmm4
movsd  0x10(%rsp),%xmm5
addsd  %xmm4,%xmm5
movsd  %xmm5,0x10(%rsp)
mov    %rbx,%rdi
mov    $0x4,%al
call   1050 <printf@plt>
add    $0x1,%rbp
movslq 0xc(%rsp),%rax
cmp    %rax,%rbp
jl     1340 <main+0x1e0>
jmp    13a0 <main+0x240>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0xd42(%rip),%rdi
call   1040 <puts@plt>
lea    0xcbd(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [25 x i8] c"error opening file '%s'\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [8 x i8] c"%lf %lf\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [52 x i8] c"The linear equation that best fits the given data:\0A\00"
@.str.6 = [29 x i8] c" y = %6.2lfx + %6.2lf\0A\00"
@.str.7 = [52 x i8] c"--------------------------------------------------\0A\00"
@.str.8 = [48 x i8] c" Original (x,y) Estimated y Residual\0A\00"
@.str.9 = [45 x i8] c" (%6.2lf %6.2lf) %6.2lf %6.2lf\0A\00"
@.str.10 = [23 x i8] c"Residual sum = %6.2lf\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double*
%7 = alloca double*
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %23, i32** %19
%24 = load i32*, i32** %19
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %31
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %26, %2
%32 = load i32*, i32** %19
%33 = call i32 (i32*, i8*, ...) @fscanf(i32* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %18)
%34 = load i32, i32* %18
%35 = sext i32 %34 to i64
%36 = mul i64 %35, 8
%37 = trunc i64 %36 to i32
%38 = call i64 @malloc(i32 %37)
%39 = inttoptr i64 %38 to double*
store double* %39, double** %6
%40 = load i32, i32* %18
%41 = sext i32 %40 to i64
%42 = mul i64 %41, 8
%43 = trunc i64 %42 to i32
%44 = call i64 @malloc(i32 %43)
%45 = inttoptr i64 %44 to double*
store double* %45, double** %7
store double 0.000000e+00, double* %8
store double 0.000000e+00, double* %9
store double 0.000000e+00, double* %10
store double 0.000000e+00, double* %11
store i32 0, i32* %17
br label %46
46: ; preds = %99, %31
%47 = load i32, i32* %17
%48 = load i32, i32* %18
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %102
50: ; preds = %46
%51 = load i32*, i32** %19
%52 = load double*, double** %6
%53 = load i32, i32* %17
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %52, i64 %54
%56 = load double*, double** %7
%57 = load i32, i32* %17
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %56, i64 %58
%60 = call i32 (i32*, i8*, ...) @fscanf(i32* %51, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double* %55, double* %59)
%61 = load double, double* %8
%62 = load double*, double** %6
%63 = load i32, i32* %17
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %62, i64 %64
%66 = load double, double* %65
%67 = fadd double %61, %66
store double %67, double* %8
%68 = load double, double* %9
%69 = load double*, double** %7
%70 = load i32, i32* %17
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds double, double* %69, i64 %71
%73 = load double, double* %72
%74 = fadd double %68, %73
store double %74, double* %9
%75 = load double, double* %10
%76 = load double*, double** %6
%77 = load i32, i32* %17
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds double, double* %76, i64 %78
%80 = load double, double* %79
%81 = load double*, double** %7
%82 = load i32, i32* %17
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds double, double* %81, i64 %83
%85 = load double, double* %84
%86 = call double @llvm.fmuladd.f64(double %80, double %85, double %75)
store double %86, double* %10
%87 = load double, double* %11
%88 = load double*, double** %6
%89 = load i32, i32* %17
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds double, double* %88, i64 %90
%92 = load double, double* %91
%93 = load double*, double** %6
%94 = load i32, i32* %17
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds double, double* %93, i64 %95
%97 = load double, double* %96
%98 = call double @llvm.fmuladd.f64(double %92, double %97, double %87)
store double %98, double* %11
br label %99
99: ; preds = %50
%100 = load i32, i32* %17
%101 = add nsw i32 %100, 1
store i32 %101, i32* %17
br label %46
102: ; preds = %46
%103 = load double, double* %8
%104 = load double, double* %9
%105 = load i32, i32* %18
%106 = sitofp i32 %105 to double
%107 = load double, double* %10
%108 = fmul double %106, %107
%109 = fneg double %108
%110 = call double @llvm.fmuladd.f64(double %103, double %104, double %109)
%111 = load double, double* %8
%112 = load double, double* %8
%113 = load i32, i32* %18
%114 = sitofp i32 %113 to double
%115 = load double, double* %11
%116 = fmul double %114, %115
%117 = fneg double %116
%118 = call double @llvm.fmuladd.f64(double %111, double %112, double %117)
%119 = fdiv double %110, %118
store double %119, double* %14
%120 = load double, double* %9
%121 = load double, double* %14
%122 = load double, double* %8
%123 = fneg double %121
%124 = call double @llvm.fmuladd.f64(double %123, double %122, double %120)
%125 = load i32, i32* %18
%126 = sitofp i32 %125 to double
%127 = fdiv double %124, %126
store double %127, double* %15
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0))
%130 = load double, double* %14
%131 = load double, double* %15
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), double %130, double %131)
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0))
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0))
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0))
store double 0.000000e+00, double* %12
store i32 0, i32* %17
br label %136
136: ; preds = %173, %102
%137 = load i32, i32* %17
%138 = load i32, i32* %18
%139 = icmp slt i32 %137, %138
br i1 %139, label %140, label %176
140: ; preds = %136
%141 = load double, double* %14
%142 = load double*, double** %6
%143 = load i32, i32* %17
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds double, double* %142, i64 %144
%146 = load double, double* %145
%147 = load double, double* %15
%148 = call double @llvm.fmuladd.f64(double %141, double %146, double %147)
store double %148, double* %16
%149 = load double*, double** %7
%150 = load i32, i32* %17
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds double, double* %149, i64 %151
%153 = load double, double* %152
%154 = load double, double* %16
%155 = fsub double %153, %154
store double %155, double* %13
%156 = load double, double* %12
%157 = load double, double* %13
%158 = load double, double* %13
%159 = call double @llvm.fmuladd.f64(double %157, double %158, double %156)
store double %159, double* %12
%160 = load double*, double** %6
%161 = load i32, i32* %17
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds double, double* %160, i64 %162
%164 = load double, double* %163
%165 = load double*, double** %7
%166 = load i32, i32* %17
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds double, double* %165, i64 %167
%169 = load double, double* %168
%170 = load double, double* %16
%171 = load double, double* %13
%172 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), double %164, double %169, double %170, double %171)
br label %173
173: ; preds = %140
%174 = load i32, i32* %17
%175 = add nsw i32 %174, 1
store i32 %175, i32* %17
br label %136
176: ; preds = %136
%177 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0))
%178 = load double, double* %12
%179 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), double %178)
%180 = load i32, i32* %3
ret i32 %180
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [25 x i8] c"error opening file '%s'\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [8 x i8] c"%lf %lf\00"
@.str.6 = [29 x i8] c" y = %6.2lfx + %6.2lf\0A\00"
@.str.9 = [45 x i8] c" (%6.2lf %6.2lf) %6.2lf %6.2lf\0A\00"
@.str.10 = [23 x i8] c"Residual sum = %6.2lf\0A\00"
@str = [51 x i8] c"The linear equation that best fits the given data:\00"
@str.12 = [47 x i8] c" Original (x,y) Estimated y Residual\00"
@str.14 = [51 x i8] c"--------------------------------------------------\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %9, %2
%13 = call i32 (i32*, i8*, ...) @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %3
%15 = shl i32 %14, 3
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to double*
%18 = load i32, i32* %3
%19 = shl i32 %18, 3
%20 = call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to double*
%22 = load i32, i32* %3
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %44
24: ; preds = %12, %24
%25 = phi i64 [ %38, %24 ], [ 0, %12 ]
%26 = phi <2 x double> [ %37, %24 ], [ zeroinitializer, %12 ]
%27 = phi <2 x double> [ %35, %24 ], [ zeroinitializer, %12 ]
%28 = getelementptr inbounds double, double* %17, i64 %25
%29 = getelementptr inbounds double, double* %21, i64 %25
%30 = call i32 (i32*, i8*, ...) @fscanf(i32* %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double* %28, double* %29)
%31 = load double, double* %28
%32 = load double, double* %29
%33 = insertelement <2 x double> poison, double %31, i64 0
%34 = insertelement <2 x double> %33, double %32, i64 1
%35 = fadd <2 x double> %27, %34
%36 = shufflevector <2 x double> %33, <2 x double> poison, <2 x i32> zeroinitializer
%37 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %36, <2 x double> %34, <2 x double> %26)
%38 = add nuw nsw i64 %25, 1
%39 = load i32, i32* %3
%40 = sext i32 %39 to i64
%41 = icmp slt i64 %38, %40
br i1 %41, label %24, label %42
42: ; preds = %24
%43 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %36, <2 x double> %34, <2 x double> %26)
br label %44
44: ; preds = %42, %12
%45 = phi i32 [ %22, %12 ], [ %39, %42 ]
%46 = phi <2 x double> [ zeroinitializer, %12 ], [ %43, %42 ]
%47 = phi <2 x double> [ zeroinitializer, %12 ], [ %35, %42 ]
%48 = sitofp i32 %45 to double
%49 = fneg <2 x double> %46
%50 = insertelement <2 x double> poison, double %48, i64 0
%51 = shufflevector <2 x double> %50, <2 x double> poison, <2 x i32> zeroinitializer
%52 = fmul <2 x double> %51, %49
%53 = extractelement <2 x double> %47, i64 0
%54 = shufflevector <2 x double> %47, <2 x double> undef, <2 x i32> zeroinitializer
%55 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %54, <2 x double> %47, <2 x double> %52)
%56 = extractelement <2 x double> %55, i64 0
%57 = extractelement <2 x double> %55, i64 1
%58 = fdiv double %57, %56
%59 = fneg double %58
%60 = extractelement <2 x double> %47, i64 1
%61 = call double @llvm.fmuladd.f64(double %59, double %53, double %60)
%62 = fdiv double %61, %48
%63 = call i32 @putchar(i32 10)
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), double %58, double %62)
%66 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.14, i64 0, i64 0))
%67 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.12, i64 0, i64 0))
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.14, i64 0, i64 0))
%69 = load i32, i32* %3
%70 = icmp sgt i32 %69, 0
br i1 %70, label %71, label %86
71: ; preds = %44, %71
%72 = phi i64 [ %82, %71 ], [ 0, %44 ]
%73 = phi double [ %80, %71 ], [ 0.000000e+00, %44 ]
%74 = getelementptr inbounds double, double* %17, i64 %72
%75 = load double, double* %74
%76 = call double @llvm.fmuladd.f64(double %58, double %75, double %62)
%77 = getelementptr inbounds double, double* %21, i64 %72
%78 = load double, double* %77
%79 = fsub double %78, %76
%80 = call double @llvm.fmuladd.f64(double %79, double %79, double %73)
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), double %75, double %78, double %76, double %79)
%82 = add nuw nsw i64 %72, 1
%83 = load i32, i32* %3
%84 = sext i32 %83 to i64
%85 = icmp slt i64 %82, %84
br i1 %85, label %71, label %86
86: ; preds = %71, %44
%87 = phi double [ 0.000000e+00, %44 ], [ %80, %71 ]
%88 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.14, i64 0, i64 0))
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), double %87)
ret i32 0
}