// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movsd %xmm0, 0x8(%rsp)
movq %rsi, %r14
movq %rdi, %r15
movq %rsi, %rdi
callq 0x83fc
movq %r15, %rdi
callq 0xed38
movq %r15, %rdi
movsd 0x8(%rsp), %xmm0
callq 0xf180
leaq 0x118(%rsp), %rbx
xorl %eax, %eax
movq %rax, 0x30(%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x20(%rbx)
movupd %xmm0, 0x8(%rbx)
leaq 0xbeba(%rip), %rcx      # 0x1bcb8
movq %rcx, -0xc0(%rbx)
leaq 0xbef4(%rip), %rcx      # 0x1bd00
movq %rcx, (%rbx)
leaq 0xd0(%rsp), %rcx
movl $0x0, (%rcx)
movq %rax, 0x8(%rcx)
movupd %xmm0, -0x70(%rcx)
movupd %xmm0, -0x60(%rcx)
movupd %xmm0, -0x50(%rcx)
movupd %xmm0, -0x40(%rcx)
movupd %xmm0, -0x30(%rcx)
movupd %xmm0, -0x20(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movb %al, 0x60(%rcx)
movupd %xmm0, 0x20(%rcx)
movupd %xmm0, 0x29(%rcx)
movb %al, 0x44(%rcx)
movb %al, 0x46(%rcx)
movw $0x0, 0x38(%rbx)
addq $0x10, %r15
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x9e96
xorpd %xmm0, %xmm0
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xfea8
leaq 0x58(%rsp), %rdi
movl $0x1, %esi
movq %r14, %rdx
movl $0x2, %ecx
movl $0x2, %r8d
callq 0xa674
jmp 0x10047
leaq 0x58(%rsp), %r12
movq (%r12), %rax
movq -0x18(%rax), %rsi
addq %r12, %rsi
leaq 0x20(%rsp), %rdi
callq 0xa038
movl $0x40, %edi
callq 0x3210
leaq 0x40(%rsp), %rsi
movq %rax, (%rsi)
movq %rax, %rcx
addq $0x40, %rcx
movq %rcx, 0x10(%rsi)
movq %rcx, 0x8(%rsi)
movq 0x20(%rsp), %rdi
movq 0x38(%rsp), %rcx
addq $-0xa, %rdi
addq $0xa, %rcx
movq %rdi, (%rax)
movq %rcx, 0x8(%rax)
movq 0x30(%rsp), %rdx
addq $0xa, %rdx
movq %rdx, 0x10(%rax)
movq %rcx, 0x18(%rax)
movq 0x28(%rsp), %rcx
addq $-0xa, %rcx
movq %rdx, 0x20(%rax)
movq %rcx, 0x28(%rax)
movq %rdi, 0x30(%rax)
movq %rax, 0x10(%rsp)
movq %rcx, 0x38(%rax)
movq 0x58(%rsp), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x985a
leaq 0x58(%rsp), %rdi
movb $0x1, 0xbc(%rdi)
movl $0x1, %esi
movq %r14, %rdx
movl $0x3, %ecx
movl $0x3, %r8d
callq 0xa674
movq 0x18(%r14), %rax
movq 0x20(%r14), %rcx
subq %rax, %rcx
movabsq $0x7fffffff8, %rdx      # imm = 0x7FFFFFFF8
andq %rcx, %rdx
cmpq $0x8, %rdx
jne 0x10028
movq (%rax), %rbp
movq 0x20(%rbp), %rsi
subq 0x18(%rbp), %rsi
shrq $0x3, %rsi
testl %esi, %esi
jle 0x10028
leaq 0x18(%r14), %rbx
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movq %rbx, %rdi
callq 0x11f44
movq 0x18(%rbp), %rax
movq (%rax), %rax
movq %rbx, 0x8(%rsp)
movq (%rbx), %rcx
movq %rax, (%rcx)
movq 0x18(%rbp), %rax
movq 0x20(%rbp), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
cmpl $0x2, %ecx
jl 0x10030
movl $0x1, %ebx
movq (%rax,%rbx,8), %r13
movq 0x18(%r14), %r12
movq 0x20(%r14), %r15
movq %r13, 0x18(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x12614
subq %r12, %r15
shrq $0x3, %r15
movq %r14, 0x30(%r13)
movl %r15d, 0x38(%r13)
incq %rbx
movq 0x18(%rbp), %rax
movq 0x20(%rbp), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
movslq %ecx, %rcx
cmpq %rcx, %rbx
jl 0xffdd
jmp 0x10030
movq %r14, %rdi
callq 0x83fc
movl $0x40, %esi
movq 0x10(%rsp), %rdi
callq 0x3220
leaq 0x118(%rsp), %rbx
leaq 0xbcd2(%rip), %rsi      # 0x1bd20
leaq 0x58(%rsp), %rdi
callq 0xa258
movq %rbx, %rdi
callq 0x9440
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1007d
jmp 0x10078
jmp 0x1007d
movq %rax, %r14
jmp 0x1008f
movq %rax, %r14
movl $0x40, %esi
movq 0x10(%rsp), %rdi
callq 0x3220
leaq 0xbc8a(%rip), %rsi      # 0x1bd20
leaq 0x58(%rsp), %rdi
callq 0xa258
leaq 0x118(%rsp), %rdi
callq 0x9440
movq %r14, %rdi
callq 0x3380
nop