#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 */
float glmDotProduct3f(float *, float *);
int /*<<< orphan*/ glmMakeVector3f(float *, float const *, float const *);
void glmComputeBarycentricCoordinates3f(float result[3], const float v1[3],
                                        const float v2[3], const float v3[3],
                                        const float p[3]) {
  float a, b, c, u, v, D;
  float tv1[3], tv2[3], tv3[3];
  glmMakeVector3f(tv1, v3, v1);
  glmMakeVector3f(tv2, v3, v2);
  a = glmDotProduct3f(tv1, tv1);
  b = glmDotProduct3f(tv2, tv1);
  c = glmDotProduct3f(tv2, tv2);
  glmMakeVector3f(tv3, v3, p);
  u = glmDotProduct3f(tv3, tv1);
  v = glmDotProduct3f(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):
<glmComputeBarycentricCoordinates3f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
lea    -0x4c(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <glmMakeVector3f@plt>
lea    -0x58(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <glmMakeVector3f@plt>
lea    -0x4c(%rbp),%rdi
lea    -0x4c(%rbp),%rsi
call   1040 <glmDotProduct3f@plt>
movss  %xmm0,-0x2c(%rbp)
lea    -0x58(%rbp),%rdi
lea    -0x4c(%rbp),%rsi
call   1040 <glmDotProduct3f@plt>
movss  %xmm0,-0x30(%rbp)
lea    -0x58(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   1040 <glmDotProduct3f@plt>
movss  %xmm0,-0x34(%rbp)
lea    -0x64(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <glmMakeVector3f@plt>
lea    -0x64(%rbp),%rdi
lea    -0x4c(%rbp),%rsi
call   1040 <glmDotProduct3f@plt>
movss  %xmm0,-0x38(%rbp)
lea    -0x64(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   1040 <glmDotProduct3f@plt>
movss  %xmm0,-0x3c(%rbp)
movss  -0x2c(%rbp),%xmm0
movss  -0x34(%rbp),%xmm2
movss  -0x30(%rbp),%xmm1
mulss  -0x30(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x40(%rbp)
movss  -0x40(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1236 <glmComputeBarycentricCoordinates3f+0x116>
jp     1236 <glmComputeBarycentricCoordinates3f+0x116>
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rax)
jmp    12e3 <glmComputeBarycentricCoordinates3f+0x1c3>
movss  -0x40(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xdc1(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x40(%rbp)
movss  -0x34(%rbp),%xmm0
movss  -0x38(%rbp),%xmm2
movss  -0x30(%rbp),%xmm1
mulss  -0x3c(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mulss  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x30(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  -0x38(%rbp),%xmm2
movss  -0x2c(%rbp),%xmm1
mulss  -0x3c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mulss  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
movss  0xd33(%rip),%xmm0
subss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
subss  0x4(%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glmComputeBarycentricCoordinates3f>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r8,%r15
mov    %rcx,%rbx
mov    %rdx,%rbp
mov    %rsi,%rdx
mov    %rdi,%r14
lea    0x5c(%rsp),%r12
mov    %r12,%rdi
mov    %rcx,%rsi
call   1030 <glmMakeVector3f@plt>
lea    0x50(%rsp),%r13
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1030 <glmMakeVector3f@plt>
mov    %r12,%rdi
mov    %r12,%rsi
call   1040 <glmDotProduct3f@plt>
movaps %xmm0,0x30(%rsp)
mov    %r13,%rdi
mov    %r12,%rsi
call   1040 <glmDotProduct3f@plt>
movaps %xmm0,0x20(%rsp)
mov    %r13,%rdi
mov    %r13,%rsi
call   1040 <glmDotProduct3f@plt>
movaps %xmm0,0x10(%rsp)
lea    0x44(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1030 <glmMakeVector3f@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1040 <glmDotProduct3f@plt>
movaps %xmm0,(%rsp)
mov    %rbp,%rdi
mov    %r13,%rsi
call   1040 <glmDotProduct3f@plt>
movaps 0x10(%rsp),%xmm6
movaps 0x30(%rsp),%xmm5
movaps 0x20(%rsp),%xmm4
movaps %xmm4,%xmm1
mulss  %xmm4,%xmm1
movaps %xmm5,%xmm3
mulss  %xmm6,%xmm3
subss  %xmm1,%xmm3
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm3
jne    11f4 <glmComputeBarycentricCoordinates3f+0xd4>
jp     11f4 <glmComputeBarycentricCoordinates3f+0xd4>
movl   $0x0,(%r14)
xorps  %xmm2,%xmm2
jmp    123d <glmComputeBarycentricCoordinates3f+0x11d>
xorps  0xe05(%rip),%xmm4
movss  0xe0d(%rip),%xmm2
movaps %xmm2,%xmm1
divss  %xmm3,%xmm1
shufps $0x0,%xmm0,%xmm0
unpcklps %xmm4,%xmm6
unpcklps %xmm5,%xmm4
mulps  %xmm0,%xmm4
movaps (%rsp),%xmm0
shufps $0x0,%xmm0,%xmm0
mulps  %xmm6,%xmm0
addps  %xmm4,%xmm0
shufps $0x0,%xmm1,%xmm1
mulps  %xmm0,%xmm1
movss  %xmm1,(%r14)
subss  %xmm1,%xmm2
shufps $0x55,%xmm1,%xmm1
subss  %xmm1,%xmm2
movss  %xmm1,0x4(%r14)
movss  %xmm2,0x8(%r14)
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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