// File: /workspace/github_cpp_makefile_star2_O1/sundale[P]gcode/rs274ngc/interp_internal.cc
// Function: Interp::enhance_block(block_struct*, setup_struct*)
int Interp::enhance_block(block_pointer block,   //!< pointer to a block to be checked 
                         setup_pointer settings)        //!< pointer to machine settings      
{
  int axis_flag;
  int ijk_flag;
  int polar_flag;
  int mode_zero_covets_axes;
  int mode0;
  int mode1;

  if(block->radius_flag || block->theta_flag) {
      // someday, tediously add polar support for other planes here:
      CHKS((!_readers[(int)'x'] || !_readers[(int)'y']), _("Cannot use polar coordinate on a machine lacking X or Y axes"));
      CHKS(((settings->plane != CANON_PLANE_XY)), _("Cannot use polar coordinate except in G17 plane"));
      CHKS(((block->x_flag)), _("Cannot specify both polar coordinate and X word"));
      CHKS(((block->y_flag)), _("Cannot specify both polar coordinate and Y word"));
  }

  axis_flag = ((block->x_flag == ON) || (block->y_flag == ON) ||
               (block->z_flag == ON) || (block->a_flag == ON) ||
               (block->b_flag == ON) || (block->c_flag == ON) ||
               (block->u_flag == ON) || (block->v_flag == ON) ||
               (block->w_flag == ON));
  polar_flag = (block->radius_flag == ON) || (block->theta_flag == ON);
  ijk_flag = ((block->i_flag == ON) || (block->j_flag == ON) ||
              (block->k_flag == ON));
  mode0 = block->g_modes[0];
  mode1 = block->g_modes[1];
  mode_zero_covets_axes =
    ((mode0 == G_10) || (mode0 == G_28) || (mode0 == G_30)
     || (mode0 == G_92));

  if (mode1 != -1) {
    if (mode1 == G_80) {
      CHKS(((polar_flag || axis_flag) && (!mode_zero_covets_axes)),
          NCE_CANNOT_USE_AXIS_VALUES_WITH_G80);
      CHKS((polar_flag && mode0 == G_92), _("Polar coordinates can only be used for motion"));
      CHKS(((!axis_flag) && (mode0 == G_92)), NCE_ALL_AXES_MISSING_WITH_G92);
    } else {
      CHKS(mode_zero_covets_axes,
          NCE_CANNOT_USE_TWO_G_CODES_THAT_BOTH_USE_AXIS_VALUES);
      CHKS(((!axis_flag && !polar_flag) && 
            mode1 != G_0 && mode1 != G_1 && 
            mode1 != G_2 && mode1 != G_3 && mode1 != G_5_2),
          NCE_ALL_AXES_MISSING_WITH_MOTION_CODE);
    }
    block->motion_to_be = mode1;
  } else if (mode_zero_covets_axes) {   /* other 3 can get by without axes but not G92 */
    CHKS((polar_flag && mode0 == G_92), _("Polar coordinates can only be used for motion"));
    CHKS(((!axis_flag) && (block->g_modes[0] == G_92)), NCE_ALL_AXES_MISSING_WITH_G92);
  } else if (axis_flag || polar_flag) {
    CHKS(((settings->motion_mode == -1)
         || (settings->motion_mode == G_80)) && (block->g_modes[8] != G_43_1),
        NCE_CANNOT_USE_AXIS_VALUES_WITHOUT_A_G_CODE_THAT_USES_THEM);
    if (block->g_modes[8] != G_43_1) {
       block->motion_to_be = settings->motion_mode;
    }
  } else if (!axis_flag && !polar_flag && ijk_flag && (settings->motion_mode == G_2 || settings->motion_mode == G_3)) {
    // this is a block like simply "i1" which should be accepted if we're in arc mode
      block->motion_to_be = settings->motion_mode;
  }
  CHKS((polar_flag && block->motion_to_be == -1), _("Polar coordinates can only be used for motion"));
  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x2a0(%rsi), %edi
testl %edi, %edi
jne 0x28a66
cmpl $0x0, 0x2b0(%rsi)
je 0x28b18
cmpq $0x0, 0x788(%rbx)
je 0x28a95
cmpq $0x0, 0x798(%rbx)
je 0x28a95
cmpl $0x1, 0xc67c(%rdx)
jne 0x28a9e
cmpb $0x1, 0x270(%rsi)
jne 0x28b06
leaq 0x12171(%rip), %rdi     # 0x3ac04
jmp 0x28aa5
leaq 0x120fb(%rip), %rdi     # 0x3ab97
jmp 0x28aa5
leaq 0x1212f(%rip), %rdi     # 0x3abd4
callq 0xa1f0
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
movq 0x1b4a2(%rip), %rdi     # 0x43f60
movl $0x0, 0xd670(%rdi)
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0x122d3(%rip), %rsi     # 0x3ada9
movl $0x50, %edx
callq 0xa8a0
movq 0x1b479(%rip), %rax     # 0x43f60
movw $0x0, 0xc71f(%rax)
movl $0x1, 0xd670(%rax)
movl $0x5, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
cmpb $0x1, 0x280(%rsi)
jne 0x28b18
leaq 0x1211e(%rip), %rdi     # 0x3ac34
jmp 0x28aa5
movb $0x1, %cl
cmpb $0x0, 0x270(%rsi)
movb $0x1, %al
jne 0x28b60
cmpb $0x0, 0x280(%rsi)
jne 0x28b60
cmpb $0x0, 0x290(%rsi)
jne 0x28b60
cmpb $0x0, (%rsi)
jne 0x28b60
cmpb $0x0, 0x10(%rsi)
jne 0x28b60
cmpb $0x0, 0x20(%rsi)
jne 0x28b60
cmpb $0x0, 0x244(%rsi)
jne 0x28b60
cmpb $0x0, 0x250(%rsi)
jne 0x28b60
movb 0x260(%rsi), %al
cmpl $0x1, %edi
je 0x28b6f
cmpl $0x1, 0x2b0(%rsi)
sete %cl
movb $0x1, %r9b
cmpb $0x0, 0x198(%rsi)
jne 0x28b8b
cmpb $0x0, 0x1a8(%rsi)
jne 0x28b8b
movb 0x1b8(%rsi), %r9b
movl 0x150(%rsi), %r8d
movl 0x154(%rsi), %edi
xorl %r10d, %r10d
cmpl $0x12b, %r8d            # imm = 0x12B
jg 0x28bb5
cmpl $0x64, %r8d
je 0x28bca
cmpl $0x118, %r8d            # imm = 0x118
je 0x28bca
jmp 0x28bc7
cmpl $0x12c, %r8d            # imm = 0x12C
je 0x28bca
cmpl $0x398, %r8d            # imm = 0x398
je 0x28bca
movb $0x1, %r10b
cmpl $-0x1, %edi
je 0x28bf3
cmpl $0x320, %edi            # imm = 0x320
jne 0x28c3e
movl %ecx, %edx
orb %al, %dl
andb %r10b, %dl
cmpb $0x1, %dl
jne 0x28c89
leaq 0x12076(%rip), %rdi     # 0x3ac64
jmp 0x28aa5
testb %r10b, %r10b
je 0x28caf
orb %cl, %al
testb $0x1, %al
je 0x28cea
movl 0x1798(%rdx), %edi
cmpl $0x320, %edi            # imm = 0x320
je 0x28c19
cmpl $-0x1, %edi
jne 0x28c29
cmpl $0x1af, 0x170(%rsi)     # imm = 0x1AF
jne 0x28d28
cmpl $0x1af, 0x170(%rsi)     # imm = 0x1AF
jne 0x28cff
jmp 0x28d05
testb %r10b, %r10b
je 0x28cde
orb %cl, %al
testb $0x1, %al
jne 0x28cff
cmpl $0x1e, %edi
je 0x28cff
cmpl $0x34, %edi
je 0x28cff
cmpl $0x14, %edi
je 0x28cff
testl %edi, %edi
je 0x28cff
cmpl $0xa, %edi
je 0x28cff
leaq 0x12079(%rip), %rdi     # 0x3acfd
jmp 0x28aa5
cmpl $0x398, %r8d            # imm = 0x398
setne %dl
movl %ecx, %r9d
xorb $0x1, %r9b
orb %dl, %r9b
je 0x28d1c
cmpl $0x398, %r8d            # imm = 0x398
setne %dl
orb %al, %dl
je 0x28cd2
jmp 0x28cff
cmpl $0x398, %r8d            # imm = 0x398
setne %dl
movl %ecx, %edi
xorb $0x1, %dil
orb %dl, %dil
je 0x28d1c
cmpl $0x398, %r8d            # imm = 0x398
setne %dl
orb %dl, %al
jne 0x28d05
leaq 0x11fd9(%rip), %rdi     # 0x3acb2
jmp 0x28aa5
leaq 0x11fe7(%rip), %rdi     # 0x3accc
jmp 0x28aa5
testb %r9b, %r9b
je 0x28d05
movl 0x1798(%rdx), %edi
cmpl $0x1e, %edi
je 0x28cff
cmpl $0x14, %edi
jne 0x28d05
movl %edi, 0x1d8(%rsi)
xorl %eax, %eax
testb %cl, %cl
je 0x28aff
cmpl $-0x1, 0x1d8(%rsi)
jne 0x28aff
leaq 0x11f61(%rip), %rdi     # 0x3ac84
jmp 0x28aa5
leaq 0x11ff0(%rip), %rdi     # 0x3ad1f
jmp 0x28aa5