// File: /workspace/github_cpp_makefile_star2_O2/sundale[P]gcode/rs274ngc/interp_read.cc
// Function: Interp::read_operation(char*, int*, int*)
int Interp::read_operation(char *line,   //!< string: line of RS274/NGC code being processed
                          int *counter, //!< pointer to a counter for position on the line 
                          int *operation)       //!< pointer to operation to be read               
{
  char c;

  c = line[*counter];
  *counter = (*counter + 1);
  switch (c) {
  case '+':
    *operation = PLUS;
    break;
  case '-':
    *operation = MINUS;
    break;
  case '/':
    *operation = DIVIDED_BY;
    break;
  case '*':
    if (line[*counter] == '*') {
      *operation = POWER;
      *counter = (*counter + 1);
    } else
      *operation = TIMES;
    break;
  case ']':
    *operation = RIGHT_BRACKET;
    break;
  case 'a':
    if ((line[*counter] == 'n') && (line[(*counter) + 1] == 'd')) {
      *operation = AND2;
      *counter = (*counter + 2);
    } else
      ERS(NCE_UNKNOWN_OPERATION_NAME_STARTING_WITH_A);
    break;
  case 'm':
    if ((line[*counter] == 'o') && (line[(*counter) + 1] == 'd')) {
      *operation = MODULO;
      *counter = (*counter + 2);
    } else
      ERS(NCE_UNKNOWN_OPERATION_NAME_STARTING_WITH_M);
    break;
  case 'o':
    if (line[*counter] == 'r') {
      *operation = NON_EXCLUSIVE_OR;
      *counter = (*counter + 1);
    } else
      ERS(NCE_UNKNOWN_OPERATION_NAME_STARTING_WITH_O);
    break;
  case 'x':
    if ((line[*counter] == 'o') && (line[(*counter) + 1] == 'r')) {
      *operation = EXCLUSIVE_OR;
      *counter = (*counter + 2);
    } else
      ERS(NCE_UNKNOWN_OPERATION_NAME_STARTING_WITH_X);
    break;

      /* relational operators */
    case 'e':
      if(line[*counter] == 'q')
	{
	  *operation = EQ;
	  *counter = (*counter + 1);
	}
      else
        ERS(NCE_UNKNOWN_OPERATION_NAME_STARTING_WITH_E);
      break;
    case 'n':
      if(line[*counter] == 'e')
	{
	  *operation = NE;
	  *counter = (*counter + 1);
	}
      else
        ERS(NCE_UNKNOWN_OPERATION_NAME_STARTING_WITH_N);
      break;
    case 'g':
      if(line[*counter] == 'e')
	{
	  *operation = GE;
	  *counter = (*counter + 1);
	}
      else if(line[*counter] == 't')
	{
	  *operation = GT;
	  *counter = (*counter + 1);
	}
      else
        ERS(NCE_UNKNOWN_OPERATION_NAME_STARTING_WITH_G);
      break;
    case 'l':
      if(line[*counter] == 'e')
	{
	  *operation = LE;
	  *counter = (*counter + 1);
	}
      else if(line[*counter] == 't')
	{
	  *operation = LT;
	  *counter = (*counter + 1);
	}
      else
        ERS(NCE_UNKNOWN_OPERATION_NAME_STARTING_WITH_L);
      break;

  case 0:
    ERS(NCE_UNCLOSED_EXPRESSION);
  default:
    ERS(NCE_UNKNOWN_OPERATION);
  }
  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movslq (%rdx), %rax
movzbl (%rsi,%rax), %r8d
leaq 0x1(%rax), %rdi
movl %edi, (%rdx)
leal -0x5d(%r8), %r9d
cmpl $0x12, %r9d
ja 0x260a3
leaq 0xde66(%rip), %r8       # 0x33ef4
movslq (%r8,%r9,4), %r9
addq %r8, %r9
jmpq *%r9
movl $0xa, (%rcx)
jmp 0x26227
leal -0x2a(%r8), %r9d
cmpl $0x5, %r9d
ja 0x260d3
leaq 0xde28(%rip), %rax      # 0x33edc
movslq (%rax,%r9,4), %r8
addq %rax, %r8
jmpq *%r8
cmpb $0x2a, (%rsi,%rdi)
jne 0x2620f
movl $0x3, (%rcx)
jmp 0x26225
testl %r8d, %r8d
je 0x261d0
cmpl $0x78, %r8d
jne 0x26102
cmpb $0x6f, (%rsi,%rdi)
jne 0x261eb
cmpb $0x72, 0x2(%rsi,%rax)
jne 0x261eb
movl $0x6, (%rcx)
jmp 0x261b3
leaq 0xf258(%rip), %rdi      # 0x35361
jmp 0x2623b
cmpb $0x72, (%rsi,%rdi)
jne 0x261f4
movl $0x8, (%rcx)
jmp 0x26225
cmpb $0x71, (%rsi,%rdi)
jne 0x261fd
movl $0xc, (%rcx)
jmp 0x26225
movzbl (%rsi,%rdi), %eax
cmpl $0x74, %eax
je 0x26217
cmpl $0x65, %eax
jne 0x2622b
movl $0xf, (%rcx)
jmp 0x26225
movzbl (%rsi,%rdi), %eax
cmpl $0x74, %eax
je 0x2621f
cmpl $0x65, %eax
jne 0x26234
movl $0xe, (%rcx)
jmp 0x26225
cmpb $0x6e, (%rsi,%rdi)
jne 0x261d9
cmpb $0x64, 0x2(%rsi,%rax)
jne 0x261d9
movl $0x5, (%rcx)
jmp 0x261b3
cmpb $0x65, (%rsi,%rdi)
jne 0x26206
movl $0xd, (%rcx)
jmp 0x26225
cmpb $0x6f, (%rsi,%rdi)
jne 0x261e2
cmpb $0x64, 0x2(%rsi,%rax)
jne 0x261e2
movl $0x2, (%rcx)
addl $0x2, (%rdx)
jmp 0x26227
movl $0x1, (%rcx)
jmp 0x26227
movl $0x7, (%rcx)
jmp 0x26227
movl $0x9, (%rcx)
jmp 0x26227
leaq 0xf176(%rip), %rdi      # 0x3534d
jmp 0x2623b
leaq 0xf035(%rip), %rdi      # 0x35215
jmp 0x2623b
leaq 0xf053(%rip), %rdi      # 0x3523c
jmp 0x2623b
leaq 0xf098(%rip), %rdi      # 0x3528a
jmp 0x2623b
leaq 0xf068(%rip), %rdi      # 0x35263
jmp 0x2623b
leaq 0xf0ad(%rip), %rdi      # 0x352b1
jmp 0x2623b
leaq 0xf0cb(%rip), %rdi      # 0x352d8
jmp 0x2623b
movl $0x4, (%rcx)
jmp 0x26227
movl $0x10, (%rcx)
jmp 0x26225
movl $0xb, (%rcx)
incl (%rdx)
xorl %eax, %eax
jmp 0x2627f
leaq 0xf0cd(%rip), %rdi      # 0x352ff
jmp 0x2623b
leaq 0xf0eb(%rip), %rdi      # 0x35326
callq 0xb220
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xb8e0
movq 0x16d0c(%rip), %rbx     # 0x3cf60
leaq 0xc6d0(%rbx), %rdi
leaq 0xe4c6(%rip), %rsi      # 0x34728
pushq $0x50
popq %rdx
callq 0xb940
andw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
pushq $0x5
popq %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq