#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 */
double glmDotProduct3d(double *, double *);
int /*<<< orphan*/ glmMakeVector3d(double *, double const *, double const *);
void glmComputeBarycentricCoordinates3d(double result[3], const double v1[3],
                                        const double v2[3], const double v3[3],
                                        const double p[3]) {
  double a, b, c, u, v, D;
  double tv1[3], tv2[3], tv3[3];
  glmMakeVector3d(tv1, v3, v1);
  glmMakeVector3d(tv2, v3, v2);
  a = glmDotProduct3d(tv1, tv1);
  b = glmDotProduct3d(tv2, tv1);
  c = glmDotProduct3d(tv2, tv2);
  glmMakeVector3d(tv3, v3, p);
  u = glmDotProduct3d(tv3, tv1);
  v = glmDotProduct3d(tv3, tv2);
  D = a * c - b * b;
  if (D == 0) {
    result[0] = 0;
    result[1] = 0;
    result[2] = 0;
    return;
  }
  D = 1.0 / D;
  result[0] = (c * u - b * v) * D;
  result[1] = (-b * u + a * v) * D;
  result[2] = 1 - result[0] - result[1];
}


x86 assembly (clang, -O0):
<glmComputeBarycentricCoordinates3d>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <glmMakeVector3d@plt>
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <glmMakeVector3d@plt>
lea    -0x70(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1040 <glmDotProduct3d@plt>
movsd  %xmm0,-0x30(%rbp)
lea    -0x90(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1040 <glmDotProduct3d@plt>
movsd  %xmm0,-0x38(%rbp)
lea    -0x90(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1040 <glmDotProduct3d@plt>
movsd  %xmm0,-0x40(%rbp)
lea    -0xb0(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <glmMakeVector3d@plt>
lea    -0xb0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1040 <glmDotProduct3d@plt>
movsd  %xmm0,-0x48(%rbp)
lea    -0xb0(%rbp),%rdi
lea    -0x90(%rbp),%rsi
call   1040 <glmDotProduct3d@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x38(%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  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    125c <glmComputeBarycentricCoordinates3d+0x13c>
jp     125c <glmComputeBarycentricCoordinates3d+0x13c>
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x10(%rax)
jmp    1311 <glmComputeBarycentricCoordinates3d+0x1f1>
movsd  0xd9c(%rip),%xmm0
divsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  -0x58(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  -0x58(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0xd05(%rip),%xmm0
subsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glmComputeBarycentricCoordinates3d>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %r8,%r15
mov    %rcx,%rbx
mov    %rdx,%rbp
mov    %rsi,%rdx
mov    %rdi,%r14
lea    0x80(%rsp),%r12
mov    %r12,%rdi
mov    %rcx,%rsi
call   1030 <glmMakeVector3d@plt>
lea    0x60(%rsp),%r13
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1030 <glmMakeVector3d@plt>
mov    %r12,%rdi
mov    %r12,%rsi
call   1040 <glmDotProduct3d@plt>
movapd %xmm0,0x30(%rsp)
mov    %r13,%rdi
mov    %r12,%rsi
call   1040 <glmDotProduct3d@plt>
movapd %xmm0,0x20(%rsp)
mov    %r13,%rdi
mov    %r13,%rsi
call   1040 <glmDotProduct3d@plt>
movapd %xmm0,0x10(%rsp)
lea    0x40(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1030 <glmMakeVector3d@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1040 <glmDotProduct3d@plt>
movapd %xmm0,(%rsp)
mov    %rbp,%rdi
mov    %r13,%rsi
call   1040 <glmDotProduct3d@plt>
movapd 0x10(%rsp),%xmm6
movapd 0x30(%rsp),%xmm5
movapd 0x20(%rsp),%xmm4
movapd %xmm4,%xmm1
mulsd  %xmm4,%xmm1
movapd %xmm5,%xmm3
mulsd  %xmm6,%xmm3
subsd  %xmm1,%xmm3
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm3
jne    1206 <glmComputeBarycentricCoordinates3d+0xe6>
jp     1206 <glmComputeBarycentricCoordinates3d+0xe6>
movq   $0x0,(%r14)
xorpd  %xmm2,%xmm2
jmp    1258 <glmComputeBarycentricCoordinates3d+0x138>
xorpd  0xdf2(%rip),%xmm4
movsd  0xdfa(%rip),%xmm2
movapd %xmm2,%xmm1
divsd  %xmm3,%xmm1
unpcklpd %xmm0,%xmm0
unpcklpd %xmm4,%xmm6
unpcklpd %xmm5,%xmm4
mulpd  %xmm0,%xmm4
movapd (%rsp),%xmm0
unpcklpd %xmm0,%xmm0
mulpd  %xmm6,%xmm0
addpd  %xmm4,%xmm0
unpcklpd %xmm1,%xmm1
mulpd  %xmm0,%xmm1
movlpd %xmm1,(%r14)
subsd  %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
subsd  %xmm1,%xmm2
movsd  %xmm1,0x8(%r14)
movsd  %xmm2,0x10(%r14)
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @glmComputeBarycentricCoordinates3d(double* %0, double* %1, double* %2, double* %3, double* %4) {
%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 [3 x double]
%18 = alloca [3 x double]
%19 = alloca [3 x double]
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
store double* %4, double** %10
%20 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 0
%21 = load double*, double** %9
%22 = load double*, double** %7
%23 = call i32 @glmMakeVector3d(double* %20, double* %21, double* %22)
%24 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 0
%25 = load double*, double** %9
%26 = load double*, double** %8
%27 = call i32 @glmMakeVector3d(double* %24, double* %25, double* %26)
%28 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 0
%29 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 0
%30 = call double @glmDotProduct3d(double* %28, double* %29)
store double %30, double* %11
%31 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 0
%32 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 0
%33 = call double @glmDotProduct3d(double* %31, double* %32)
store double %33, double* %12
%34 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 0
%35 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 0
%36 = call double @glmDotProduct3d(double* %34, double* %35)
store double %36, double* %13
%37 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 0, i64 0
%38 = load double*, double** %9
%39 = load double*, double** %10
%40 = call i32 @glmMakeVector3d(double* %37, double* %38, double* %39)
%41 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 0, i64 0
%42 = getelementptr inbounds [3 x double], [3 x double]* %17, i64 0, i64 0
%43 = call double @glmDotProduct3d(double* %41, double* %42)
store double %43, double* %14
%44 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 0, i64 0
%45 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 0
%46 = call double @glmDotProduct3d(double* %44, double* %45)
store double %46, double* %15
%47 = load double, double* %11
%48 = load double, double* %13
%49 = load double, double* %12
%50 = load double, double* %12
%51 = fmul double %49, %50
%52 = fneg double %51
%53 = call double @llvm.fmuladd.f64(double %47, double %48, double %52)
store double %53, double* %16
%54 = load double, double* %16
%55 = fcmp oeq double %54, 0.000000e+00
br i1 %55, label %56, label %63
56: ; preds = %5
%57 = load double*, double** %6
%58 = getelementptr inbounds double, double* %57, i64 0
store double 0.000000e+00, double* %58
%59 = load double*, double** %6
%60 = getelementptr inbounds double, double* %59, i64 1
store double 0.000000e+00, double* %60
%61 = load double*, double** %6
%62 = getelementptr inbounds double, double* %61, i64 2
store double 0.000000e+00, double* %62
br label %98
63: ; preds = %5
%64 = load double, double* %16
%65 = fdiv double 1.000000e+00, %64
store double %65, double* %16
%66 = load double, double* %13
%67 = load double, double* %14
%68 = load double, double* %12
%69 = load double, double* %15
%70 = fmul double %68, %69
%71 = fneg double %70
%72 = call double @llvm.fmuladd.f64(double %66, double %67, double %71)
%73 = load double, double* %16
%74 = fmul double %72, %73
%75 = load double*, double** %6
%76 = getelementptr inbounds double, double* %75, i64 0
store double %74, double* %76
%77 = load double, double* %12
%78 = fneg double %77
%79 = load double, double* %14
%80 = load double, double* %11
%81 = load double, double* %15
%82 = fmul double %80, %81
%83 = call double @llvm.fmuladd.f64(double %78, double %79, double %82)
%84 = load double, double* %16
%85 = fmul double %83, %84
%86 = load double*, double** %6
%87 = getelementptr inbounds double, double* %86, i64 1
store double %85, double* %87
%88 = load double*, double** %6
%89 = getelementptr inbounds double, double* %88, i64 0
%90 = load double, double* %89
%91 = fsub double 1.000000e+00, %90
%92 = load double*, double** %6
%93 = getelementptr inbounds double, double* %92, i64 1
%94 = load double, double* %93
%95 = fsub double %91, %94
%96 = load double*, double** %6
%97 = getelementptr inbounds double, double* %96, i64 2
store double %95, double* %97
br label %98
98: ; preds = %63, %56
ret void
}

LLVM IR (-O2):
define void @glmComputeBarycentricCoordinates3d(double* nocapture %0, double* %1, double* %2, double* %3, double* %4) {
%6 = alloca [3 x double]
%7 = alloca [3 x double]
%8 = alloca [3 x double]
%9 = bitcast [3 x double]* %6 to i8*
%10 = bitcast [3 x double]* %7 to i8*
%11 = bitcast [3 x double]* %8 to i8*
%12 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%13 = call i32 @glmMakeVector3d(double* %12, double* %3, double* %1)
%14 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%15 = call i32 @glmMakeVector3d(double* %14, double* %3, double* %2)
%16 = call double @glmDotProduct3d(double* %12, double* %12)
%17 = call double @glmDotProduct3d(double* %14, double* %12)
%18 = call double @glmDotProduct3d(double* %14, double* %14)
%19 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%20 = call i32 @glmMakeVector3d(double* %19, double* %3, double* %4)
%21 = call double @glmDotProduct3d(double* %19, double* %12)
%22 = call double @glmDotProduct3d(double* %19, double* %14)
%23 = fneg double %17
%24 = fmul double %17, %23
%25 = call double @llvm.fmuladd.f64(double %16, double %18, double %24)
%26 = fcmp oeq double %25, 0.000000e+00
br i1 %26, label %27, label %28
27: ; preds = %5
store double 0.000000e+00, double* %0
br label %47
28: ; preds = %5
%29 = fdiv double 1.000000e+00, %25
%30 = insertelement <2 x double> poison, double %22, i64 0
%31 = shufflevector <2 x double> %30, <2 x double> poison, <2 x i32> zeroinitializer
%32 = insertelement <2 x double> poison, double %23, i64 0
%33 = insertelement <2 x double> %32, double %16, i64 1
%34 = fmul <2 x double> %31, %33
%35 = insertelement <2 x double> poison, double %18, i64 0
%36 = insertelement <2 x double> %35, double %23, i64 1
%37 = insertelement <2 x double> poison, double %21, i64 0
%38 = shufflevector <2 x double> %37, <2 x double> poison, <2 x i32> zeroinitializer
%39 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %36, <2 x double> %38, <2 x double> %34)
%40 = insertelement <2 x double> poison, double %29, i64 0
%41 = shufflevector <2 x double> %40, <2 x double> poison, <2 x i32> zeroinitializer
%42 = fmul <2 x double> %41, %39
%43 = extractelement <2 x double> %42, i64 0
store double %43, double* %0
%44 = fsub double 1.000000e+00, %43
%45 = extractelement <2 x double> %42, i64 1
%46 = fsub double %44, %45
br label %47
47: ; preds = %28, %27
%48 = phi double [ 0.000000e+00, %27 ], [ %45, %28 ]
%49 = phi double [ 0.000000e+00, %27 ], [ %46, %28 ]
%50 = getelementptr inbounds double, double* %0, i64 1
store double %48, double* %50
%51 = getelementptr inbounds double, double* %0, i64 2
store double %49, double* %51
ret void
}