// File: sundale[P]gcode/rs274ngc/interp_check.cc
// Function: Interp::check_g_codes(block_struct*, setup_struct*)
int Interp::check_g_codes(block_pointer block,   //!< pointer to a block to be checked
                         setup_pointer settings)        //!< pointer to machine settings
{
  int mode0, mode1;
  int p_int;

  mode0 = block->g_modes[0];
  mode1 = block->g_modes[1];
  if (mode0 == -1) {
  } else if (mode0 == G_4) {
    CHKS((block->p_number == -1.0), NCE_DWELL_TIME_MISSING_WITH_G4);
  } else if (mode0 == G_10) {
    p_int = (int) (block->p_number + 0.0001);
    CHKS((block->l_number != 2 && block->l_number != 1 && block->l_number != 20 && block->l_number != 10), "Line with G10 does not have L1, L10, L2, or L20");
    CHKS((((block->p_number + 0.0001) - p_int) > 0.0002),  "P value not an integer with G10");
    CHKS((((block->l_number == 2 || block->l_number == 20) && ((p_int < 1) || (p_int > 9)))), "P value out of range with G10 L2 or G10 L20");
    CHKS((((block->l_number == 1 || block->l_number == 10) && p_int < 1)), "P value out of range with G10 L1 or G10 L10");
  } else if (mode0 == G_28) {
  } else if (mode0 == G_30) {
  } else if (mode0 == G_5_3) { 
      CHKS(((mode1 != G_5_2) && (mode1 != -1)), _("Between G5.2 and G5.3 codes, only additional G5.2 codes are allowed."));
  } else if (mode1 == G_5_2){
  } else if (mode0 == G_28_1 || mode0 == G_30_1) {
  } else if (mode0 == G_53) {
    CHKS(((block->motion_to_be != G_0) && (block->motion_to_be != G_1)),
        NCE_MUST_USE_G0_OR_G1_WITH_G53);
    CHKS(((block->g_modes[3] == G_91) ||
         ((block->g_modes[3] != G_90) &&
          (settings->distance_mode == MODE_INCREMENTAL))),
        NCE_CANNOT_USE_G53_INCREMENTAL);
  } else if (mode0 == G_92) {
  } else if ((mode0 == G_92_1) || (mode0 == G_92_2) || (mode0 == G_92_3)) {
  } else
    ERS(NCE_BUG_BAD_G_CODE_MODAL_GROUP_0);
  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movl 0x150(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x18(%rbp), %rax
movl 0x154(%rax), %eax
movl %eax, -0x28(%rbp)
cmpl $-0x1, -0x24(%rbp)
jne 0x13671
jmp 0x1401b
cmpl $0x28, -0x24(%rbp)
jne 0x1377d
jmp 0x1367d
movq -0x18(%rbp), %rax
movsd 0x210(%rax), %xmm0
movsd 0x651cf(%rip), %xmm1    # 0x78860
ucomisd %xmm1, %xmm0
jne 0x13776
jp 0x13776
jmp 0x136a3
leaq 0x651be(%rip), %rdi     # 0x78868
callq 0x10380
movq -0x38(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x7389c(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x7388b(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x7387d(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x6518b(%rip), %rsi     # 0x78883
movl $0x50, %edx
callq 0x10840
movq 0x73857(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x73849(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x73831(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x73821(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x73814(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x73806(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x14022
jmp 0x13778
jmp 0x14019
cmpl $0x64, -0x24(%rbp)
jne 0x13bb2
movq -0x18(%rbp), %rax
movsd 0x650bd(%rip), %xmm0    # 0x78850
addsd 0x210(%rax), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x2, 0x1c8(%rax)
je 0x138b3
movq -0x18(%rbp), %rax
cmpl $0x1, 0x1c8(%rax)
je 0x138b3
movq -0x18(%rbp), %rax
cmpl $0x14, 0x1c8(%rax)
je 0x138b3
movq -0x18(%rbp), %rax
cmpl $0xa, 0x1c8(%rax)
je 0x138b3
jmp 0x137e8
movq -0x38(%rbp), %rdi
leaq 0x650c8(%rip), %rsi     # 0x788bb
movb $0x0, %al
callq 0x10df0
movq 0x7375f(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x7374e(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x73740(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x6504e(%rip), %rsi     # 0x78883
movl $0x50, %edx
callq 0x10840
movq 0x7371a(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x7370c(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x736f4(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x736e4(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x736d7(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x736c9(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x14022
jmp 0x138b5
jmp 0x138b7
movq -0x18(%rbp), %rax
movsd 0x64f8d(%rip), %xmm0    # 0x78850
addsd 0x210(%rax), %xmm0
cvtsi2sdl -0x2c(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd 0x64f7c(%rip), %xmm1    # 0x78858
ucomisd %xmm1, %xmm0
jbe 0x139b3
jmp 0x138e8
movq -0x38(%rbp), %rdi
leaq 0x64ff8(%rip), %rsi     # 0x788eb
movb $0x0, %al
callq 0x10df0
movq 0x7365f(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x7364e(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x73640(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x64f4e(%rip), %rsi     # 0x78883
movl $0x50, %edx
callq 0x10840
movq 0x7361a(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x7360c(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x735f4(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x735e4(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x735d7(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x735c9(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x14022
jmp 0x139b5
jmp 0x139b7
movq -0x18(%rbp), %rax
cmpl $0x2, 0x1c8(%rax)
je 0x139d5
movq -0x18(%rbp), %rax
cmpl $0x14, 0x1c8(%rax)
jne 0x13ab2
cmpl $0x1, -0x2c(%rbp)
jl 0x139e5
cmpl $0x9, -0x2c(%rbp)
jle 0x13ab2
jmp 0x139e7
movq -0x38(%rbp), %rdi
leaq 0x64f19(%rip), %rsi     # 0x7890b
movb $0x0, %al
callq 0x10df0
movq 0x73560(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x7354f(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x73541(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x64e4f(%rip), %rsi     # 0x78883
movl $0x50, %edx
callq 0x10840
movq 0x7351b(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x7350d(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x734f5(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x734e5(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x734d8(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x734ca(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x14022
jmp 0x13ab4
jmp 0x13ab6
movq -0x18(%rbp), %rax
cmpl $0x1, 0x1c8(%rax)
je 0x13ad4
movq -0x18(%rbp), %rax
cmpl $0xa, 0x1c8(%rax)
jne 0x13bab
cmpl $0x1, -0x2c(%rbp)
jge 0x13bab
jmp 0x13ae0
movq -0x38(%rbp), %rdi
leaq 0x64e4c(%rip), %rsi     # 0x78937
movb $0x0, %al
callq 0x10df0
movq 0x73467(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x73456(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x73448(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x64d56(%rip), %rsi     # 0x78883
movl $0x50, %edx
callq 0x10840
movq 0x73422(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x73414(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x733fc(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x733ec(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x733df(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x733d1(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x14022
jmp 0x13bad
jmp 0x14017
cmpl $0x118, -0x24(%rbp)     # imm = 0x118
jne 0x13bc0
jmp 0x14015
cmpl $0x12c, -0x24(%rbp)     # imm = 0x12C
jne 0x13bce
jmp 0x14013
cmpl $0x35, -0x24(%rbp)
jne 0x13cca
jmp 0x13bda
cmpl $0x34, -0x28(%rbp)
je 0x13cc3
cmpl $-0x1, -0x28(%rbp)
je 0x13cc3
jmp 0x13bf0
leaq 0x64d6c(%rip), %rdi     # 0x78963
callq 0x10380
movq -0x38(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x7334f(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x7333e(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x73330(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x64c3e(%rip), %rsi     # 0x78883
movl $0x50, %edx
callq 0x10840
movq 0x7330a(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x732fc(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x732e4(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x732d4(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x732c7(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x732b9(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x14022
jmp 0x13cc5
jmp 0x14011
cmpl $0x34, -0x28(%rbp)
jne 0x13cd5
jmp 0x1400f
cmpl $0x119, -0x24(%rbp)     # imm = 0x119
je 0x13ce7
cmpl $0x12d, -0x24(%rbp)     # imm = 0x12D
jne 0x13cec
jmp 0x1400d
cmpl $0x212, -0x24(%rbp)     # imm = 0x212
jne 0x13f07
jmp 0x13cfb
movq -0x18(%rbp), %rax
cmpl $0x0, 0x1d8(%rax)
je 0x13df2
movq -0x18(%rbp), %rax
cmpl $0xa, 0x1d8(%rax)
je 0x13df2
jmp 0x13d1f
leaq 0x64c82(%rip), %rdi     # 0x789a8
callq 0x10380
movq -0x38(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x73220(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x7320f(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x73201(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x64b0f(%rip), %rsi     # 0x78883
movl $0x50, %edx
callq 0x10840
movq 0x731db(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x731cd(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x731b5(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x731a5(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x73198(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x7318a(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x14022
jmp 0x13df4
jmp 0x13df6
movq -0x18(%rbp), %rax
cmpl $0x38e, 0x15c(%rax)     # imm = 0x38E
je 0x13e2b
movq -0x18(%rbp), %rax
cmpl $0x384, 0x15c(%rax)     # imm = 0x384
je 0x13f00
movq -0x20(%rbp), %rax
cmpl $0x1, 0x668(%rax)
jne 0x13f00
jmp 0x13e2d
leaq 0x64b8f(%rip), %rdi     # 0x789c3
callq 0x10380
movq -0x38(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x73112(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x73101(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x730f3(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x64a01(%rip), %rsi     # 0x78883
movl $0x50, %edx
callq 0x10840
movq 0x730cd(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x730bf(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x730a7(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x73097(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x7308a(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x7307c(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x14022
jmp 0x13f02
jmp 0x1400b
cmpl $0x398, -0x24(%rbp)     # imm = 0x398
jne 0x13f15
jmp 0x14009
cmpl $0x399, -0x24(%rbp)     # imm = 0x399
je 0x13f30
cmpl $0x39a, -0x24(%rbp)     # imm = 0x39A
je 0x13f30
cmpl $0x39b, -0x24(%rbp)     # imm = 0x39B
jne 0x13f35
jmp 0x14007
jmp 0x13f37
leaq 0x64aa0(%rip), %rdi     # 0x789de
callq 0x10380
movq -0x38(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x73008(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x72ff7(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x72fe9(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x648f7(%rip), %rsi     # 0x78883
movl $0x50, %edx
callq 0x10840
movq 0x72fc3(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x72fb5(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x72f9d(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x72f8d(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x72f80(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x72f72(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x14022
jmp 0x14009
jmp 0x1400b
jmp 0x1400d
jmp 0x1400f
jmp 0x14011
jmp 0x14013
jmp 0x14015
jmp 0x14017
jmp 0x14019
jmp 0x1401b
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)