#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 getSTcoordinates(double x[2], double a[2], double b[2], double c[2],
                      double rgb[3], double alpha[2], double beta[2],
                      double gamma[2], double coordinates[2]) {
  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) {
    coordinates[0] =
        alpha[0] + pq[0] * (beta[0] - alpha[0]) + pq[1] * (gamma[0] - alpha[0]);
    coordinates[1] =
        alpha[1] + pq[0] * (beta[1] - alpha[1]) + pq[1] * (gamma[1] - alpha[1]);
  } else {
    printf("The matrix doesn't have an Inverse, something is wrong here\n");
  }
}


x86 assembly (clang, -O0):
<getSTcoordinates>:
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 <getSTcoordinates+0x122>
jp     1262 <getSTcoordinates+0x122>
jmp    130d <getSTcoordinates+0x1cd>
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    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    0x20(%rbp),%rax
movsd  %xmm0,0x8(%rax)
jmp    1319 <getSTcoordinates+0x1d9>
lea    0xcec(%rip),%rdi
call   1030 <printf@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getSTcoordinates>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x78,%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,%r14
mov    %rdi,%r15
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),%r12
mov    %r12,%rsi
call   1050 <mat22Invert@plt>
movsd  %xmm0,0x18(%rsp)
movupd (%r15),%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    %r12,%rdi
call   1040 <mat221Multiply@plt>
xorpd  %xmm0,%xmm0
movsd  0x18(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jne    11e1 <getSTcoordinates+0xb1>
jnp    125c <getSTcoordinates+0x12c>
mov    0xb0(%rsp),%rax
mov    0xa8(%rsp),%rcx
mov    0xa0(%rsp),%rdx
movsd  (%r14),%xmm0
movsd  (%rdx),%xmm1
subsd  %xmm0,%xmm1
movsd  (%rsp),%xmm2
movsd  0x8(%rsp),%xmm3
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  (%rcx),%xmm4
subsd  %xmm0,%xmm4
mulsd  %xmm3,%xmm4
addsd  %xmm1,%xmm4
movsd  %xmm4,(%rax)
movsd  0x8(%r14),%xmm0
movsd  0x8(%rdx),%xmm1
subsd  %xmm0,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0x8(%rcx),%xmm2
subsd  %xmm0,%xmm2
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rax)
jmp    1268 <getSTcoordinates+0x138>
lea    0xdad(%rip),%rdi
call   1030 <puts@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r12
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 @getSTcoordinates(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 %139
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** %18
%113 = getelementptr inbounds double, double* %112, i64 0
store double %111, double* %113
%114 = load double*, double** %15
%115 = getelementptr inbounds double, double* %114, i64 1
%116 = load double, double* %115
%117 = getelementptr inbounds [2 x double], [2 x double]* %23, i64 0, i64 0
%118 = load double, double* %117
%119 = load double*, double** %16
%120 = getelementptr inbounds double, double* %119, i64 1
%121 = load double, double* %120
%122 = load double*, double** %15
%123 = getelementptr inbounds double, double* %122, i64 1
%124 = load double, double* %123
%125 = fsub double %121, %124
%126 = call double @llvm.fmuladd.f64(double %118, double %125, double %116)
%127 = getelementptr inbounds [2 x double], [2 x double]* %23, i64 0, i64 1
%128 = load double, double* %127
%129 = load double*, double** %17
%130 = getelementptr inbounds double, double* %129, i64 1
%131 = load double, double* %130
%132 = load double*, double** %15
%133 = getelementptr inbounds double, double* %132, i64 1
%134 = load double, double* %133
%135 = fsub double %131, %134
%136 = call double @llvm.fmuladd.f64(double %128, double %135, double %126)
%137 = load double*, double** %18
%138 = getelementptr inbounds double, double* %137, i64 1
store double %136, double* %138
br label %141
139: ; preds = %9
%140 = call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
br label %141
141: ; preds = %139, %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 @getSTcoordinates(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, double* nocapture readnone %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 %74
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)
store double %62, double* %8
%63 = getelementptr inbounds double, double* %5, i64 1
%64 = load double, double* %63
%65 = getelementptr inbounds double, double* %6, i64 1
%66 = load double, double* %65
%67 = fsub double %66, %64
%68 = call double @llvm.fmuladd.f64(double %54, double %67, double %64)
%69 = getelementptr inbounds double, double* %7, i64 1
%70 = load double, double* %69
%71 = fsub double %70, %64
%72 = call double @llvm.fmuladd.f64(double %59, double %71, double %68)
%73 = getelementptr inbounds double, double* %8, i64 1
store double %72, double* %73
br label %76
74: ; preds = %9
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str, i64 0, i64 0))
br label %76
76: ; preds = %74, %52
ret void
}