// File: /workspace/github_cpp_makefile_star2_O3/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 0x28a4d
leal -0x5d(%r8), %r9d
cmpl $0x12, %r9d
ja 0x28a7b
leaq 0xf4bc(%rip), %r8       # 0x37ef4
movslq (%r8,%r9,4), %r9
addq %r8, %r9
jmpq *%r9
movl $0xa, (%rcx)
jmp 0x28bbf
leal -0x2a(%r8), %edi
cmpl $0x5, %edi
ja 0x28a9e
leaq 0xf47f(%rip), %r8       # 0x37edc
movslq (%r8,%rdi,4), %rdi
addq %r8, %rdi
jmpq *%rdi
cmpb $0x2a, (%rsi,%rax)
jne 0x28b8c
movl $0x3, (%rcx)
jmp 0x28bbd
cmpl $0x78, %r8d
jne 0x28aaf
cmpb $0x6f, (%rsi,%rax)
jne 0x28b83
cmpb $0x72, 0x2(%rsi,%rdi)
jne 0x28b83
movl $0x6, (%rcx)
jmp 0x28b19
testl %r8d, %r8d
jne 0x28aaf
leaq 0x108a3(%rip), %rdi     # 0x3934d
jmp 0x28bd3
leaq 0x108ab(%rip), %rdi     # 0x39361
jmp 0x28bd3
movl $0x1, (%rcx)
jmp 0x28bbf
movl $0x9, (%rcx)
jmp 0x28bbf
movl $0x7, (%rcx)
jmp 0x28bbf
cmpb $0x71, (%rsi,%rax)
jne 0x28b94
movl $0xc, (%rcx)
jmp 0x28bbd
cmpb $0x6e, (%rsi,%rax)
jne 0x28b71
cmpb $0x64, 0x2(%rsi,%rdi)
jne 0x28b71
movl $0x5, (%rcx)
jmp 0x28b19
cmpb $0x6f, (%rsi,%rax)
jne 0x28b7a
cmpb $0x64, 0x2(%rsi,%rdi)
jne 0x28b7a
movl $0x2, (%rcx)
addl $0x2, (%rdx)
jmp 0x28bbf
movzbl (%rsi,%rax), %eax
cmpl $0x74, %eax
je 0x28baf
cmpl $0x65, %eax
jne 0x28bc3
movl $0xe, (%rcx)
jmp 0x28bbd
movzbl (%rsi,%rax), %eax
cmpl $0x74, %eax
je 0x28bb7
cmpl $0x65, %eax
jne 0x28bcc
movl $0xf, (%rcx)
jmp 0x28bbd
cmpb $0x72, (%rsi,%rax)
jne 0x28b9d
movl $0x8, (%rcx)
jmp 0x28bbd
cmpb $0x65, (%rsi,%rax)
jne 0x28ba6
movl $0xd, (%rcx)
jmp 0x28bbd
leaq 0x1069d(%rip), %rdi     # 0x39215
jmp 0x28bd3
leaq 0x106bb(%rip), %rdi     # 0x3923c
jmp 0x28bd3
leaq 0x10700(%rip), %rdi     # 0x3928a
jmp 0x28bd3
movl $0x4, (%rcx)
jmp 0x28bbf
leaq 0x10716(%rip), %rdi     # 0x392b1
jmp 0x28bd3
leaq 0x106bf(%rip), %rdi     # 0x39263
jmp 0x28bd3
leaq 0x1072b(%rip), %rdi     # 0x392d8
jmp 0x28bd3
movl $0xb, (%rcx)
jmp 0x28bbd
movl $0x10, (%rcx)
incl (%rdx)
xorl %eax, %eax
jmp 0x28c1c
leaq 0x1075c(%rip), %rdi     # 0x39326
jmp 0x28bd3
leaq 0x1072c(%rip), %rdi     # 0x392ff
callq 0xa1f0
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
movq 0x18374(%rip), %rbx     # 0x40f60
leaq 0xc6d0(%rbx), %rdi
leaq 0xfb2e(%rip), %rsi      # 0x38728
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