#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 */
int /*<<< orphan*/ mat221Multiply(double **, double *, double *);
double mat22Invert(double **, double **);
int /*<<< orphan*/ printf(char *);
void interpolating(double x[2], double a[2], double b[2], double c[2],
                   double rgb[3], double alpha[3], double beta[3],
                   double gamma[3], double new_rgb[3]) {
  double m[2][2] = {{b[0] - a[0], c[0] - a[0]}, {b[1] - a[1], c[1] - a[1]}};
  double Inv[2][2] = {{0.0, 0.0}, {0.0, 0.0}};
  double det = mat22Invert(m, Inv);
  double vec[2] = {x[0] - a[0], x[1] - a[1]};
  double pq[2] = {0.0, 0.0};
  mat221Multiply(Inv, vec, pq);
  if (det != 0) {
    new_rgb[0] = (alpha[0] + pq[0] * (beta[0] - alpha[0]) +
                  pq[1] * (gamma[0] - alpha[0])) *
                 rgb[0];
    new_rgb[1] = (alpha[1] + pq[0] * (beta[1] - alpha[1]) +
                  pq[1] * (gamma[1] - alpha[1])) *
                 rgb[1];
    new_rgb[2] = (alpha[2] + pq[0] * (beta[2] - alpha[2]) +
                  pq[1] * (gamma[2] - alpha[2])) *
                 rgb[2];
  } else {
    printf("The matrix doesn't have an Inverse, something is wrong here\n");
  }
}


