// File: sundale[P]gcode/rs274ngc/interp_convert.cc
// Function: Interp::convert_cutter_compensation(int, block_struct*, setup_struct*)
int Interp::convert_cutter_compensation(int g_code,      //!< must be G_40, G_41, or G_42             
                                       block_pointer block,     //!< pointer to a block of RS274 instructions
                                       setup_pointer settings)  //!< pointer to machine settings             
{

  if (g_code == G_40) {
    CHP(convert_cutter_compensation_off(settings));
  } else if (g_code == G_41) {
    CHP(convert_cutter_compensation_on(LEFT, block, settings));
  } else if (g_code == G_42) {
    CHP(convert_cutter_compensation_on(RIGHT, block, settings));
  } else if (g_code == G_41_1) {
    CHP(convert_cutter_compensation_on(LEFT, block, settings));
  } else if (g_code == G_42_1) {
    CHP(convert_cutter_compensation_on(RIGHT, block, settings));
  } else
    ERS("BUG: Code not G40, G41, G41.1, G42, G42.2");

  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpl $0x190, -0x14(%rbp)     # imm = 0x190
jne 0x1ff9c
jmp 0x1febe
movq -0x48(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x11930
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x1ff95
jmp 0x1feda
movq 0x6707f(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x1ff8a
movq 0x6706b(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x6705d(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x59eb4(%rip), %rsi     # 0x79dcc
movl $0x50, %edx
callq 0x10840
movq 0x67037(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x67029(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x67011(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x67001(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x66ff4(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x66fe6(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2044d
jmp 0x1ff97
jmp 0x20446
cmpl $0x19a, -0x14(%rbp)     # imm = 0x19A
jne 0x20092
jmp 0x1ffab
movq -0x48(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl $0x2, %esi
callq 0x10430
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x2008b
jmp 0x1ffd0
movq 0x66f89(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x20080
movq 0x66f75(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x66f67(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x59dbe(%rip), %rsi     # 0x79dcc
movl $0x50, %edx
callq 0x10840
movq 0x66f41(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x66f33(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x66f1b(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x66f0b(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x66efe(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x66ef0(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2044d
jmp 0x2008d
jmp 0x20444
cmpl $0x1a4, -0x14(%rbp)     # imm = 0x1A4
jne 0x20188
jmp 0x200a1
movq -0x48(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl $0x1, %esi
callq 0x10430
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x20181
jmp 0x200c6
movq 0x66e93(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x20176
movq 0x66e7f(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x66e71(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x59cc8(%rip), %rsi     # 0x79dcc
movl $0x50, %edx
callq 0x10840
movq 0x66e4b(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x66e3d(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x66e25(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x66e15(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x66e08(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x66dfa(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2044d
jmp 0x20183
jmp 0x20442
cmpl $0x19b, -0x14(%rbp)     # imm = 0x19B
jne 0x2027e
jmp 0x20197
movq -0x48(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl $0x2, %esi
callq 0x10430
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
je 0x20277
jmp 0x201bc
movq 0x66d9d(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x2026c
movq 0x66d89(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x66d7b(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x59bd2(%rip), %rsi     # 0x79dcc
movl $0x50, %edx
callq 0x10840
movq 0x66d55(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x66d47(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x66d2f(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x66d1f(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x66d12(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x66d04(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x38(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2044d
jmp 0x20279
jmp 0x20440
cmpl $0x1a5, -0x14(%rbp)     # imm = 0x1A5
jne 0x20374
jmp 0x2028d
movq -0x48(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl $0x1, %esi
callq 0x10430
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x2036d
jmp 0x202b2
movq 0x66ca7(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x20362
movq 0x66c93(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x66c85(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x59adc(%rip), %rsi     # 0x79dcc
movl $0x50, %edx
callq 0x10840
movq 0x66c5f(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x66c51(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x66c39(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x66c29(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x66c1c(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x66c0e(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2044d
jmp 0x2036f
jmp 0x2043e
jmp 0x20376
movq -0x48(%rbp), %rdi
leaq 0x59a96(%rip), %rsi     # 0x79e17
movb $0x0, %al
callq 0x10df0
movq 0x66bd1(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x66bc0(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x66bb2(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x59a09(%rip), %rsi     # 0x79dcc
movl $0x50, %edx
callq 0x10840
movq 0x66b8c(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x66b7e(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x66b66(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x66b56(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x66b49(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x66b3b(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x2044d
jmp 0x20440
jmp 0x20442
jmp 0x20444
jmp 0x20446
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)