// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Cont.cpp
// Function: gaps::R3Contains(gaps::R3Triangle const&, gaps::R3Point const&)
RNBoolean R3Contains(const R3Triangle& triangle, const R3Point& point)
{
    // Check whether triangle bounding shape contains point
    if (!R3Contains(triangle.Box(), point)) return FALSE;
  
    // Check whether triangle plane contains point
    if (!R3Contains(triangle.Plane(), point)) return FALSE;
  
    // Compute whether point is on correct side of each edge
    const R3Point& p0 = triangle.Vertex(0)->Position();
    const R3Point& p1 = triangle.Vertex(1)->Position();
    const R3Point& p2 = triangle.Vertex(2)->Position();
    R3Plane h01(p1, triangle.Normal(), p1 - p0);
    if (RNIsNegative(R3SignedDistance(h01, point))) return FALSE;
    R3Plane plane01(p1, triangle.Normal(), p1 - p0);
    if (RNIsNegative(R3SignedDistance(plane01, point))) return FALSE;
    R3Plane plane12(p2, triangle.Normal(), p2 - p1);
    if (RNIsNegative(R3SignedDistance(plane12, point))) return FALSE;
    R3Plane plane20(p0, triangle.Normal(), p0 - p2);
    if (RNIsNegative(R3SignedDistance(plane20, point))) return FALSE;
  
    // Triangle contains point
    return TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %rbx
movq %rdi, %r12
addq $0x40, %rdi
callq 0x419e0
xorl %ebp, %ebp
testl %eax, %eax
je 0x419cc
leaq 0x20(%r12), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x415ce
testl %eax, %eax
je 0x419cc
movq 0x8(%r12), %r15
movq 0x10(%r12), %r13
movq 0x18(%r12), %rax
movq %rax, 0x8(%rsp)
leaq 0x50(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x37d29
leaq 0x88(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x36892
movq %r12, %rdi
movq %rbx, %rsi
callq 0x43420
leaq 0x992ea(%rip), %rax     # 0xdaba8
movsd (%rax), %xmm1
xorpd 0x51766(%rip), %xmm1    # 0x93030
xorl %ebp, %ebp
ucomisd %xmm0, %xmm1
ja 0x419cc
leaq 0x30(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x37d29
leaq 0x50(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0x36892
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x43420
leaq 0x99297(%rip), %rax     # 0xdaba8
movsd (%rax), %xmm1
xorpd 0x51713(%rip), %xmm1    # 0x93030
xorl %ebp, %ebp
ucomisd %xmm0, %xmm1
ja 0x419cc
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq 0x8(%rsp), %r12
movq %r12, %rsi
movq %r13, %rdx
callq 0x37d29
leaq 0x30(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x36892
movq %r13, %rdi
movq %rbx, %rsi
callq 0x43420
leaq 0x9923f(%rip), %rax     # 0xdaba8
movsd (%rax), %xmm1
xorpd 0x516bb(%rip), %xmm1    # 0x93030
xorl %ebp, %ebp
ucomisd %xmm0, %xmm1
ja 0x419cc
leaq 0x70(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rax, %r12
callq 0x37d29
leaq 0x10(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x36892
movq %r13, %rdi
movq %rbx, %rsi
callq 0x43420
movsd (%r12), %xmm1
xorpd 0x5166e(%rip), %xmm1    # 0x93030
xorl %ebp, %ebp
ucomisd %xmm0, %xmm1
setbe %bpl
movl %ebp, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq