// File: hzeller[P]gcode-multi-shell-extrude/third_party/clipper.cpp
// Function: ClipperLib::ClipperOffset::Execute(ClipperLib::PolyTree&, double)
void ClipperOffset::Execute(PolyTree& solution, double delta)
{
  solution.Clear();
  FixOrientations();
  DoOffset(delta);

  //now clean up 'corners' ...
  Clipper clpr;
  clpr.AddPaths(m_destPolys, ptSubject, true);
  if (delta > 0)
  {
    clpr.Execute(ctUnion, solution, pftPositive, pftPositive);
  }
  else
  {
    IntRect r = clpr.GetBounds();
    Path outer(4);
    outer[0] = IntPoint(r.left - 10, r.bottom + 10);
    outer[1] = IntPoint(r.right + 10, r.bottom + 10);
    outer[2] = IntPoint(r.right + 10, r.top - 10);
    outer[3] = IntPoint(r.left - 10, r.top - 10);

    clpr.AddPath(outer, ptSubject, true);
    clpr.ReverseSolution(true);
    clpr.Execute(ctUnion, solution, pftNegative, pftNegative);
    //remove the outer PolyNode rectangle ...
    if (solution.ChildCount() == 1 && solution.Childs[0]->ChildCount() > 0)
    {
      PolyNode* outerNode = solution.Childs[0];
      solution.Childs.reserve(outerNode->ChildCount());
      solution.Childs[0] = outerNode->Childs[0];
      for (int i = 1; i < outerNode->ChildCount(); ++i)
        solution.AddChild(*outerNode->Childs[i]);
    }
    else
      solution.Clear();
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x10af0
movq -0x1c0(%rbp), %rdi
callq 0x1c170
movq -0x1c0(%rbp), %rdi
movsd -0x18(%rbp), %xmm0
callq 0x1c670
leaq -0x118(%rbp), %rdi
xorl %esi, %esi
movl %esi, -0x1b8(%rbp)
callq 0x14780
movq -0x1c0(%rbp), %rsi
movl -0x1b8(%rbp), %edx
movq -0x118(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x118(%rbp,%rax), %rdi
addq $0x10, %rsi
movl $0x1, %ecx
callq 0x141c0
jmp 0x1da9d
movsd -0x18(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1dae7
movq -0x10(%rbp), %rdx
leaq -0x118(%rbp), %rdi
movl $0x1, %esi
movl $0x2, %r8d
movl %r8d, %ecx
callq 0x14df0
jmp 0x1dacb
jmp 0x1de23
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x120(%rbp)
movl %eax, -0x124(%rbp)
jmp 0x1de38
movq -0x118(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x118(%rbp,%rax), %rsi
leaq -0x148(%rbp), %rdi
callq 0x14470
leaq -0x161(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0xd0a0
movq -0x1c8(%rbp), %rdx
leaq -0x160(%rbp), %rdi
movl $0x4, %esi
callq 0x21ae0
jmp 0x1db33
leaq -0x161(%rbp), %rdi
callq 0xd440
movq -0x148(%rbp), %rsi
movq -0x130(%rbp), %rdx
addq $-0xa, %rsi
addq $0xa, %rdx
leaq -0x178(%rbp), %rdi
callq 0xcae0
jmp 0x1db63
xorl %eax, %eax
movl %eax, %esi
leaq -0x160(%rbp), %rdi
callq 0x21aa0
movups -0x178(%rbp), %xmm0
movups %xmm0, (%rax)
movq -0x138(%rbp), %rsi
movq -0x130(%rbp), %rdx
addq $0xa, %rsi
addq $0xa, %rdx
leaq -0x188(%rbp), %rdi
callq 0xcae0
jmp 0x1dba1
leaq -0x160(%rbp), %rdi
movl $0x1, %esi
callq 0x21aa0
movups -0x188(%rbp), %xmm0
movups %xmm0, (%rax)
movq -0x140(%rbp), %rdx
movq -0x138(%rbp), %rsi
addq $0xa, %rsi
addq $-0xa, %rdx
leaq -0x198(%rbp), %rdi
callq 0xcae0
jmp 0x1dbe0
leaq -0x160(%rbp), %rdi
movl $0x2, %esi
callq 0x21aa0
movups -0x198(%rbp), %xmm0
movups %xmm0, (%rax)
movq -0x148(%rbp), %rsi
movq -0x140(%rbp), %rdx
addq $-0xa, %rsi
addq $-0xa, %rdx
leaq -0x1a8(%rbp), %rdi
callq 0xcae0
jmp 0x1dc1f
leaq -0x160(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
movl $0x3, %esi
callq 0x21aa0
movq -0x1d0(%rbp), %rsi
movups -0x1a8(%rbp), %xmm0
movups %xmm0, (%rax)
movq -0x118(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x118(%rbp,%rax), %rdi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x13670
jmp 0x1dc69
leaq -0x118(%rbp), %rdi
movl $0x1, %esi
callq 0x21b50
jmp 0x1dc7c
movq -0x10(%rbp), %rdx
leaq -0x118(%rbp), %rdi
movl $0x1, %esi
movl $0x3, %r8d
movl %r8d, %ecx
callq 0x14df0
jmp 0x1dc9c
movq -0x10(%rbp), %rdi
callq 0x10c70
cmpl $0x1, %eax
jne 0x1de0a
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x20200
movq (%rax), %rdi
callq 0x10c70
cmpl $0x0, %eax
jle 0x1de0a
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x20200
movq (%rax), %rax
movq %rax, -0x1b0(%rbp)
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x1d8(%rbp)
movq -0x1b0(%rbp), %rdi
callq 0x10c70
movq -0x1d8(%rbp), %rdi
movslq %eax, %rsi
callq 0x216e0
jmp 0x1dd17
movq -0x1b0(%rbp), %rdi
addq $0x18, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x20200
movq (%rax), %rax
movq %rax, -0x1e0(%rbp)
movq -0x10(%rbp), %rdi
addq $0x18, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x20200
movq -0x1e0(%rbp), %rcx
movq %rcx, (%rax)
movl $0x1, -0x1b4(%rbp)
movl -0x1b4(%rbp), %eax
movl %eax, -0x1e4(%rbp)
movq -0x1b0(%rbp), %rdi
callq 0x10c70
movl %eax, %ecx
movl -0x1e4(%rbp), %eax
cmpl %ecx, %eax
jge 0x1de08
movq -0x10(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movq -0x1b0(%rbp), %rdi
addq $0x18, %rdi
movslq -0x1b4(%rbp), %rsi
callq 0x20200
movq -0x1f0(%rbp), %rdi
movq (%rax), %rsi
callq 0x10c90
jmp 0x1ddb5
jmp 0x1ddb7
movl -0x1b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1b4(%rbp)
jmp 0x1dd5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x120(%rbp)
movl %eax, -0x124(%rbp)
leaq -0x161(%rbp), %rdi
callq 0xd440
jmp 0x1de38
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x120(%rbp)
movl %eax, -0x124(%rbp)
leaq -0x160(%rbp), %rdi
callq 0xcff0
jmp 0x1de38
jmp 0x1de17
movq -0x10(%rbp), %rdi
callq 0x10af0
jmp 0x1de15
jmp 0x1de17
leaq -0x160(%rbp), %rdi
callq 0xcff0
leaq -0x118(%rbp), %rdi
callq 0x14940
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
leaq -0x118(%rbp), %rdi
callq 0x14940
movq -0x120(%rbp), %rdi
callq 0x3440