x86 assembly (clang, -O0):
<interpolating>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
lea    -0x50(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1060 <mat22Invert@plt>
movsd  %xmm0,-0x78(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x90(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
lea    -0x70(%rbp),%rdi
lea    -0x90(%rbp),%rsi
lea    -0xa0(%rbp),%rdx
call   1050 <mat221Multiply@plt>
movsd  -0x78(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1262 <interpolating+0x122>
jp     1262 <interpolating+0x122>
jmp    137d <interpolating+0x23d>
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0xa0(%rbp),%xmm1
ff
mov    0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x30(%rbp),%rax
subsd  (%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
mov    0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x30(%rbp),%rax
subsd  (%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
mulsd  (%rax),%xmm0
mov    0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  -0xa0(%rbp),%xmm1
ff
mov    0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x30(%rbp),%rax
subsd  0x8(%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
mov    0x18(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x30(%rbp),%rax
subsd  0x8(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mov    0x20(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x30(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  -0xa0(%rbp),%xmm1
ff
mov    0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x30(%rbp),%rax
subsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
mov    0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x30(%rbp),%rax
subsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
mulsd  0x10(%rax),%xmm0
mov    0x20(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    1389 <interpolating+0x249>
lea    0xc7c(%rip),%rdi
call   1030 <printf@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interpolating>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x70,%rsp
movsd  (%rdx),%xmm0
movhpd (%rcx),%xmm0
mov    %rsi,%rbx
movsd  (%rsi),%xmm1
unpcklpd %xmm1,%xmm1
subpd  %xmm1,%xmm0
movapd %xmm0,0x50(%rsp)
movsd  0x8(%rdx),%xmm0
movhpd 0x8(%rcx),%xmm0
mov    %r9,%r15
mov    %r8,%r14
mov    %rdi,%r12
movsd  0x8(%rsi),%xmm1
unpcklpd %xmm1,%xmm1
subpd  %xmm1,%xmm0
movapd %xmm0,0x60(%rsp)
xorpd  %xmm0,%xmm0
movapd %xmm0,0x40(%rsp)
movapd %xmm0,0x30(%rsp)
lea    0x50(%rsp),%rdi
lea    0x30(%rsp),%r13
mov    %r13,%rsi
call   1050 <mat22Invert@plt>
movsd  %xmm0,0x18(%rsp)
movupd (%r12),%xmm0
movupd (%rbx),%xmm1
subpd  %xmm1,%xmm0
movapd %xmm0,0x20(%rsp)
xorpd  %xmm0,%xmm0
movapd %xmm0,(%rsp)
lea    0x20(%rsp),%rsi
mov    %rsp,%rdx
mov    %r13,%rdi
call   1040 <mat221Multiply@plt>
xorpd  %xmm0,%xmm0
movsd  0x18(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jne    11eb <interpolating+0xbb>
jnp    12a4 <interpolating+0x174>
mov    0xb0(%rsp),%rax
mov    0xa8(%rsp),%rcx
mov    0xa0(%rsp),%rdx
movsd  (%r15),%xmm2
movsd  (%rdx),%xmm3
subsd  %xmm2,%xmm3
movsd  (%rsp),%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm3
addsd  %xmm2,%xmm3
movsd  (%rcx),%xmm4
subsd  %xmm2,%xmm4
mulsd  %xmm0,%xmm4
addsd  %xmm3,%xmm4
mulsd  (%r14),%xmm4
movsd  %xmm4,(%rax)
movsd  0x8(%r15),%xmm2
movsd  0x8(%rdx),%xmm3
subsd  %xmm2,%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm2,%xmm3
movsd  0x8(%rcx),%xmm4
subsd  %xmm2,%xmm4
mulsd  %xmm0,%xmm4
addsd  %xmm3,%xmm4
mulsd  0x8(%r14),%xmm4
movsd  %xmm4,0x8(%rax)
movsd  0x10(%r15),%xmm2
movsd  0x10(%rdx),%xmm3
subsd  %xmm2,%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm2,%xmm3
movsd  0x10(%rcx),%xmm1
subsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm3,%xmm1
mulsd  0x10(%r14),%xmm1
movsd  %xmm1,0x10(%rax)
jmp    12b0 <interpolating+0x180>
lea    0xd65(%rip),%rdi
call   1030 <puts@plt>
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [61 x i8] c"The matrix doesn't have an Inverse, something is wrong here\0A\00"
define void @interpolating(double* %0, double* %1, double* %2, double* %3, double* %4, double* %5, double* %6, double* %7, double* %8) {
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double*
%16 = alloca double*
%17 = alloca double*
%18 = alloca double*
%19 = alloca [2 x [2 x double]]
%20 = alloca [2 x [2 x double]]
%21 = alloca double
%22 = alloca [2 x double]
%23 = alloca [2 x double]
store double* %0, double** %10
store double* %1, double** %11
store double* %2, double** %12
store double* %3, double** %13
store double* %4, double** %14
store double* %5, double** %15
store double* %6, double** %16
store double* %7, double** %17
store double* %8, double** %18
%24 = getelementptr inbounds [2 x [2 x double]], [2 x [2 x double]]* %19, i64 0, i64 0
%25 = getelementptr inbounds [2 x double], [2 x double]* %24, i64 0, i64 0
%26 = load double*, double** %12
%27 = getelementptr inbounds double, double* %26, i64 0
%28 = load double, double* %27
%29 = load double*, double** %11
%30 = getelementptr inbounds double, double* %29, i64 0
%31 = load double, double* %30
%32 = fsub double %28, %31
store double %32, double* %25
%33 = getelementptr inbounds double, double* %25, i64 1
%34 = load double*, double** %13
%35 = getelementptr inbounds double, double* %34, i64 0
%36 = load double, double* %35
%37 = load double*, double** %11
%38 = getelementptr inbounds double, double* %37, i64 0
%39 = load double, double* %38
%40 = fsub double %36, %39
store double %40, double* %33
%41 = getelementptr inbounds [2 x double], [2 x double]* %24, i64 1
%42 = getelementptr inbounds [2 x double], [2 x double]* %41, i64 0, i64 0
%43 = load double*, double** %12
%44 = getelementptr inbounds double, double* %43, i64 1
%45 = load double, double* %44
%46 = load double*, double** %11
%47 = getelementptr inbounds double, double* %46, i64 1
%48 = load double, double* %47
%49 = fsub double %45, %48
store double %49, double* %42
%50 = getelementptr inbounds double, double* %42, i64 1
%51 = load double*, double** %13
%52 = getelementptr inbounds double, double* %51, i64 1
%53 = load double, double* %52
%54 = load double*, double** %11
%55 = getelementptr inbounds double, double* %54, i64 1
%56 = load double, double* %55
%57 = fsub double %53, %56
store double %57, double* %50
%58 = bitcast [2 x [2 x double]]* %20 to i8*
%59 = getelementptr inbounds [2 x [2 x double]], [2 x [2 x double]]* %19, i64 0, i64 0
%60 = bitcast [2 x double]* %59 to double**
%61 = getelementptr inbounds [2 x [2 x double]], [2 x [2 x double]]* %20, i64 0, i64 0
%62 = bitcast [2 x double]* %61 to double**
%63 = call double @mat22Invert(double** %60, double** %62)
store double %63, double* %21
%64 = getelementptr inbounds [2 x double], [2 x double]* %22, i64 0, i64 0
%65 = load double*, double** %10
%66 = getelementptr inbounds double, double* %65, i64 0
%67 = load double, double* %66
%68 = load double*, double** %11
%69 = getelementptr inbounds double, double* %68, i64 0
%70 = load double, double* %69
%71 = fsub double %67, %70
store double %71, double* %64
%72 = getelementptr inbounds double, double* %64, i64 1
%73 = load double*, double** %10
%74 = getelementptr inbounds double, double* %73, i64 1
%75 = load double, double* %74
%76 = load double*, double** %11
%77 = getelementptr inbounds double, double* %76, i64 1
%78 = load double, double* %77
%79 = fsub double %75, %78
store double %79, double* %72
%80 = bitcast [2 x double]* %23 to i8*
%81 = getelementptr inbounds [2 x [2 x double]], [2 x [2 x double]]* %20, i64 0, i64 0
%82 = bitcast [2 x double]* %81 to double**
%83 = getelementptr inbounds [2 x double], [2 x double]* %22, i64 0, i64 0
%84 = getelementptr inbounds [2 x double], [2 x double]* %23, i64 0, i64 0
%85 = call i32 @mat221Multiply(double** %82, double* %83, double* %84)
%86 = load double, double* %21
%87 = fcmp une double %86, 0.000000e+00
br i1 %87, label %88, label %176
88: ; preds = %9
%89 = load double*, double** %15
%90 = getelementptr inbounds double, double* %89, i64 0
%91 = load double, double* %90
%92 = getelementptr inbounds [2 x double], [2 x double]* %23, i64 0, i64 0
%93 = load double, double* %92
%94 = load double*, double** %16
%95 = getelementptr inbounds double, double* %94, i64 0
%96 = load double, double* %95
%97 = load double*, double** %15
%98 = getelementptr inbounds double, double* %97, i64 0
%99 = load double, double* %98
%100 = fsub double %96, %99
%101 = call double @llvm.fmuladd.f64(double %93, double %100, double %91)
%102 = getelementptr inbounds [2 x double], [2 x double]* %23, i64 0, i64 1
%103 = load double, double* %102
%104 = load double*, double** %17
%105 = getelementptr inbounds double, double* %104, i64 0
%106 = load double, double* %105
%107 = load double*, double** %15
%108 = getelementptr inbounds double, double* %107, i64 0
%109 = load double, double* %108
%110 = fsub double %106, %109
%111 = call double @llvm.fmuladd.f64(double %103, double %110, double %101)
%112 = load double*, double** %14
%113 = getelementptr inbounds double, double* %112, i64 0
%114 = load double, double* %113
%115 = fmul double %111, %114
%116 = load double*, double** %18
%117 = getelementptr inbounds double, double* %116, i64 0
store double %115, double* %117
%118 = load double*, double** %15
%119 = getelementptr inbounds double, double* %118, i64 1
%120 = load double, double* %119
%121 = getelementptr inbounds [2 x double], [2 x double]* %23, i64 0, i64 0
%122 = load double, double* %121
%123 = load double*, double** %16
%124 = getelementptr inbounds double, double* %123, i64 1
%125 = load double, double* %124
%126 = load double*, double** %15
%127 = getelementptr inbounds double, double* %126, i64 1
%128 = load double, double* %127
%129 = fsub double %125, %128
%130 = call double @llvm.fmuladd.f64(double %122, double %129, double %120)
%131 = getelementptr inbounds [2 x double], [2 x double]* %23, i64 0, i64 1
%132 = load double, double* %131
%133 = load double*, double** %17
%134 = getelementptr inbounds double, double* %133, i64 1
%135 = load double, double* %134
%136 = load double*, double** %15
%137 = getelementptr inbounds double, double* %136, i64 1
%138 = load double, double* %137
%139 = fsub double %135, %138
%140 = call double @llvm.fmuladd.f64(double %132, double %139, double %130)
%141 = load double*, double** %14
%142 = getelementptr inbounds double, double* %141, i64 1
%143 = load double, double* %142
%144 = fmul double %140, %143
%145 = load double*, double** %18
%146 = getelementptr inbounds double, double* %145, i64 1
store double %144, double* %146
%147 = load double*, double** %15
%148 = getelementptr inbounds double, double* %147, i64 2
%149 = load double, double* %148
%150 = getelementptr inbounds [2 x double], [2 x double]* %23, i64 0, i64 0
%151 = load double, double* %150
%152 = load double*, double** %16
%153 = getelementptr inbounds double, double* %152, i64 2
%154 = load double, double* %153
%155 = load double*, double** %15
%156 = getelementptr inbounds double, double* %155, i64 2
%157 = load double, double* %156
%158 = fsub double %154, %157
%159 = call double @llvm.fmuladd.f64(double %151, double %158, double %149)
%160 = getelementptr inbounds [2 x double], [2 x double]* %23, i64 0, i64 1
%161 = load double, double* %160
%162 = load double*, double** %17
%163 = getelementptr inbounds double, double* %162, i64 2
%164 = load double, double* %163
%165 = load double*, double** %15
%166 = getelementptr inbounds double, double* %165, i64 2
%167 = load double, double* %166
%168 = fsub double %164, %167
%169 = call double @llvm.fmuladd.f64(double %161, double %168, double %159)
%170 = load double*, double** %14
%171 = getelementptr inbounds double, double* %170, i64 2
%172 = load double, double* %171
%173 = fmul double %169, %172
%174 = load double*, double** %18
%175 = getelementptr inbounds double, double* %174, i64 2
store double %173, double* %175
br label %178
176: ; preds = %9
%177 = call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
br label %178
178: ; preds = %176, %88
ret void
}

LLVM IR (-O2):
@str = [60 x i8] c"The matrix doesn't have an Inverse, something is wrong here\00"
define void @interpolating(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, double* nocapture %4, double* nocapture %5, double* nocapture %6, double* nocapture %7, double* nocapture writeonly %8) {
%10 = alloca [2 x [2 x double]]
%11 = alloca [2 x [2 x double]]
%12 = alloca <2 x double>
%13 = alloca [2 x double]
%14 = bitcast [2 x [2 x double]]* %10 to i8*
%15 = load double, double* %2
%16 = load double, double* %1
%17 = load double, double* %3
%18 = insertelement <2 x double> poison, double %15, i64 0
%19 = insertelement <2 x double> %18, double %17, i64 1
%20 = insertelement <2 x double> poison, double %16, i64 0
%21 = shufflevector <2 x double> %20, <2 x double> poison, <2 x i32> zeroinitializer
%22 = fsub <2 x double> %19, %21
%23 = bitcast [2 x [2 x double]]* %10 to <2 x double>*
store <2 x double> %22, <2 x double>* %23
%24 = getelementptr inbounds [2 x [2 x double]], [2 x [2 x double]]* %10, i64 0, i64 1, i64 0
%25 = getelementptr inbounds double, double* %2, i64 1
%26 = load double, double* %25
%27 = getelementptr inbounds double, double* %1, i64 1
%28 = load double, double* %27
%29 = getelementptr inbounds double, double* %3, i64 1
%30 = load double, double* %29
%31 = insertelement <2 x double> poison, double %26, i64 0
%32 = insertelement <2 x double> %31, double %30, i64 1
%33 = insertelement <2 x double> poison, double %28, i64 0
%34 = shufflevector <2 x double> %33, <2 x double> poison, <2 x i32> zeroinitializer
%35 = fsub <2 x double> %32, %34
%36 = bitcast double* %24 to <2 x double>*
store <2 x double> %35, <2 x double>* %36
%37 = bitcast [2 x [2 x double]]* %11 to i8*
%38 = bitcast [2 x [2 x double]]* %10 to double**
%39 = bitcast [2 x [2 x double]]* %11 to double**
%40 = call double @mat22Invert(double** %38, double** %39)
%41 = bitcast <2 x double>* %12 to i8*
%42 = getelementptr inbounds <2 x double>, <2 x double>* %12, i64 0, i64 0
%43 = bitcast double* %0 to <2 x double>*
%44 = load <2 x double>, <2 x double>* %43
%45 = bitcast double* %1 to <2 x double>*
%46 = load <2 x double>, <2 x double>* %45
%47 = fsub <2 x double> %44, %46
store <2 x double> %47, <2 x double>* %12
%48 = bitcast [2 x double]* %13 to i8*
%49 = getelementptr inbounds [2 x double], [2 x double]* %13, i64 0, i64 0
%50 = call i32 @mat221Multiply(double** %39, double* %42, double* %49)
%51 = fcmp une double %40, 0.000000e+00
br i1 %51, label %52, label %93
52: ; preds = %9
%53 = load double, double* %5
%54 = load double, double* %49
%55 = load double, double* %6
%56 = fsub double %55, %53
%57 = call double @llvm.fmuladd.f64(double %54, double %56, double %53)
%58 = getelementptr inbounds [2 x double], [2 x double]* %13, i64 0, i64 1
%59 = load double, double* %58
%60 = load double, double* %7
%61 = fsub double %60, %53
%62 = call double @llvm.fmuladd.f64(double %59, double %61, double %57)
%63 = load double, double* %4
%64 = fmul double %63, %62
store double %64, double* %8
%65 = getelementptr inbounds double, double* %5, i64 1
%66 = load double, double* %65
%67 = getelementptr inbounds double, double* %6, i64 1
%68 = load double, double* %67
%69 = fsub double %68, %66
%70 = call double @llvm.fmuladd.f64(double %54, double %69, double %66)
%71 = getelementptr inbounds double, double* %7, i64 1
%72 = load double, double* %71
%73 = fsub double %72, %66
%74 = call double @llvm.fmuladd.f64(double %59, double %73, double %70)
%75 = getelementptr inbounds double, double* %4, i64 1
%76 = load double, double* %75
%77 = fmul double %76, %74
%78 = getelementptr inbounds double, double* %8, i64 1
store double %77, double* %78
%79 = getelementptr inbounds double, double* %5, i64 2
%80 = load double, double* %79
%81 = getelementptr inbounds double, double* %6, i64 2
%82 = load double, double* %81
%83 = fsub double %82, %80
%84 = call double @llvm.fmuladd.f64(double %54, double %83, double %80)
%85 = getelementptr inbounds double, double* %7, i64 2
%86 = load double, double* %85
%87 = fsub double %86, %80
%88 = call double @llvm.fmuladd.f64(double %59, double %87, double %84)
%89 = getelementptr inbounds double, double* %4, i64 2
%90 = load double, double* %89
%91 = fmul double %90, %88
%92 = getelementptr inbounds double, double* %8, i64 2
store double %91, double* %92
br label %95
93: ; preds = %9
%94 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str, i64 0, i64 0))
br label %95
95: ; preds = %93, %52
ret void
}