// File: /workspace/github_cpp_makefile_star2_O2/hzeller[P]gcode-multi-shell-extrude/third_party/clipper.cpp
// Function: ClipperLib::ClipperOffset::OffsetPoint(int, int&, ClipperLib::JoinType)
void ClipperOffset::OffsetPoint(int j, int& k, JoinType jointype)
{
  m_sinA = (m_normals[k].X * m_normals[j].Y - m_normals[j].X * m_normals[k].Y);
  if (m_sinA < 0.00005 && m_sinA > -0.00005) return;
  else if (m_sinA > 1.0) m_sinA = 1.0;
  else if (m_sinA < -1.0) m_sinA = -1.0;

  if (m_sinA * m_delta < 0)
  {
    m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].X + m_normals[k].X * m_delta),
      Round(m_srcPoly[j].Y + m_normals[k].Y * m_delta)));
    m_destPoly.push_back(m_srcPoly[j]);
    m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].X + m_normals[j].X * m_delta),
      Round(m_srcPoly[j].Y + m_normals[j].Y * m_delta)));
  }
  else
    switch (jointype)
    {
      case jtMiter:
        {
          double r = 1 + (m_normals[j].X * m_normals[k].X +
            m_normals[j].Y * m_normals[k].Y);
          if (r >= m_miterLim) DoMiter(j, k, r); else DoSquare(j, k);
          break;
        }
      case jtSquare: DoSquare(j, k); break;
      case jtRound: DoRound(j, k); break;
    }
  k = j;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movl %esi, %ebp
movslq (%rdx), %rdx
movq 0x58(%rdi), %rax
movq %rdx, %rsi
shlq $0x4, %rsi
movslq %ebp, %r13
shlq $0x4, %r13
movsd (%rax,%r13), %xmm0
movsd 0x8(%rax,%r13), %xmm2
movupd (%rax,%rsi), %xmm1
movapd %xmm1, %xmm3
unpckhpd %xmm1, %xmm3            # xmm3 = xmm3[1],xmm1[1]
movapd %xmm3, %xmm5
mulsd %xmm0, %xmm5
movapd %xmm1, %xmm4
mulsd %xmm2, %xmm4
subsd %xmm5, %xmm4
movsd %xmm4, 0x78(%rdi)
movapd 0x4dd5(%rip), %xmm5     # 0x12ee0
andpd %xmm4, %xmm5
movsd 0x55d1(%rip), %xmm6     # 0x136e8
ucomisd %xmm5, %xmm6
ja 0xe2c9
movq %rdi, %r14
movsd 0x3f54(%rip), %xmm5     # 0x12080
ucomisd %xmm5, %xmm4
ja 0xe140
movsd 0x3f26(%rip), %xmm5     # 0x12060
ucomisd %xmm4, %xmm5
jbe 0xe14a
movsd %xmm5, 0x78(%r14)
movapd %xmm5, %xmm4
movsd 0x70(%r14), %xmm5
mulsd %xmm5, %xmm4
xorpd %xmm6, %xmm6
ucomisd %xmm4, %xmm6
jbe 0xe278
leaq 0x40(%r14), %r15
movq 0x28(%r14), %rax
cvtsi2sdq 0x8(%rax,%r13), %xmm0
cvtsi2sdq (%rax,%r13), %xmm2
unpcklpd %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
unpcklpd %xmm5, %xmm5            # xmm5 = xmm5[0,0]
mulpd %xmm5, %xmm1
addpd %xmm2, %xmm1
xorpd %xmm2, %xmm2
movapd %xmm1, %xmm0
cmpltpd %xmm2, %xmm0
movapd 0x5564(%rip), %xmm2     # 0x13700
andpd %xmm0, %xmm2
andnpd 0x3e78(%rip), %xmm0     # 0x12020
orpd %xmm2, %xmm0
addpd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
cvttsd2si %xmm0, %rax
movq %rax, %xmm0
punpcklqdq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0]
movq %rsp, %r12
movdqa %xmm1, (%r12)
movq %r15, %rdi
movq %r12, %rsi
callq 0x6770
movq 0x28(%r14), %rsi
addq %r13, %rsi
movq %r15, %rdi
callq 0xf8fe
movq 0x28(%r14), %rax
movq 0x58(%r14), %rcx
cvtsi2sdq 0x8(%rax,%r13), %xmm0
movupd 0x70(%r14), %xmm1
cvtsi2sdq (%rax,%r13), %xmm2
unpcklpd %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
movupd (%rcx,%r13), %xmm0
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
mulpd %xmm0, %xmm1
addpd %xmm2, %xmm1
movapd %xmm1, %xmm0
cmpltpd 0x3de3(%rip), %xmm0     # 0x12010
movapd 0x54cb(%rip), %xmm2     # 0x13700
andpd %xmm0, %xmm2
andnpd 0x3ddf(%rip), %xmm0     # 0x12020
orpd %xmm2, %xmm0
addpd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
cvttsd2si %xmm0, %rcx
movq %rax, %xmm0
movq %rcx, %xmm1
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movdqa %xmm0, (%r12)
movq %rsp, %rsi
movq %r15, %rdi
callq 0x6770
jmp 0xe2c7
testl %ecx, %ecx
je 0xe2a5
cmpl $0x1, %ecx
je 0xe2b1
cmpl $0x2, %ecx
jne 0xe2c7
mulsd %xmm3, %xmm2
mulsd %xmm1, %xmm0
addsd %xmm2, %xmm0
addsd 0x3de6(%rip), %xmm0     # 0x12080
ucomisd 0x90(%r14), %xmm0
jae 0xe2bd
movq %r14, %rdi
movl %ebp, %esi
callq 0xe2d8
jmp 0xe2c7
movq %r14, %rdi
movl %ebp, %esi
callq 0xe494
jmp 0xe2c7
movq %r14, %rdi
movl %ebp, %esi
callq 0xe680
movl %ebp, (%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq