// File: sundale[P]gcode/rs274ngc/interp_cycles.cc
// Function: Interp::convert_cycle_g87(block_struct*, int, double, double, double, double, double, double, double, double, int)
int Interp::convert_cycle_g87(block_pointer block,
                              CANON_PLANE plane, //!< selected plane                     
                              double x,  //!< x-value where cycle is executed    
                              double offset_x,   //!< x-axis offset position             
                              double y,  //!< y-value where cycle is executed    
                              double offset_y,   //!< y-axis offset position             
                              double r,  //!< z_value of r_plane                 
                              double clear_z,    //!< z-value of clearance plane         
                              double middle_z,   //!< z-value of top of back bore        
                              double bottom_z,   //!< value of z at bottom of cycle      
                              CANON_DIRECTION direction) //!< direction spindle turning at outset
{
  CHKS(((direction != CANON_CLOCKWISE) &&
       (direction != CANON_COUNTERCLOCKWISE)),
      NCE_SPINDLE_NOT_TURNING_IN_G87);

  cycle_traverse(block, plane, offset_x, offset_y, r);
  STOP_SPINDLE_TURNING();
  ORIENT_SPINDLE(0.0, direction);
  cycle_traverse(block, plane, offset_x, offset_y, bottom_z);
  cycle_traverse(block, plane, x, y, bottom_z);
  if (direction == CANON_CLOCKWISE)
    START_SPINDLE_CLOCKWISE();
  else
    START_SPINDLE_COUNTERCLOCKWISE();
  cycle_feed(block, plane, x, y, middle_z);
  cycle_feed(block, plane, x, y, bottom_z);
  STOP_SPINDLE_TURNING();
  ORIENT_SPINDLE(0.0, direction);
  cycle_traverse(block, plane, offset_x, offset_y, bottom_z);
  cycle_traverse(block, plane, offset_x, offset_y, clear_z);
  cycle_traverse(block, plane, x, y, clear_z);
  if (direction == CANON_CLOCKWISE)
    START_SPINDLE_CLOCKWISE();
  else
    START_SPINDLE_COUNTERCLOCKWISE();

  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movsd %xmm0, -0x28(%rbp)
movsd %xmm1, -0x30(%rbp)
movsd %xmm2, -0x38(%rbp)
movsd %xmm3, -0x40(%rbp)
movsd %xmm4, -0x48(%rbp)
movsd %xmm5, -0x50(%rbp)
movsd %xmm6, -0x58(%rbp)
movsd %xmm7, -0x60(%rbp)
movl %ecx, -0x64(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
cmpl $0x2, -0x64(%rbp)
je 0x3816f
cmpl $0x3, -0x64(%rbp)
je 0x3816f
jmp 0x3809c
leaq 0x43ecd(%rip), %rdi     # 0x7bf70
callq 0x10380
movq -0x70(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x4eea3(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x4ee92(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x4ee84(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x43e9a(%rip), %rsi     # 0x7bf8b
movl $0x50, %edx
callq 0x10840
movq 0x4ee5e(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x4ee50(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x4ee38(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x4ee28(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x4ee1b(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x4ee0d(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x382b4
jmp 0x38171
movq -0x70(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movsd -0x30(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
movsd -0x48(%rbp), %xmm2
callq 0x11bf0
callq 0x11300
movl -0x64(%rbp), %edi
xorps %xmm0, %xmm0
callq 0x11bc0
movq -0x70(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movsd -0x30(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
movsd -0x60(%rbp), %xmm2
callq 0x11bf0
movq -0x70(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movsd -0x28(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movsd -0x60(%rbp), %xmm2
callq 0x11bf0
cmpl $0x2, -0x64(%rbp)
jne 0x381eb
callq 0x112f0
jmp 0x381f0
callq 0x118b0
movq -0x70(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movsd -0x28(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movsd -0x58(%rbp), %xmm2
callq 0x10290
movq -0x70(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movsd -0x28(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movsd -0x60(%rbp), %xmm2
callq 0x10290
callq 0x11300
movl -0x64(%rbp), %edi
xorps %xmm0, %xmm0
callq 0x11bc0
movq -0x70(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movsd -0x30(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
movsd -0x60(%rbp), %xmm2
callq 0x11bf0
movq -0x70(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movsd -0x30(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
movsd -0x50(%rbp), %xmm2
callq 0x11bf0
movq -0x70(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movsd -0x28(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movsd -0x50(%rbp), %xmm2
callq 0x11bf0
cmpl $0x2, -0x64(%rbp)
jne 0x382a8
callq 0x112f0
jmp 0x382ad
callq 0x118b0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)