// File: /workspace/github_cpp_makefile_star2_O3/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 0x1aff7
jp 0x1aff7
leaq 0x1bf8e(%rip), %rsi     # 0x36f83
jmp 0x1b01d
movq %rcx, %r14
cmpl $0x1, 0x670(%rcx)
jne 0x1b00c
leaq 0x1bf99(%rip), %rsi     # 0x36fa3
jmp 0x1b01d
cmpl $0x0, 0x624(%r14)
je 0x1b069
leaq 0x1bfb6(%rip), %rsi     # 0x36fd3
movq %rbx, %rdi
xorl %eax, %eax
callq 0xa850
movq 0x25f32(%rip), %rbx     # 0x40f60
leaq 0xc6d0(%rbx), %rdi
leaq 0x1b9a8(%rip), %rsi     # 0x369e4
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
movl $0x5, %ebx
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 0x1b09b
cmpl %r15d, 0x1798(%r14)
jne 0x1b0f2
movsd 0x660(%r14), %xmm0
movsd %xmm0, 0x230(%r12)
movl 0x1c8(%r12), %ecx
cmpl $-0x1, %ecx
je 0x1b0b8
testl %ecx, %ecx
jne 0x1b0c4
leaq 0x1bf7c(%rip), %rdi     # 0x3702f
jmp 0x1b203
movl $0x1, 0x1c8(%r12)
decl %eax
cmpl $0x5, %eax
ja 0x1b1fc
leaq 0x1b8f6(%rip), %rcx     # 0x369cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
movq %r14, %rcx
callq 0xa0a0
jmp 0x1b15b
leaq 0x1bf0f(%rip), %rdi     # 0x37008
jmp 0x1b203
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
movq %r14, %rcx
callq 0xa4d0
jmp 0x1b15b
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
movq %r14, %rcx
callq 0xa060
jmp 0x1b15b
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
movq %r14, %rcx
callq 0xaf40
jmp 0x1b15b
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
movq %r14, %rcx
callq 0xa6e0
jmp 0x1b15b
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
movq %r14, %rcx
callq 0xb1b0
testl %eax, %eax
je 0x1b1cc
movl %eax, %ebx
movq 0x25df8(%rip), %r14     # 0x40f60
movslq 0xd670(%r14), %rax
cmpq $0x30, %rax
jg 0x1b05e
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
leaq (%r14,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0x1b851(%rip), %rsi     # 0x369e4
movl $0x50, %edx
callq 0xa8a0
movslq 0xd670(%r14), %rax
leaq (%rax,%rax,4), %rcx
shlq $0x4, %rcx
xorl %edx, %edx
movb %dl, 0xc71f(%r14,%rcx)
incl %eax
movl %eax, 0xd670(%r14)
movb %dl, 0xc720(%r14,%rcx)
jmp 0x1b05e
movl 0x1c8(%r12), %eax
movl %eax, 0x648(%r14)
movsd 0x230(%r12), %xmm0
movsd %xmm0, 0x660(%r14)
movl %r15d, 0x1798(%r14)
xorl %ebx, %ebx
jmp 0x1b05e
leaq 0x19db0(%rip), %rdi     # 0x34fb3
callq 0xa1f0
movq %rbx, %rdi
movq %rax, %rsi
jmp 0x1b020
nop