// File: /workspace/github_cpp_makefile_star2_O1/sundale[P]gcode/rs274ngc/interp_read.cc
// Function: Interp::read_operation_unary(char*, int*, int*)
int Interp::read_operation_unary(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 'a':
    if ((line[*counter] == 'b') && (line[(*counter) + 1] == 's')) {
      *operation = ABS;
      *counter = (*counter + 2);
    } else if (strncmp((line + *counter), "cos", 3) == 0) {
      *operation = ACOS;
      *counter = (*counter + 3);
    } else if (strncmp((line + *counter), "sin", 3) == 0) {
      *operation = ASIN;
      *counter = (*counter + 3);
    } else if (strncmp((line + *counter), "tan", 3) == 0) {
      *operation = ATAN;
      *counter = (*counter + 3);
    } else
      ERS(NCE_UNKNOWN_WORD_STARTING_WITH_A);
    break;
  case 'c':
    if ((line[*counter] == 'o') && (line[(*counter) + 1] == 's')) {
      *operation = COS;
      *counter = (*counter + 2);
    } else
      ERS(NCE_UNKNOWN_WORD_STARTING_WITH_C);
    break;
  case 'e':
    if ((line[*counter] == 'x') && (line[(*counter) + 1] == 'p')) {
      *operation = EXP;
      *counter = (*counter + 2);
    } else
      ERS(NCE_UNKNOWN_WORD_STARTING_WITH_E);
    break;
  case 'f':
    if ((line[*counter] == 'i') && (line[(*counter) + 1] == 'x')) {
      *operation = FIX;
      *counter = (*counter + 2);
    } else if ((line[*counter] == 'u') && (line[(*counter) + 1] == 'p')) {
      *operation = FUP;
      *counter = (*counter + 2);
    } else
      ERS(NCE_UNKNOWN_WORD_STARTING_WITH_F);
    break;
  case 'l':
    if (line[*counter] == 'n') {
      *operation = LN;
      *counter = (*counter + 1);
    } else
      ERS(NCE_UNKNOWN_WORD_STARTING_WITH_L);
    break;
  case 'r':
    if (strncmp((line + *counter), "ound", 4) == 0) {
      *operation = ROUND;
      *counter = (*counter + 4);
    } else
      ERS(NCE_UNKNOWN_WORD_STARTING_WITH_R);
    break;
  case 's':
    if ((line[*counter] == 'i') && (line[(*counter) + 1] == 'n')) {
      *operation = SIN;
      *counter = (*counter + 2);
    } else if (strncmp((line + *counter), "qrt", 3) == 0) {
      *operation = SQRT;
      *counter = (*counter + 3);
    } else
      ERS(NCE_UNKNOWN_WORD_STARTING_WITH_S);
    break;
  case 't':
    if ((line[*counter] == 'a') && (line[(*counter) + 1] == 'n')) {
      *operation = TAN;
      *counter = (*counter + 2);
    } else
      ERS(NCE_UNKNOWN_WORD_STARTING_WITH_T);
    break;
  default:
    ERS(NCE_UNKNOWN_WORD_WHERE_UNARY_OPERATION_COULD_BE);
  }
  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rcx, %r15
