#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*/ avaliacao(char *, int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ inicializacao();
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
double rand();
int /*<<< orphan*/ srand(int);
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;
  if (argc > 1) {
    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));
    for (i = 0; i < n; i++) {
      fscanf(infile, "%lf %lf", &x[i], &y[i]);
    }
  } else {
    n = 100000000;
    srand(424242);
    x = (double *)malloc(n * sizeof(double));
    y = (double *)malloc(n * sizeof(double));
    for (i = 0; i < n; i++) {
      x[i] = i * 2 + rand() / 100000000.0;
      y[i] = i * 5 - rand() / 10000000.0;
    }
  }
  inicializacao();
  SUMx = 0;
  SUMy = 0;
  SUMxy = 0;
  SUMxx = 0;
  for (i = 0; i < n; i++) {
    SUMx += x[i];
    SUMy += y[i];
    SUMxy += x[i] * y[i];
    SUMxx += x[i] * x[i];
  }
  slope = (SUMx * SUMy - n * SUMxy) / (SUMx * SUMx - n * SUMxx);
  y_intercept = (SUMy - slope * SUMx) / n;
  avaliacao("Least Squares - Simples", 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");
  ;
  volatile double result = y_intercept;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    126e <main+0xee>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    11dc <main+0x5c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x78(%rbp),%rdi
lea    0xe44(%rip),%rsi
lea    -0x70(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
movslq -0x70(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
movslq -0x70(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x70(%rbp),%eax
jge    1269 <main+0xe9>
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    0xdda(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    121f <main+0x9f>
jmp    134b <main+0x1cb>
movl   $0x5f5e100,-0x70(%rbp)
mov    $0x67932,%edi
call   1060 <srand@plt>
movslq -0x70(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
movslq -0x70(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x70(%rbp),%eax
jge    1346 <main+0x1c6>
mov    -0x6c(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
mov    $0x0,%al
call   10a0 <rand@plt>
movaps %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
movsd  0xd24(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
imul   $0x5,-0x6c(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    $0x0,%al
call   10a0 <rand@plt>
movaps %xmm0,%xmm1
movsd  -0x88(%rbp),%xmm0
ff
movsd  0xcdd(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    12ac <main+0x12c>
jmp    134b <main+0x1cb>
mov    $0x0,%al
call   1090 <inicializacao@plt>
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    1419 <main+0x299>
mov    -0x18(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%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),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
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
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    1379 <main+0x1f9>
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)
mov    -0x70(%rbp),%esi
lea    0xb68(%rip),%rdi
call   1030 <avaliacao@plt>
lea    0xb4f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xb66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x58(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
lea    0xb82(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
lea    0xb91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xbb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xb75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
cmp    $0x2,%edi
jl     1262 <main+0xc2>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe4b(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    11e4 <main+0x44>
mov    0x8(%rbx),%rsi
lea    0xe35(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe40(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <fscanf@plt>
mov    0xc(%rsp),%edi
shl    $0x3,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    0xc(%rsp),%edi
shl    $0x3,%edi
call   1090 <malloc@plt>
mov    %rax,%r13
cmpl   $0x0,0xc(%rsp)
jle    1301 <main+0x161>
mov    %r14,%rbx
mov    %r13,%rbp
xor    %r12d,%r12d
nopl   0x0(%rax)
mov    %r15,%rdi
lea    0xdf4(%rip),%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   1070 <fscanf@plt>
add    $0x1,%r12
movslq 0xc(%rsp),%rax
add    $0x8,%rbp
add    $0x8,%rbx
cmp    %rax,%r12
jl     1230 <main+0x90>
jmp    1301 <main+0x161>
movl   $0x5f5e100,0xc(%rsp)
05
mov    $0x67932,%edi
call   1080 <srand@plt>
mov    $0x2faf0800,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    $0x2faf0800,%edi
call   1090 <malloc@plt>
mov    %rax,%r13
xor    %ebx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   10c0 <rand@plt>
divsd  0xd44(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%r14,%rbx,4)
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   10c0 <rand@plt>
divsd  0xd24(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x0(%r13,%rbx,4)
add    $0x5,%ebp
add    $0x2,%rbx
cmp    $0xbebc200,%rbx
jne    12a0 <main+0x100>
xor    %eax,%eax
call   10b0 <inicializacao@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    132e <main+0x18e>
cmp    $0x1,%esi
jne    133b <main+0x19b>
xorpd  %xmm1,%xmm1
xor    %eax,%eax
xorpd  %xmm4,%xmm4
test   $0x1,%sil
jne    13aa <main+0x20a>
jmp    13cb <main+0x22b>
xorpd  %xmm0,%xmm0
xorpd  %xmm4,%xmm4
jmp    13cb <main+0x22b>
mov    %esi,%ecx
and    $0xfffffffe,%ecx
xorpd  %xmm1,%xmm1
xor    %eax,%eax
xorpd  %xmm4,%xmm4
nopw   0x0(%rax,%rax,1)
movsd  (%r14,%rax,8),%xmm2
movsd  0x8(%r14,%rax,8),%xmm0
movapd %xmm2,%xmm3
movhpd 0x0(%r13,%rax,8),%xmm3
addpd  %xmm3,%xmm4
unpcklpd %xmm2,%xmm2
mulpd  %xmm3,%xmm2
addpd  %xmm1,%xmm2
movapd %xmm0,%xmm1
movhpd 0x8(%r13,%rax,8),%xmm1
addpd  %xmm1,%xmm4
unpcklpd %xmm0,%xmm0
mulpd  %xmm1,%xmm0
movapd %xmm0,%xmm1
addpd  %xmm2,%xmm1
add    $0x2,%rax
cmp    %rax,%rcx
jne    1350 <main+0x1b0>
addpd  %xmm2,%xmm0
test   $0x1,%sil
je     13cb <main+0x22b>
movsd  (%r14,%rax,8),%xmm0
movapd %xmm0,%xmm2
movhpd 0x0(%r13,%rax,8),%xmm2
addpd  %xmm2,%xmm4
unpcklpd %xmm0,%xmm0
mulpd  %xmm2,%xmm0
addpd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %esi,%xmm1
movapd %xmm1,%xmm2
unpcklpd %xmm1,%xmm2
mulpd  %xmm0,%xmm2
movapd %xmm4,%xmm0
unpcklpd %xmm4,%xmm0
mulpd  %xmm4,%xmm0
subpd  %xmm2,%xmm0
movapd %xmm0,%xmm2
unpckhpd %xmm0,%xmm2
divsd  %xmm0,%xmm2
movapd %xmm2,0x20(%rsp)
movapd %xmm2,%xmm0
mulsd  %xmm4,%xmm0
unpckhpd %xmm4,%xmm4
subsd  %xmm0,%xmm4
divsd  %xmm1,%xmm4
movapd %xmm4,0x10(%rsp)
lea    0xc15(%rip),%rdi
call   1030 <avaliacao@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xc34(%rip),%rdi
call   1050 <puts@plt>
lea    0xc0b(%rip),%rdi
movaps 0x20(%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
mov    $0x2,%al
call   1060 <printf@plt>
lea    0xc72(%rip),%rbx
mov    %rbx,%rdi
call   1050 <puts@plt>
lea    0xc34(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
movaps 0x10(%rsp),%xmm0
movsd  %xmm0,0x30(%rsp)
xor    %eax,%eax
add    $0x38,%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 = [24 x i8] c"Least Squares - Simples\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [52 x i8] c"The linear equation that best fits the given data:\0A\00"
@.str.7 = [29 x i8] c" y = %6.2lfx + %6.2lf\0A\00"
@.str.8 = [52 x i8] c"--------------------------------------------------\0A\00"
@.str.9 = [48 x i8] c" Original (x,y) Estimated y Residual\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*
%20 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%21 = load i32, i32* %4
%22 = icmp sgt i32 %21, 1
br i1 %22, label %23, label %69
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %27, i32** %19
%28 = load i32*, i32** %19
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %35
30: ; preds = %23
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %30, %23
%36 = load i32*, i32** %19
%37 = call i32 (i32*, i8*, ...) @fscanf(i32* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %18)
%38 = load i32, i32* %18
%39 = sext i32 %38 to i64
%40 = mul i64 %39, 8
%41 = trunc i64 %40 to i32
%42 = call i64 @malloc(i32 %41)
%43 = inttoptr i64 %42 to double*
store double* %43, double** %6
%44 = load i32, i32* %18
%45 = sext i32 %44 to i64
%46 = mul i64 %45, 8
%47 = trunc i64 %46 to i32
%48 = call i64 @malloc(i32 %47)
%49 = inttoptr i64 %48 to double*
store double* %49, double** %7
store i32 0, i32* %17
br label %50
50: ; preds = %65, %35
%51 = load i32, i32* %17
%52 = load i32, i32* %18
%53 = icmp slt i32 %51, %52
br i1 %53, label %54, label %68
54: ; preds = %50
%55 = load i32*, i32** %19
%56 = load double*, double** %6
%57 = load i32, i32* %17
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %56, i64 %58
%60 = load double*, double** %7
%61 = load i32, i32* %17
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %60, i64 %62
%64 = call i32 (i32*, i8*, ...) @fscanf(i32* %55, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double* %59, double* %63)
br label %65
65: ; preds = %54
%66 = load i32, i32* %17
%67 = add nsw i32 %66, 1
store i32 %67, i32* %17
br label %50
68: ; preds = %50
br label %112
69: ; preds = %2
store i32 100000000, i32* %18
%70 = call i32 @srand(i32 424242)
%71 = load i32, i32* %18
%72 = sext i32 %71 to i64
%73 = mul i64 %72, 8
%74 = trunc i64 %73 to i32
%75 = call i64 @malloc(i32 %74)
%76 = inttoptr i64 %75 to double*
store double* %76, double** %6
%77 = load i32, i32* %18
%78 = sext i32 %77 to i64
%79 = mul i64 %78, 8
%80 = trunc i64 %79 to i32
%81 = call i64 @malloc(i32 %80)
%82 = inttoptr i64 %81 to double*
store double* %82, double** %7
store i32 0, i32* %17
br label %83
83: ; preds = %108, %69
%84 = load i32, i32* %17
%85 = load i32, i32* %18
%86 = icmp slt i32 %84, %85
br i1 %86, label %87, label %111
87: ; preds = %83
%88 = load i32, i32* %17
%89 = mul nsw i32 %88, 2
%90 = sitofp i32 %89 to double
%91 = call double (...) @rand()
%92 = fdiv double %91, 1.000000e+08
%93 = fadd double %90, %92
%94 = load double*, double** %6
%95 = load i32, i32* %17
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds double, double* %94, i64 %96
store double %93, double* %97
%98 = load i32, i32* %17
%99 = mul nsw i32 %98, 5
%100 = sitofp i32 %99 to double
%101 = call double (...) @rand()
%102 = fdiv double %101, 1.000000e+07
%103 = fsub double %100, %102
%104 = load double*, double** %7
%105 = load i32, i32* %17
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds double, double* %104, i64 %106
store double %103, double* %107
br label %108
108: ; preds = %87
%109 = load i32, i32* %17
%110 = add nsw i32 %109, 1
store i32 %110, i32* %17
br label %83
111: ; preds = %83
br label %112
112: ; preds = %111, %68
%113 = call i32 (...) @inicializacao()
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 %114
114: ; preds = %157, %112
%115 = load i32, i32* %17
%116 = load i32, i32* %18
%117 = icmp slt i32 %115, %116
br i1 %117, label %118, label %160
118: ; preds = %114
%119 = load double*, double** %6
%120 = load i32, i32* %17
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds double, double* %119, i64 %121
%123 = load double, double* %122
%124 = load double, double* %8
%125 = fadd double %124, %123
store double %125, double* %8
%126 = load double*, double** %7
%127 = load i32, i32* %17
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds double, double* %126, i64 %128
%130 = load double, double* %129
%131 = load double, double* %9
%132 = fadd double %131, %130
store double %132, double* %9
%133 = load double*, double** %6
%134 = load i32, i32* %17
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds double, double* %133, i64 %135
%137 = load double, double* %136
%138 = load double*, double** %7
%139 = load i32, i32* %17
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds double, double* %138, i64 %140
%142 = load double, double* %141
%143 = load double, double* %10
%144 = call double @llvm.fmuladd.f64(double %137, double %142, double %143)
store double %144, double* %10
%145 = load double*, double** %6
%146 = load i32, i32* %17
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds double, double* %145, i64 %147
%149 = load double, double* %148
%150 = load double*, double** %6
%151 = load i32, i32* %17
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds double, double* %150, i64 %152
%154 = load double, double* %153
%155 = load double, double* %11
%156 = call double @llvm.fmuladd.f64(double %149, double %154, double %155)
store double %156, double* %11
br label %157
157: ; preds = %118
%158 = load i32, i32* %17
%159 = add nsw i32 %158, 1
store i32 %159, i32* %17
br label %114
160: ; preds = %114
%161 = load double, double* %8
%162 = load double, double* %9
%163 = load i32, i32* %18
%164 = sitofp i32 %163 to double
%165 = load double, double* %10
%166 = fmul double %164, %165
%167 = fneg double %166
%168 = call double @llvm.fmuladd.f64(double %161, double %162, double %167)
%169 = load double, double* %8
%170 = load double, double* %8
%171 = load i32, i32* %18
%172 = sitofp i32 %171 to double
%173 = load double, double* %11
%174 = fmul double %172, %173
%175 = fneg double %174
%176 = call double @llvm.fmuladd.f64(double %169, double %170, double %175)
%177 = fdiv double %168, %176
store double %177, double* %14
%178 = load double, double* %9
%179 = load double, double* %14
%180 = load double, double* %8
%181 = fneg double %179
%182 = call double @llvm.fmuladd.f64(double %181, double %180, double %178)
%183 = load i32, i32* %18
%184 = sitofp i32 %183 to double
%185 = fdiv double %182, %184
store double %185, double* %15
%186 = load i32, i32* %18
%187 = call i32 @avaliacao(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %186)
%188 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%189 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0))
%190 = load double, double* %14
%191 = load double, double* %15
%192 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), double %190, double %191)
%193 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.8, i64 0, i64 0))
%194 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.9, i64 0, i64 0))
%195 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.8, i64 0, i64 0))
%196 = load double, double* %15
store volatile double %196, double* %20
%197 = load i32, i32* %3
ret i32 %197
}

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.4 = [24 x i8] c"Least Squares - Simples\00"
@.str.7 = [29 x i8] c" y = %6.2lfx + %6.2lf\0A\00"
@str = [51 x i8] c"The linear equation that best fits the given data:\00"
@str.11 = [47 x i8] c" Original (x,y) Estimated y Residual\00"
@str.12 = [51 x i8] c"--------------------------------------------------\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca double
%5 = bitcast i32* %3 to i8*
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %36
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load i8*, i8** %8
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %12, %7
%16 = call i32 (i32*, i8*, ...) @fscanf(i32* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%17 = load i32, i32* %3
%18 = shl i32 %17, 3
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to double*
%21 = load i32, i32* %3
%22 = shl i32 %21, 3
%23 = call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to double*
%25 = load i32, i32* %3
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %60
27: ; preds = %15, %27
%28 = phi i64 [ %32, %27 ], [ 0, %15 ]
%29 = getelementptr inbounds double, double* %20, i64 %28
%30 = getelementptr inbounds double, double* %24, i64 %28
%31 = call i32 (i32*, i8*, ...) @fscanf(i32* %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double* %29, double* %30)
%32 = add nuw nsw i64 %28, 1
%33 = load i32, i32* %3
%34 = sext i32 %33 to i64
%35 = icmp slt i64 %32, %34
br i1 %35, label %27, label %60
36: ; preds = %2
store i32 100000000, i32* %3
%37 = tail call i32 @srand(i32 424242)
%38 = tail call i64 @malloc(i32 800000000)
%39 = inttoptr i64 %38 to double*
%40 = tail call i64 @malloc(i32 800000000)
%41 = inttoptr i64 %40 to double*
br label %42
42: ; preds = %36, %42
%43 = phi i64 [ 0, %36 ], [ %58, %42 ]
%44 = trunc i64 %43 to i32
%45 = shl i32 %44, 1
%46 = sitofp i32 %45 to double
%47 = tail call double (...) @rand()
%48 = fdiv double %47, 1.000000e+08
%49 = fadd double %48, %46
%50 = getelementptr inbounds double, double* %39, i64 %43
store double %49, double* %50
%51 = trunc i64 %43 to i32
%52 = mul i32 %51, 5
%53 = sitofp i32 %52 to double
%54 = tail call double (...) @rand()
%55 = fdiv double %54, 1.000000e+07
%56 = fsub double %53, %55
%57 = getelementptr inbounds double, double* %41, i64 %43
store double %56, double* %57
%58 = add nuw nsw i64 %43, 1
%59 = icmp eq i64 %58, 100000000
br i1 %59, label %60, label %42
60: ; preds = %42, %27, %15
%61 = phi double* [ %24, %15 ], [ %24, %27 ], [ %41, %42 ]
%62 = phi double* [ %20, %15 ], [ %20, %27 ], [ %39, %42 ]
%63 = call i32 (...) @inicializacao()
%64 = load i32, i32* %3
%65 = icmp sgt i32 %64, 0
br i1 %65, label %66, label %118
66: ; preds = %60
%67 = zext i32 %64 to i64
%68 = and i64 %67, 1
%69 = icmp eq i32 %64, 1
br i1 %69, label %101, label %70
70: ; preds = %66
%71 = and i64 %67, 4294967294
br label %72
72: ; preds = %72, %70
%73 = phi i64 [ 0, %70 ], [ %96, %72 ]
%74 = phi <2 x double> [ zeroinitializer, %70 ], [ %95, %72 ]
%75 = phi <2 x double> [ zeroinitializer, %70 ], [ %93, %72 ]
%76 = phi i64 [ 0, %70 ], [ %97, %72 ]
%77 = getelementptr inbounds double, double* %62, i64 %73
%78 = load double, double* %77
%79 = getelementptr inbounds double, double* %61, i64 %73
%80 = load double, double* %79
%81 = insertelement <2 x double> poison, double %78, i64 0
%82 = insertelement <2 x double> %81, double %80, i64 1
%83 = fadd <2 x double> %75, %82
%84 = shufflevector <2 x double> %81, <2 x double> poison, <2 x i32> zeroinitializer
%85 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %84, <2 x double> %82, <2 x double> %74)
%86 = or i64 %73, 1
%87 = getelementptr inbounds double, double* %62, i64 %86
%88 = load double, double* %87
%89 = getelementptr inbounds double, double* %61, i64 %86
%90 = load double, double* %89
%91 = insertelement <2 x double> poison, double %88, i64 0
%92 = insertelement <2 x double> %91, double %90, i64 1
%93 = fadd <2 x double> %83, %92
%94 = shufflevector <2 x double> %91, <2 x double> poison, <2 x i32> zeroinitializer
%95 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %94, <2 x double> %92, <2 x double> %85)
%96 = add nuw nsw i64 %73, 2
%97 = add i64 %76, 2
%98 = icmp eq i64 %97, %71
br i1 %98, label %99, label %72
99: ; preds = %72
%100 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %94, <2 x double> %92, <2 x double> %85)
br label %101
101: ; preds = %99, %66
%102 = phi <2 x double> [ undef, %66 ], [ %93, %99 ]
%103 = phi <2 x double> [ undef, %66 ], [ %100, %99 ]
%104 = phi i64 [ 0, %66 ], [ %96, %99 ]
%105 = phi <2 x double> [ zeroinitializer, %66 ], [ %95, %99 ]
%106 = phi <2 x double> [ zeroinitializer, %66 ], [ %93, %99 ]
%107 = icmp eq i64 %68, 0
br i1 %107, label %118, label %108
108: ; preds = %101
%109 = getelementptr inbounds double, double* %62, i64 %104
%110 = load double, double* %109
%111 = getelementptr inbounds double, double* %61, i64 %104
%112 = load double, double* %111
%113 = insertelement <2 x double> poison, double %110, i64 0
%114 = insertelement <2 x double> %113, double %112, i64 1
%115 = fadd <2 x double> %106, %114
%116 = shufflevector <2 x double> %113, <2 x double> poison, <2 x i32> zeroinitializer
%117 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %116, <2 x double> %114, <2 x double> %105)
br label %118
118: ; preds = %108, %101, %60
%119 = phi <2 x double> [ zeroinitializer, %60 ], [ %103, %101 ], [ %117, %108 ]
%120 = phi <2 x double> [ zeroinitializer, %60 ], [ %102, %101 ], [ %115, %108 ]
%121 = sitofp i32 %64 to double
%122 = fneg <2 x double> %119
%123 = insertelement <2 x double> poison, double %121, i64 0
%124 = shufflevector <2 x double> %123, <2 x double> poison, <2 x i32> zeroinitializer
%125 = fmul <2 x double> %124, %122
%126 = extractelement <2 x double> %120, i64 0
%127 = shufflevector <2 x double> %120, <2 x double> undef, <2 x i32> zeroinitializer
%128 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %127, <2 x double> %120, <2 x double> %125)
%129 = extractelement <2 x double> %128, i64 0
%130 = extractelement <2 x double> %128, i64 1
%131 = fdiv double %130, %129
%132 = fneg double %131
%133 = extractelement <2 x double> %120, i64 1
%134 = call double @llvm.fmuladd.f64(double %132, double %126, double %133)
%135 = fdiv double %134, %121
%136 = call i32 @avaliacao(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %64)
%137 = call i32 @putchar(i32 10)
%138 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
%139 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), double %131, double %135)
%140 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.12, i64 0, i64 0))
%141 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.11, i64 0, i64 0))
%142 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.12, i64 0, i64 0))
%143 = bitcast double* %4 to i8*
store volatile double %135, double* %4
ret i32 0
}