#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ free(double *);
double *gaussSLESolve(int, double *);
double *calcParabolaCoeffs(double *points) {
  double *m = (double *)calloc(3 * 4, sizeof(double));
  for (int i = 0; i < 3; i++) {
    int offset = i * 2;
    m[i * 4] = points[offset] * points[offset];
    m[i * 4 + 1] = points[offset];
    m[i * 4 + 2] = 1;
    m[i * 4 + 3] = points[offset + 1];
  }
  double *coeffs = gaussSLESolve(3, m);
  free(m);
  return coeffs;
}


x86 assembly (clang, -O0):
<calcParabolaCoeffs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0xc,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    1209 <calcParabolaCoeffs+0xd9>
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x2,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x2,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x2,%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  0xe31(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x2,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1156 <calcParabolaCoeffs+0x26>
mov    -0x10(%rbp),%rsi
mov    $0x3,%edi
call   1040 <gaussSLESolve@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcParabolaCoeffs>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0xc,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
movsd  (%r14),%xmm0
mulsd  %xmm0,%xmm0
movsd  %xmm0,(%rax)
movsd  (%r14),%xmm0
movsd  %xmm0,0x8(%rax)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x10(%rbx)
movsd  0x8(%r14),%xmm0
movsd  %xmm0,0x18(%rbx)
movsd  0x10(%r14),%xmm0
mulsd  %xmm0,%xmm0
movsd  %xmm0,0x20(%rbx)
movsd  0x10(%r14),%xmm0
movsd  %xmm0,0x28(%rbx)
mov    %rax,0x30(%rbx)
movsd  0x18(%r14),%xmm0
movsd  %xmm0,0x38(%rbx)
movsd  0x20(%r14),%xmm0
mulsd  %xmm0,%xmm0
movsd  %xmm0,0x40(%rbx)
movsd  0x20(%r14),%xmm0
movsd  %xmm0,0x48(%rbx)
mov    %rax,0x50(%rbx)
movsd  0x28(%r14),%xmm0
movsd  %xmm0,0x58(%rbx)
mov    $0x3,%edi
mov    %rbx,%rsi
call   1040 <gaussSLESolve@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double* @calcParabolaCoeffs(double* %0) {
%2 = alloca double*
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca double*
store double* %0, double** %2
%7 = call i64 @calloc(i32 12, i32 8)
%8 = inttoptr i64 %7 to double*
store double* %8, double** %3
store i32 0, i32* %4
br label %9
9: ; preds = %60, %1
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %63
12: ; preds = %9
%13 = load i32, i32* %4
%14 = mul nsw i32 %13, 2
store i32 %14, i32* %5
%15 = load double*, double** %2
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds double, double* %15, i64 %17
%19 = load double, double* %18
%20 = load double*, double** %2
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
%24 = load double, double* %23
%25 = fmul double %19, %24
%26 = load double*, double** %3
%27 = load i32, i32* %4
%28 = mul nsw i32 %27, 4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %26, i64 %29
store double %25, double* %30
%31 = load double*, double** %2
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load double, double* %34
%36 = load double*, double** %3
%37 = load i32, i32* %4
%38 = mul nsw i32 %37, 4
%39 = add nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %36, i64 %40
store double %35, double* %41
%42 = load double*, double** %3
%43 = load i32, i32* %4
%44 = mul nsw i32 %43, 4
%45 = add nsw i32 %44, 2
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %42, i64 %46
store double 1.000000e+00, double* %47
%48 = load double*, double** %2
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %48, i64 %51
%53 = load double, double* %52
%54 = load double*, double** %3
%55 = load i32, i32* %4
%56 = mul nsw i32 %55, 4
%57 = add nsw i32 %56, 3
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %54, i64 %58
store double %53, double* %59
br label %60
60: ; preds = %12
%61 = load i32, i32* %4
%62 = add nsw i32 %61, 1
store i32 %62, i32* %4
br label %9
63: ; preds = %9
%64 = load double*, double** %3
%65 = call double* @gaussSLESolve(i32 3, double* %64)
store double* %65, double** %6
%66 = load double*, double** %3
%67 = call i32 @free(double* %66)
%68 = load double*, double** %6
ret double* %68
}

LLVM IR (-O2):
define double* @calcParabolaCoeffs(double* nocapture %0) {
%2 = tail call i64 @calloc(i32 12, i32 8)
%3 = inttoptr i64 %2 to double*
%4 = load double, double* %0
%5 = fmul double %4, %4
store double %5, double* %3
%6 = load double, double* %0
%7 = getelementptr inbounds double, double* %3, i64 1
store double %6, double* %7
%8 = getelementptr inbounds double, double* %3, i64 2
store double 1.000000e+00, double* %8
%9 = getelementptr inbounds double, double* %0, i64 1
%10 = load double, double* %9
%11 = getelementptr inbounds double, double* %3, i64 3
store double %10, double* %11
%12 = getelementptr inbounds double, double* %0, i64 2
%13 = load double, double* %12
%14 = fmul double %13, %13
%15 = getelementptr inbounds double, double* %3, i64 4
store double %14, double* %15
%16 = load double, double* %12
%17 = getelementptr inbounds double, double* %3, i64 5
store double %16, double* %17
%18 = getelementptr inbounds double, double* %3, i64 6
store double 1.000000e+00, double* %18
%19 = getelementptr inbounds double, double* %0, i64 3
%20 = load double, double* %19
%21 = getelementptr inbounds double, double* %3, i64 7
store double %20, double* %21
%22 = getelementptr inbounds double, double* %0, i64 4
%23 = load double, double* %22
%24 = fmul double %23, %23
%25 = getelementptr inbounds double, double* %3, i64 8
store double %24, double* %25
%26 = load double, double* %22
%27 = getelementptr inbounds double, double* %3, i64 9
store double %26, double* %27
%28 = getelementptr inbounds double, double* %3, i64 10
store double 1.000000e+00, double* %28
%29 = getelementptr inbounds double, double* %0, i64 5
%30 = load double, double* %29
%31 = getelementptr inbounds double, double* %3, i64 11
store double %30, double* %31
%32 = tail call double* @gaussSLESolve(i32 3, double* %3)
%33 = tail call i32 @free(double* %3)
ret double* %32
}