movq %rdx, %r14
movq %rdi, %rbx
movslq (%rdx), %rcx
movzbl (%rsi,%rcx), %edx
leaq 0x1(%rcx), %rax
movl %eax, (%r14)
addl $-0x61, %edx
cmpl $0x13, %edx
ja 0x2c254
movq %rsi, %r12
leaq 0xed18(%rip), %rsi      # 0x3af40
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
cmpb $0x62, (%r12,%rax)
jne 0x2c3b1
cmpb $0x73, 0x2(%r12,%rcx)
jne 0x2c3b1
movl $0x1, (%r15)
jmp 0x2c457
leaq 0x10208(%rip), %rdi     # 0x3c463
jmp 0x2c464
cltq
addq %rax, %r12
leaq 0xe926(%rip), %rsi      # 0x3ab92
movl $0x4, %edx
movq %r12, %rdi
callq 0xa4e0
testl %eax, %eax
je 0x2c412
leaq 0x10184(%rip), %rdi     # 0x3c40c
jmp 0x2c464
cmpb $0x6f, (%r12,%rax)
jne 0x2c362
cmpb $0x73, 0x2(%r12,%rcx)
jne 0x2c362
movl $0x5, (%r15)
jmp 0x2c457
cmpb $0x69, (%r12,%rax)
jne 0x2c36e
cmpb $0x6e, 0x2(%r12,%rcx)
jne 0x2c36e
movl $0xb, (%r15)
jmp 0x2c457
cmpb $0x61, (%r12,%rax)
jne 0x2c399
cmpb $0x6e, 0x2(%r12,%rcx)
jne 0x2c399
movl $0xd, (%r15)
jmp 0x2c457
cmpb $0x78, (%r12,%rax)
jne 0x2c3a5
cmpb $0x70, 0x2(%r12,%rcx)
jne 0x2c3a5
movl $0x6, (%r15)
jmp 0x2c457
movzbl (%r12,%rax), %edx
cmpl $0x75, %edx
je 0x2c448
cmpl $0x69, %edx
jne 0x2c45d
cmpb $0x78, 0x2(%r12,%rcx)
jne 0x2c443
movl $0x7, (%r15)
jmp 0x2c457
cmpb $0x6e, (%r12,%rax)
jne 0x2c409
movl $0x9, (%r15)
incl (%r14)
jmp 0x2c4c4
leaq 0x1002f(%rip), %rdi     # 0x3c398
jmp 0x2c464
addq %rax, %r12
leaq 0xe4b1(%rip), %rsi      # 0x3a829
movl $0x3, %edx
movq %r12, %rdi
callq 0xa4e0
testl %eax, %eax
je 0x2c422
leaq 0x10095(%rip), %rdi     # 0x3c429
jmp 0x2c464
leaq 0x100a6(%rip), %rdi     # 0x3c446
jmp 0x2c464
leaq 0x10009(%rip), %rdi     # 0x3c3b5
jmp 0x2c464
addq %rax, %r12
leaq 0xffb8(%rip), %rsi      # 0x3c373
movl $0x3, %edx
movq %r12, %rdi
callq 0xa4e0
testl %eax, %eax
je 0x2c42e
leaq 0xffa4(%rip), %rsi      # 0x3c377
movl $0x3, %edx
movq %r12, %rdi
callq 0xa4e0
testl %eax, %eax
je 0x2c43a
leaq 0xfb92(%rip), %rsi      # 0x3bf7d
movl $0x3, %edx
movq %r12, %rdi
callq 0xa4e0
testl %eax, %eax
je 0x2c4b9
leaq 0xff74(%rip), %rdi      # 0x3c37b
jmp 0x2c464
leaq 0xffdf(%rip), %rdi      # 0x3c3ef
jmp 0x2c464
movl $0xa, (%r15)
addl $0x4, (%r14)
jmp 0x2c4c4
movl $0xc, (%r15)
jmp 0x2c4c0
movl $0x2, (%r15)
jmp 0x2c4c0
movl $0x3, (%r15)
jmp 0x2c4c0
cmpb $0x75, %dl
jne 0x2c45d
cmpb $0x70, 0x1(%r12,%rax)
jne 0x2c45d
movl $0x8, (%r15)
addl $0x2, (%r14)
jmp 0x2c4c4
leaq 0xff6e(%rip), %rdi      # 0x3c3d2
callq 0xa1f0
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
movq 0x17ae3(%rip), %rbx     # 0x43f60
movl $0x0, 0xd670(%rbx)
leaq 0xc6d0(%rbx), %rdi
leaq 0xf2e4(%rip), %rsi      # 0x3b779
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
movl $0x5, %eax
jmp 0x2c4c6
movl $0x4, (%r15)
addl $0x3, (%r14)
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop