// File: /workspace/github_cpp_makefile_star2_O2/sundale[P]gcode/rs274ngc/interp_cycles.cc
// Function: Interp::convert_cycle(int, block_struct*, setup_struct*)
int Interp::convert_cycle(int motion,    //!< a g-code between G_81 and G_89, a canned cycle
                         block_pointer block,   //!< pointer to a block of RS274 instructions      
                         setup_pointer settings)        //!< pointer to machine settings                   
{
  CANON_PLANE plane;

  CHKS((settings->feed_rate == 0.0), "Cannot feed with zero feed rate");
  CHKS((settings->feed_mode == INVERSE_TIME), "Cannot use inverse time feed with canned cycles");
  CHKS((settings->cutter_comp_side != OFF), "Cannot use canned cycles with cutter compensation on");

  plane = settings->plane;
  if (block->r_flag == OFF) {
    if (settings->motion_mode == motion)
      block->r_number = settings->cycle_r;
    else
      ERS(NCE_R_CLEARANCE_PLANE_UNSPECIFIED_IN_CYCLE);
  }

  CHKS((block->l_number == 0), NCE_CANNOT_DO_ZERO_REPEATS_OF_CYCLE);
  if (block->l_number == -1)
    block->l_number = 1;

  if (plane == CANON_PLANE_XY) {
    CHP(convert_cycle_xy(motion, block, settings));
  } else if (plane == CANON_PLANE_YZ) {
    CHP(convert_cycle_yz(motion, block, settings));
  } else if (plane == CANON_PLANE_XZ) {
    CHP(convert_cycle_zx(motion, block, settings));
  } else if (plane == CANON_PLANE_UV) {
    CHP(convert_cycle_uv(motion, block, settings));
  } else if (plane == CANON_PLANE_VW) {
    CHP(convert_cycle_vw(motion, block, settings));
  } else if (plane == CANON_PLANE_UW) {
    CHP(convert_cycle_wu(motion, block, settings));
  } else
    ERS(NCE_BUG_PLANE_NOT_XY_YZ_OR_XZ);

  settings->cycle_l = block->l_number;
  settings->cycle_r = block->r_number;
  settings->motion_mode = motion;
  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movsd 0x678(%rcx), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x1b1cd
jp 0x1b1cd
leaq 0x17db8(%rip), %rsi     # 0x32f83
jmp 0x1b1f3
movq %rcx, %r14
cmpl $0x1, 0x670(%rcx)
jne 0x1b1e2
leaq 0x17dc3(%rip), %rsi     # 0x32fa3
jmp 0x1b1f3
cmpl $0x0, 0x624(%r14)
je 0x1b23a
leaq 0x17de0(%rip), %rsi     # 0x32fd3
movq %rbx, %rdi
xorl %eax, %eax
callq 0xb8e0
movq 0x21d5c(%rip), %rbx     # 0x3cf60
leaq 0xc6d0(%rbx), %rdi
leaq 0x177d2(%rip), %rsi     # 0x329e4
pushq $0x50
popq %rdx
callq 0xb940
andw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
pushq $0x5
popq %rbx
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, %r12
movl %esi, %r15d
movl 0xc67c(%r14), %eax
cmpb $0x0, 0x229(%rdx)
jne 0x1b26c
cmpl %r15d, 0x1798(%r14)
jne 0x1b2c3
movsd 0x660(%r14), %xmm0
movsd %xmm0, 0x230(%r12)
movl 0x1c8(%r12), %ecx
cmpl $-0x1, %ecx
je 0x1b289
testl %ecx, %ecx
jne 0x1b295
leaq 0x17dab(%rip), %rdi     # 0x3302f
jmp 0x1b3ca
movl $0x1, 0x1c8(%r12)
decl %eax
cmpl $0x5, %eax
ja 0x1b3c3
leaq 0x17725(%rip), %rcx     # 0x329cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
movq %r14, %rcx
callq 0xb0b0
jmp 0x1b32c
leaq 0x17d3e(%rip), %rdi     # 0x33008
jmp 0x1b3ca
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
movq %r14, %rcx
callq 0xb510
jmp 0x1b32c
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
movq %r14, %rcx
callq 0xb060
jmp 0x1b32c
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
movq %r14, %rcx
callq 0xc070
jmp 0x1b32c
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
movq %r14, %rcx
callq 0xb730
jmp 0x1b32c
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
movq %r14, %rcx
callq 0xc310
testl %eax, %eax
je 0x1b393
movl %eax, %ebx
movq 0x21c27(%rip), %r14     # 0x3cf60
movslq 0xd670(%r14), %rax
cmpq $0x30, %rax
jg 0x1b22f
imulq $0x50, %rax, %rax
leaq (%r14,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0x17684(%rip), %rsi     # 0x329e4
pushq $0x50
popq %rdx
callq 0xb940
movslq 0xd670(%r14), %rax
imulq $0x50, %rax, %rcx
xorl %edx, %edx
movb %dl, 0xc71f(%r14,%rcx)
incl %eax
movl %eax, 0xd670(%r14)
movb %dl, 0xc720(%r14,%rcx)
jmp 0x1b22f
movl 0x1c8(%r12), %eax
movl %eax, 0x648(%r14)
movsd 0x230(%r12), %xmm0
movsd %xmm0, 0x660(%r14)
movl %r15d, 0x1798(%r14)
xorl %ebx, %ebx
jmp 0x1b22f
leaq 0x15be9(%rip), %rdi     # 0x30fb3
callq 0xb220
movq %rbx, %rdi
movq %rax, %rsi
jmp 0x1b1f6