// File: /workspace/github_cpp_makefile_star2_O3/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 0x47508
xorl %ebp, %ebp
testl %eax, %eax
je 0x474f4
leaq 0x20(%r12), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x49617
leaq 0x9e828(%rip), %rax     # 0xe5b98
movsd (%rax), %xmm1
movapd 0x5aca4(%rip), %xmm2    # 0xa2020
xorpd %xmm1, %xmm2
ucomisd %xmm2, %xmm0
jb 0x474f4
ucomisd %xmm0, %xmm1
jb 0x474f4
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 0x3c78e
leaq 0x88(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x3b198
movq %r12, %rdi
movq %rbx, %rsi
callq 0x49617
leaq 0x9e7b2(%rip), %rax     # 0xe5b98
movsd (%rax), %xmm1
xorpd 0x5ac2e(%rip), %xmm1    # 0xa2020
xorl %ebp, %ebp
ucomisd %xmm0, %xmm1
ja 0x474f4
leaq 0x30(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x3c78e
leaq 0x50(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0x3b198
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x49617
leaq 0x9e75f(%rip), %rax     # 0xe5b98
movsd (%rax), %xmm1
xorpd 0x5abdb(%rip), %xmm1    # 0xa2020
xorl %ebp, %ebp
ucomisd %xmm0, %xmm1
ja 0x474f4
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq 0x8(%rsp), %r12
movq %r12, %rsi
movq %r13, %rdx
callq 0x3c78e
leaq 0x30(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x3b198
movq %r13, %rdi
movq %rbx, %rsi
callq 0x49617
leaq 0x9e707(%rip), %rax     # 0xe5b98
movsd (%rax), %xmm1
xorpd 0x5ab83(%rip), %xmm1    # 0xa2020
xorl %ebp, %ebp
ucomisd %xmm0, %xmm1
ja 0x474f4
leaq 0x70(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rax, %r12
callq 0x3c78e
leaq 0x10(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x3b198
movq %r13, %rdi
movq %rbx, %rsi
callq 0x49617
movsd (%r12), %xmm1
xorpd 0x5ab36(%rip), %xmm1    # 0xa2020
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