// File: sundale[P]gcode/rs274ngc/interp_convert.cc
// Function: Interp::convert_set_plane(int, setup_struct*)
int Interp::convert_set_plane(int g_code,        //!< must be G_17, G_18, or G_19 
                             setup_pointer settings)    //!< pointer to machine settings 
{
  CHKS((settings->cutter_comp_side != OFF && g_code == G_17 && settings->plane != CANON_PLANE_XY),
        NCE_CANNOT_CHANGE_PLANES_WITH_CUTTER_RADIUS_COMP_ON);
  CHKS((settings->cutter_comp_side != OFF && g_code == G_18 && settings->plane != CANON_PLANE_XZ),
        NCE_CANNOT_CHANGE_PLANES_WITH_CUTTER_RADIUS_COMP_ON);
  CHKS((settings->cutter_comp_side != OFF && g_code == G_19 && settings->plane != CANON_PLANE_YZ),
        NCE_CANNOT_CHANGE_PLANES_WITH_CUTTER_RADIUS_COMP_ON);

  CHKS((settings->cutter_comp_side != OFF && g_code == G_19), 
          NCE_RADIUS_COMP_ONLY_IN_XY_OR_XZ);

  if (g_code == G_17) {
    SELECT_PLANE(CANON_PLANE_XY);
    settings->plane = CANON_PLANE_XY;
  } else if (g_code == G_18) {
    SELECT_PLANE(CANON_PLANE_XZ);
    settings->plane = CANON_PLANE_XZ;
  } else if (g_code == G_19) {
    SELECT_PLANE(CANON_PLANE_YZ);
    settings->plane = CANON_PLANE_YZ;
  } else if (g_code == G_17_1) {
    SELECT_PLANE(CANON_PLANE_UV);
    settings->plane = CANON_PLANE_UV;
  } else if (g_code == G_18_1) {
    SELECT_PLANE(CANON_PLANE_UW);
    settings->plane = CANON_PLANE_UW;
  } else if (g_code == G_19_1) {
    SELECT_PLANE(CANON_PLANE_VW);
    settings->plane = CANON_PLANE_VW;
  } else
    ERS(NCE_BUG_CODE_NOT_G17_G18_OR_G19);
  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, 0x624(%rax)
je 0x2265f
cmpl $0xaa, -0x14(%rbp)
jne 0x2265f
movq -0x20(%rbp), %rax
cmpl $0x1, 0xc67c(%rax)
je 0x2265f
jmp 0x2258c
leaq 0x58854(%rip), %rdi     # 0x7ade7
callq 0x10380
movq -0x28(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x649b3(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x649a2(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x64994(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x5883e(%rip), %rsi     # 0x7ae1f
movl $0x50, %edx
callq 0x10840
movq 0x6496e(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x64960(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x64948(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x64938(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x6492b(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x6491d(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x22b2f
jmp 0x22661
jmp 0x22663
movq -0x20(%rbp), %rax
cmpl $0x0, 0x624(%rax)
je 0x22767
cmpl $0xb4, -0x14(%rbp)
jne 0x22767
movq -0x20(%rbp), %rax
cmpl $0x3, 0xc67c(%rax)
je 0x22767
jmp 0x22694
leaq 0x5874c(%rip), %rdi     # 0x7ade7
callq 0x10380
movq -0x28(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x648ab(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x6489a(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x6488c(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x58736(%rip), %rsi     # 0x7ae1f
movl $0x50, %edx
callq 0x10840
movq 0x64866(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x64858(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x64840(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x64830(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x64823(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x64815(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x22b2f
jmp 0x22769
jmp 0x2276b
movq -0x20(%rbp), %rax
cmpl $0x0, 0x624(%rax)
je 0x2286f
cmpl $0xbe, -0x14(%rbp)
jne 0x2286f
movq -0x20(%rbp), %rax
cmpl $0x2, 0xc67c(%rax)
je 0x2286f
jmp 0x2279c
leaq 0x58644(%rip), %rdi     # 0x7ade7
callq 0x10380
movq -0x28(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x647a3(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x64792(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x64784(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x5862e(%rip), %rsi     # 0x7ae1f
movl $0x50, %edx
callq 0x10840
movq 0x6475e(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x64750(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x64738(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x64728(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x6471b(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x6470d(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x22b2f
jmp 0x22871
jmp 0x22873
movq -0x20(%rbp), %rax
cmpl $0x0, 0x624(%rax)
je 0x22966
cmpl $0xbe, -0x14(%rbp)
jne 0x22966
jmp 0x22893
leaq 0x5760e(%rip), %rdi     # 0x79ea8
callq 0x10380
movq -0x28(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x646ac(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x6469b(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x6468d(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x58537(%rip), %rsi     # 0x7ae1f
movl $0x50, %edx
callq 0x10840
movq 0x64667(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x64659(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x64641(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x64631(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x64624(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x64616(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x22b2f
jmp 0x22968
cmpl $0xaa, -0x14(%rbp)
jne 0x2298e
movl $0x1, %edi
callq 0x11320
movq -0x20(%rbp), %rax
movl $0x1, 0xc67c(%rax)
jmp 0x22b28
cmpl $0xb4, -0x14(%rbp)
jne 0x229b4
movl $0x3, %edi
callq 0x11320
movq -0x20(%rbp), %rax
movl $0x3, 0xc67c(%rax)
jmp 0x22b26
cmpl $0xbe, -0x14(%rbp)
jne 0x229da
movl $0x2, %edi
callq 0x11320
movq -0x20(%rbp), %rax
movl $0x2, 0xc67c(%rax)
jmp 0x22b24
cmpl $0xab, -0x14(%rbp)
jne 0x22a00
movl $0x4, %edi
callq 0x11320
movq -0x20(%rbp), %rax
movl $0x4, 0xc67c(%rax)
jmp 0x22b22
cmpl $0xb5, -0x14(%rbp)
jne 0x22a26
movl $0x6, %edi
callq 0x11320
movq -0x20(%rbp), %rax
movl $0x6, 0xc67c(%rax)
jmp 0x22b20
cmpl $0xbf, -0x14(%rbp)
jne 0x22a4c
movl $0x5, %edi
callq 0x11320
movq -0x20(%rbp), %rax
movl $0x5, 0xc67c(%rax)
jmp 0x22b1e
jmp 0x22a4e
leaq 0x583fc(%rip), %rdi     # 0x7ae51
callq 0x10380
movq -0x28(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x644f1(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x644e0(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x644d2(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x5837c(%rip), %rsi     # 0x7ae1f
movl $0x50, %edx
callq 0x10840
movq 0x644ac(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x6449e(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x64486(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x64476(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x64469(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x6445b(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x22b2f
jmp 0x22b20
jmp 0x22b22
jmp 0x22b24
jmp 0x22b26
jmp 0x22b28
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)