// File: /workspace/github_cpp_makefile_star2_O1/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), %rdi
movzbl (%rsi,%rdi), %r8d
leaq 0x1(%rdi), %rax
movl %eax, (%rdx)
cmpl $0x5c, %r8d
jle 0x2c013
leal -0x5d(%r8), %r9d
cmpl $0x12, %r9d
ja 0x2c041
leaq 0xeef6(%rip), %r8       # 0x3aef4
movslq (%r8,%r9,4), %r9
addq %r8, %r9
jmpq *%r9
movl $0xa, (%rcx)
jmp 0x2c185
leal -0x2a(%r8), %edi
cmpl $0x5, %edi
ja 0x2c064
leaq 0xeeb9(%rip), %r8       # 0x3aedc
movslq (%r8,%rdi,4), %rdi
addq %r8, %rdi
jmpq *%rdi
cmpb $0x2a, (%rsi,%rax)
jne 0x2c152
movl $0x3, (%rcx)
jmp 0x2c183
cmpl $0x78, %r8d
jne 0x2c075
cmpb $0x6f, (%rsi,%rax)
jne 0x2c149
cmpb $0x72, 0x2(%rsi,%rdi)
jne 0x2c149
movl $0x6, (%rcx)
jmp 0x2c0df
testl %r8d, %r8d
jne 0x2c075
leaq 0x102dd(%rip), %rdi     # 0x3c34d
jmp 0x2c199
leaq 0x102e5(%rip), %rdi     # 0x3c361
jmp 0x2c199
movl $0x1, (%rcx)
jmp 0x2c185
movl $0x9, (%rcx)
jmp 0x2c185
movl $0x7, (%rcx)
jmp 0x2c185
cmpb $0x71, (%rsi,%rax)
jne 0x2c15a
movl $0xc, (%rcx)
jmp 0x2c183
cmpb $0x6e, (%rsi,%rax)
jne 0x2c137
cmpb $0x64, 0x2(%rsi,%rdi)
jne 0x2c137
movl $0x5, (%rcx)
jmp 0x2c0df
cmpb $0x6f, (%rsi,%rax)
jne 0x2c140
cmpb $0x64, 0x2(%rsi,%rdi)
jne 0x2c140
movl $0x2, (%rcx)
addl $0x2, (%rdx)
jmp 0x2c185
movzbl (%rsi,%rax), %eax
cmpl $0x74, %eax
je 0x2c175
cmpl $0x65, %eax
jne 0x2c189
movl $0xe, (%rcx)
jmp 0x2c183
movzbl (%rsi,%rax), %eax
cmpl $0x74, %eax
je 0x2c17d
cmpl $0x65, %eax
jne 0x2c192
movl $0xf, (%rcx)
jmp 0x2c183
cmpb $0x72, (%rsi,%rax)
jne 0x2c163
movl $0x8, (%rcx)
jmp 0x2c183
cmpb $0x65, (%rsi,%rax)
jne 0x2c16c
movl $0xd, (%rcx)
jmp 0x2c183
leaq 0x100d7(%rip), %rdi     # 0x3c215
jmp 0x2c199
leaq 0x100f5(%rip), %rdi     # 0x3c23c
jmp 0x2c199
leaq 0x1013a(%rip), %rdi     # 0x3c28a
jmp 0x2c199
movl $0x4, (%rcx)
jmp 0x2c185
leaq 0x10150(%rip), %rdi     # 0x3c2b1
jmp 0x2c199
leaq 0x100f9(%rip), %rdi     # 0x3c263
jmp 0x2c199
leaq 0x10165(%rip), %rdi     # 0x3c2d8
jmp 0x2c199
movl $0xb, (%rcx)
jmp 0x2c183
movl $0x10, (%rcx)
incl (%rdx)
xorl %eax, %eax
jmp 0x2c1ec
leaq 0x10196(%rip), %rdi     # 0x3c326
jmp 0x2c199
leaq 0x10166(%rip), %rdi     # 0x3c2ff
callq 0xa1f0
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
movq 0x17dae(%rip), %rbx     # 0x43f60
movl $0x0, 0xd670(%rbx)
leaq 0xc6d0(%rbx), %rdi
leaq 0xf55e(%rip), %rsi      # 0x3b728
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
movl $0x5, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
nop