// File: /workspace/github_cpp_makefile_star2_O1/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 0x1be77
jp 0x1be77
leaq 0x1e116(%rip), %rsi     # 0x39f8b
jmp 0x1be9d
movq %rcx, %r14
cmpl $0x1, 0x670(%rcx)
jne 0x1be8c
leaq 0x1e121(%rip), %rsi     # 0x39fab
jmp 0x1be9d
cmpl $0x0, 0x624(%r14)
je 0x1bef3
leaq 0x1e13e(%rip), %rsi     # 0x39fdb
movq %rbx, %rdi
xorl %eax, %eax
callq 0xa850
movq 0x280b2(%rip), %rbx     # 0x43f60
movl $0x0, 0xd670(%rbx)
leaq 0xc6d0(%rbx), %rdi
leaq 0x1db26(%rip), %rsi     # 0x399ec
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 0x1bf25
cmpl %r15d, 0x1798(%r14)
jne 0x1bf7c
movsd 0x660(%r14), %xmm0
movsd %xmm0, 0x230(%r12)
movl 0x1c8(%r12), %ecx
cmpl $-0x1, %ecx
je 0x1bf42
testl %ecx, %ecx
jne 0x1bf4e
leaq 0x1e0fa(%rip), %rdi     # 0x3a037
jmp 0x1c08d
movl $0x1, 0x1c8(%r12)
decl %eax
cmpl $0x5, %eax
ja 0x1c086
leaq 0x1da74(%rip), %rcx     # 0x399d4
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 0x1bfe5
leaq 0x1e08d(%rip), %rdi     # 0x3a010
jmp 0x1c08d
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
movq %r14, %rcx
callq 0xa4d0
jmp 0x1bfe5
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
movq %r14, %rcx
callq 0xa060
jmp 0x1bfe5
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
movq %r14, %rcx
callq 0xaf40
jmp 0x1bfe5
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
movq %r14, %rcx
callq 0xa6e0
jmp 0x1bfe5
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
movq %r14, %rcx
callq 0xb1b0
testl %eax, %eax
je 0x1c056
movl %eax, %ebx
movq 0x27f6e(%rip), %r14     # 0x43f60
movslq 0xd670(%r14), %rax
cmpq $0x30, %rax
jg 0x1bee8
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
leaq (%r14,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0x1d9cf(%rip), %rsi     # 0x399ec
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 0x1bee8
movl 0x1c8(%r12), %eax
movl %eax, 0x648(%r14)
movsd 0x230(%r12), %xmm0
movsd %xmm0, 0x660(%r14)
movl %r15d, 0x1798(%r14)
xorl %ebx, %ebx
jmp 0x1bee8
leaq 0x1bf26(%rip), %rdi     # 0x37fb3
callq 0xa1f0
movq %rbx, %rdi
movq %rax, %rsi
jmp 0x1bea0
nop