// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Shapes/R3Polyline.cpp
// Function: gaps::R3Polyline::IsPlanar() const
const RNBoolean R3Polyline::
IsPlanar(void) const
{
  // Return whether spline lies on one line
  if (nvertices == 0) return FALSE;
  if (nvertices <= 3) return TRUE;

  // Check if vertices all line on same plane
  R3Plane plane;
  int plane_npositions = 0;
  R3Point plane_positions[3];
  for (int i = 0; i < nvertices; i++) {
    if (plane_npositions == 0) {
      plane_positions[plane_npositions++] = vertex_positions[i];
    }
    else if ((plane_npositions == 1) &&
             !R3Contains(plane_positions[0], vertex_positions[i])) {
      plane_positions[plane_npositions++] = vertex_positions[i];
    }
    else if ((plane_npositions == 2) &&
             !R3Contains(plane_positions[0], vertex_positions[i]) &&
             !R3Contains(plane_positions[1], vertex_positions[i])) {
      plane_positions[plane_npositions++] = vertex_positions[i];
      R3Vector v1 = plane_positions[1] - plane_positions[0];
      R3Vector v2 = plane_positions[2] - plane_positions[0];
      R3Vector normal = v1 % v2; normal.Normalize();
      plane.Reset(plane_positions[0], normal);
    }
    else if (!R3Contains(plane, vertex_positions[i])) {
      return FALSE;
    }
  }

  // All vertices are on same plane
  return TRUE;
}

// Assembly:
movl 0x20(%rdi), %ecx
testl %ecx, %ecx
je 0x5046d
movl $0x1, %eax
cmpl $0x4, %ecx
jl 0x50488
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %rbx
movq %rsp, %rdi
callq 0x3b514
xorl %r14d, %r14d
leaq (%rsp,%r14), %rdi
addq $0x20, %rdi
callq 0x3ca24
addq $0x18, %r14
cmpq $0x48, %r14
jne 0x50310
cmpl $0x0, 0x20(%rbx)
setle %r14b
jle 0x50470
xorl %ebp, %ebp
leaq 0x20(%rsp), %r12
xorl %r15d, %r15d
xorl %r13d, %r13d
cmpl $0x2, %r13d
je 0x50383
cmpl $0x1, %r13d
je 0x5036a
testl %r13d, %r13d
jne 0x503ab
movq 0x8(%rbx), %rsi
addq %rbp, %rsi
movq %r12, %rdi
callq 0x3cd94
movl $0x1, %r13d
jmp 0x503c2
movq 0x8(%rbx), %rsi
addq %rbp, %rsi
movq %r12, %rdi
callq 0x46e1b
testl %eax, %eax
je 0x503df
cmpl $0x2, %r13d
jne 0x503ab
movq 0x8(%rbx), %rsi
addq %rbp, %rsi
movq %r12, %rdi
callq 0x46e1b
testl %eax, %eax
jne 0x503ab
movq 0x8(%rbx), %rsi
addq %rbp, %rsi
leaq 0x38(%rsp), %rdi
callq 0x46e1b
testl %eax, %eax
je 0x503f8
movq 0x8(%rbx), %rsi
addq %rbp, %rsi
movq %rsp, %rdi
callq 0x47841
testl %eax, %eax
je 0x50470
incq %r15
movslq 0x20(%rbx), %rax
addq $0x18, %rbp
cmpq %rax, %r15
setge %r14b
jl 0x50342
jmp 0x50470
movq 0x8(%rbx), %rsi
addq %rbp, %rsi
leaq 0x38(%rsp), %rdi
callq 0x3cd94
movl $0x2, %r13d
jmp 0x503c2
movq 0x8(%rbx), %rsi
addq %rbp, %rsi
leaq 0x50(%rsp), %r14
movq %r14, %rdi
callq 0x3cd94
leaq 0x70(%rsp), %rdi
leaq 0x38(%rsp), %rsi
movq %r12, %rdx
callq 0x3cc88
leaq 0xa0(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x3cc88
leaq 0x88(%rsp), %r14
movq %r14, %rdi
leaq 0x70(%rsp), %rsi
movq %r13, %rdx
callq 0x3de12
movq %r14, %rdi
callq 0x3d7e0
movq %rsp, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x3bd7a
movl $0x3, %r13d
jmp 0x503c2
xorl %eax, %eax
retq
movzbl %r14b, %eax
andl $0x1, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop