// File: /workspace/github_cpp_makefile_star2_O1/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 0x47df8
xorl %ebp, %ebp
testl %eax, %eax
je 0x47de4
leaq 0x20(%r12), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4a10f
leaq 0x9df38(%rip), %rax     # 0xe5b98
movsd (%rax), %xmm1
movapd 0x5a3b4(%rip), %xmm2    # 0xa2020
xorpd %xmm1, %xmm2
ucomisd %xmm2, %xmm0
jb 0x47de4
ucomisd %xmm0, %xmm1
jb 0x47de4
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 0x3cc88
leaq 0x88(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x3b68c
movq %r12, %rdi
movq %rbx, %rsi
callq 0x4a10f
leaq 0x9dec2(%rip), %rax     # 0xe5b98
movsd (%rax), %xmm1
xorpd 0x5a33e(%rip), %xmm1    # 0xa2020
xorl %ebp, %ebp
ucomisd %xmm0, %xmm1
ja 0x47de4
leaq 0x30(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x3cc88
leaq 0x50(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0x3b68c
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x4a10f
leaq 0x9de6f(%rip), %rax     # 0xe5b98
movsd (%rax), %xmm1
xorpd 0x5a2eb(%rip), %xmm1    # 0xa2020
xorl %ebp, %ebp
ucomisd %xmm0, %xmm1
ja 0x47de4
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq 0x8(%rsp), %r12
movq %r12, %rsi
movq %r13, %rdx
callq 0x3cc88
leaq 0x30(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x3b68c
movq %r13, %rdi
movq %rbx, %rsi
callq 0x4a10f
leaq 0x9de17(%rip), %rax     # 0xe5b98
movsd (%rax), %xmm1
xorpd 0x5a293(%rip), %xmm1    # 0xa2020
xorl %ebp, %ebp
ucomisd %xmm0, %xmm1
ja 0x47de4
leaq 0x70(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rax, %r12
callq 0x3cc88
leaq 0x10(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x3b68c
movq %r13, %rdi
movq %rbx, %rsi
callq 0x4a10f
movsd (%r12), %xmm1
xorpd 0x5a246(%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