// File: /workspace/github_cpp_makefile_star2_O1/hzeller[P]gcode-multi-shell-extrude/third_party/clipper.cpp
// Function: ClipperLib::Clipper::FixupOutPolygon(ClipperLib::OutRec&)
void Clipper::FixupOutPolygon(OutRec &outrec)
{
  //FixupOutPolygon() - removes duplicate points and simplifies consecutive
  //parallel edges by removing the middle vertex.
  OutPt *lastOK = 0;
  outrec.BottomPt = 0;
  OutPt *pp = outrec.Pts;

  for (;;)
  {
    if (pp->Prev == pp || pp->Prev == pp->Next )
    {
      DisposeOutPts(pp);
      outrec.Pts = 0;
      return;
    }

    //test for duplicate points and collinear edges ...
    if ((pp->Pt == pp->Next->Pt) || (pp->Pt == pp->Prev->Pt) || 
      (SlopesEqual(pp->Prev->Pt, pp->Pt, pp->Next->Pt, m_UseFullRange) &&
      (!m_PreserveCollinear || 
      !Pt2IsBetweenPt1AndPt3(pp->Prev->Pt, pp->Pt, pp->Next->Pt))))
    {
      lastOK = 0;
      OutPt *tmp = pp;
      pp->Prev->Next = pp->Next;
      pp->Next->Prev = pp->Prev;
      pp = pp->Prev;
      delete tmp;
    }
    else if (pp == lastOK) break;
    else
    {
      if (!lastOK) lastOK = pp;
      pp = pp->Next;
    }
  }
  outrec.Pts = pp;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, 0x30(%rsp)
movq $0x0, 0x20(%rsi)
movq %rsi, 0x10(%rsp)
movq 0x18(%rsi), %r14
movq %r14, 0x38(%rsp)
movq 0x20(%r14), %rbx
cmpq %r14, %rbx
je 0xbcd1
leaq 0x20(%r14), %rbp
xorl %r8d, %r8d
movq 0x18(%r14), %r15
cmpq %r15, %rbx
je 0xbcd1
movq 0x8(%r14), %r12
movq 0x10(%r14), %rax
movq 0x8(%r15), %r13
cmpq %r13, %r12
jne 0xbb83
cmpq 0x10(%r15), %rax
je 0xbb92
movq 0x8(%rbx), %rdi
cmpq %rdi, %r12
jne 0xbbcc
cmpq 0x10(%rbx), %rax
jne 0xbbcc
movq %r15, 0x18(%rbx)
movq 0x18(%r14), %rax
movq %rbx, 0x20(%rax)
movq (%rbp), %r15
testq %r14, %r14
je 0xbbb4
movl $0x28, %esi
movq %r14, %rdi
callq 0x3220
xorl %r8d, %r8d
leaq 0x20(%r15), %rbp
movq 0x20(%r15), %rbx
movq %r15, %r14
cmpq %r15, %rbx
jne 0xbb5f
jmp 0xbcd4
movq 0x10(%rbx), %rsi
movq 0x10(%r14), %rcx
movq 0x10(%r15), %r9
movq 0x30(%rsp), %rdx
movq (%rdx), %rax
movq -0x18(%rax), %rax
movq %rax, 0x40(%rsp)
movzbl 0x18(%rdx,%rax), %eax
movl %eax, (%rsp)
movq %rsi, 0x20(%rsp)
movq %r12, %rdx
movq %rcx, 0x28(%rsp)
movq %r8, 0x50(%rsp)
movq %r13, %r8
movq %rdi, 0x48(%rsp)
movq %r9, 0x18(%rsp)
callq 0x8d2a
movq 0x48(%rsp), %r9
movq 0x50(%rsp), %r8
testb %al, %al
je 0xbcc0
movq 0x30(%rsp), %rax
movq 0x40(%rsp), %rcx
cmpb $0x1, 0x38(%rax,%rcx)
jne 0xbb92
movq %r12, %rax
xorq %r9, %rax
movq %r12, %rcx
xorq %r13, %rcx
movq %r9, %rdx
xorq %r13, %rdx
movq 0x20(%rsp), %rdi
movq %rdi, %rsi
movq 0x18(%rsp), %r11
xorq %r11, %rsi
movq 0x28(%rsp), %r10
xorq %r10, %rdi
orq %rax, %rdi
sete %al
movq %r11, %rdi
xorq %r10, %rdi
orq %rcx, %rdi
sete %cl
orq %rdx, %rsi
je 0xbb92
testb %al, %al
jne 0xbb92
testb %cl, %cl
jne 0xbb92
cmpq %r13, %r9
jne 0xbcaa
movq 0x28(%rsp), %rax
cmpq 0x20(%rsp), %rax
setg %cl
cmpq 0x18(%rsp), %rax
jmp 0xbcb3
cmpq %r9, %r12
setg %cl
cmpq %r13, %r12
setge %al
xorb %cl, %al
testb %al, %al
je 0xbb92
cmpq %r8, %r14
je 0xbcfc
testq %r8, %r8
cmoveq %r14, %r8
jmp 0xbbb7
movq %r14, %r15
leaq 0x38(%rsp), %rdi
movq %r15, (%rdi)
callq 0x910b
xorl %r14d, %r14d
movq 0x10(%rsp), %rax
movq %r14, 0x18(%rax)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, 0x38(%rsp)
jmp 0xbce4
nop