// File: hzeller[P]gcode-multi-shell-extrude/third_party/clipper.cpp
// Function: ClipperLib::ClipperOffset::Execute(std::vector<std::vector<ClipperLib::IntPoint, std::allocator<ClipperLib::IntPoint>>, std::allocator<std::vector<ClipperLib::IntPoint, std::allocator<ClipperLib::IntPoint>>>>&, double)
void ClipperOffset::Execute(Paths& 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);
    if (solution.size() > 0) solution.erase(solution.begin());
  }
}

// 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, -0x1d0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x21ac0
movq -0x1d0(%rbp), %rdi
callq 0x1c170
movq -0x1d0(%rbp), %rdi
movsd -0x18(%rbp), %xmm0
callq 0x1c670
leaq -0x118(%rbp), %rdi
xorl %esi, %esi
movl %esi, -0x1c4(%rbp)
callq 0x14780
movq -0x1d0(%rbp), %rsi
movl -0x1c4(%rbp), %edx
movq -0x118(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x118(%rbp,%rax), %rdi
addq $0x10, %rsi
movl $0x1, %ecx
callq 0x141c0
jmp 0x1c38d
movsd -0x18(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1c3d7
movq -0x10(%rbp), %rdx
leaq -0x118(%rbp), %rdi
movl $0x1, %esi
movl $0x2, %r8d
movl %r8d, %ecx
callq 0x14ad0
jmp 0x1c3bb
jmp 0x1c641
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x120(%rbp)
movl %eax, -0x124(%rbp)
jmp 0x1c656
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, -0x1d8(%rbp)
callq 0xd0a0
movq -0x1d8(%rbp), %rdx
leaq -0x160(%rbp), %rdi
movl $0x4, %esi
callq 0x21ae0
jmp 0x1c423
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 0x1c453
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 0x1c491
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 0x1c4d0
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 0x1c50f
leaq -0x160(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
movl $0x3, %esi
callq 0x21aa0
movq -0x1e0(%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 0x1c559
leaq -0x118(%rbp), %rdi
movl $0x1, %esi
callq 0x21b50
jmp 0x1c56c
movq -0x10(%rbp), %rdx
leaq -0x118(%rbp), %rdi
movl $0x1, %esi
movl $0x3, %r8d
movl %r8d, %ecx
callq 0x14ad0
jmp 0x1c58c
movq -0x10(%rbp), %rdi
callq 0xcb30
cmpq $0x0, %rax
jbe 0x1c635
movq -0x10(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0xcb80
movq %rax, -0x1b8(%rbp)
leaq -0x1b0(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x21bf0
movq -0x1f0(%rbp), %rdi
movq -0x1b0(%rbp), %rsi
callq 0x21b80
movq %rax, -0x1e8(%rbp)
jmp 0x1c5e5
movq -0x1e8(%rbp), %rax
movq %rax, -0x1c0(%rbp)
jmp 0x1c635
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x120(%rbp)
movl %eax, -0x124(%rbp)
leaq -0x161(%rbp), %rdi
callq 0xd440
jmp 0x1c656
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x120(%rbp)
movl %eax, -0x124(%rbp)
leaq -0x160(%rbp), %rdi
callq 0xcff0
jmp 0x1c656
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
nop