// File: /workspace/github_cpp_makefile_star2_O1/sundale[P]gcode/rs274ngc/interp_cycles.cc
// Function: Interp::convert_cycle_g83(block_struct*, int, double, double, double, double, double, double)
int Interp::convert_cycle_g83(block_pointer block,
                              CANON_PLANE plane, //!< selected plane                  
                              double x,  //!< x-value where cycle is executed 
                              double y,  //!< y-value where cycle is executed 
                              double r,  //!< initial z-value                 
                              double clear_z,    //!< z-value of clearance plane      
                              double bottom_z,   //!< value of z at bottom of cycle   
                              double delta)      //!< size of z-axis feed increment   
{
  double current_depth;
  double rapid_delta;

  /* Moved the check for negative Q values here as a sign
     may be used with user defined M functions
     Thanks to Billy Singleton for pointing it out... */
  CHKS((delta <= 0.0), NCE_NEGATIVE_OR_ZERO_Q_VALUE_USED);

  rapid_delta = G83_RAPID_DELTA;
  if (_setup.length_units == CANON_UNITS_MM)
    rapid_delta = (rapid_delta * 25.4);

  for (current_depth = (r - delta);
       current_depth > bottom_z; current_depth = (current_depth - delta)) {
    cycle_feed(block, plane, x, y, current_depth);
    cycle_traverse(block, plane, x, y, clear_z);
    cycle_traverse(block, plane, x, y, current_depth + rapid_delta);
  }
  cycle_feed(block, plane, x, y, bottom_z);
  cycle_traverse(block, plane, x, y, clear_z);

  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
xorpd %xmm6, %xmm6
ucomisd %xmm5, %xmm6
jae 0x1b830
movl %edx, %ebx
movq %rsi, %r14
movq 0x2880f(%rip), %rcx     # 0x43f60
xorl %eax, %eax
cmpl $0x2, 0x1690(%rcx)
sete %cl
subsd %xmm5, %xmm2
ucomisd %xmm4, %xmm2
movsd %xmm3, -0x30(%rbp)
movsd %xmm1, -0x20(%rbp)
movsd %xmm0, -0x28(%rbp)
jbe 0x1b805
movb %cl, %al
leaq 0x1e4a5(%rip), %rcx     # 0x39c28
movsd (%rcx,%rax,8), %xmm3
movsd %xmm3, -0x40(%rbp)
movsd %xmm4, -0x50(%rbp)
movsd %xmm5, -0x48(%rbp)
movsd %xmm2, -0x38(%rbp)
movq %r14, %rsi
movl %ebx, %edx
movsd -0x20(%rbp), %xmm1
callq 0xa180
movq %r14, %rsi
movl %ebx, %edx
movsd -0x28(%rbp), %xmm0
movsd -0x20(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
callq 0xb120
movsd -0x40(%rbp), %xmm2
addsd -0x38(%rbp), %xmm2
movq %r14, %rsi
movl %ebx, %edx
movsd -0x28(%rbp), %xmm0
movsd -0x20(%rbp), %xmm1
callq 0xb120
movsd -0x38(%rbp), %xmm2
movsd -0x48(%rbp), %xmm5
movsd -0x50(%rbp), %xmm4
movsd -0x28(%rbp), %xmm0
movsd -0x20(%rbp), %xmm1
subsd %xmm5, %xmm2
ucomisd %xmm4, %xmm2
ja 0x1b797
movq %r14, %rsi
movl %ebx, %edx
movapd %xmm4, %xmm2
callq 0xa180
movq %r14, %rsi
movl %ebx, %edx
movsd -0x28(%rbp), %xmm0
movsd -0x20(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
callq 0xb120
xorl %eax, %eax
jmp 0x1b88d
movq %rdi, %r15
leaq 0x1e3fe(%rip), %rdi     # 0x39c38
callq 0xa1f0
movq %r15, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
movq 0x2870d(%rip), %rbx     # 0x43f60
movl $0x0, 0xd670(%rbx)
leaq 0xc6d0(%rbx), %rdi
leaq 0x1e3eb(%rip), %rsi     # 0x39c56
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
movl $0x5, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq