// File: /workspace/github_cpp_makefile_star2_O2/sundale[P]gcode/rs274ngc/interp_convert.cc
// Function: Interp::convert_comment(char*)
int Interp::convert_comment(char *comment)       //!< string with comment
{
  enum
  { LC_SIZE = 256, EX_SIZE = 2*LC_SIZE};            // 256 from comment[256] in rs274ngc.hh
  char lc[LC_SIZE+1];
  char expanded[EX_SIZE+1];
  char MSG_STR[] = "msg,";

  //!!!KL add two -- debug => same as msg
  //!!!KL         -- print => goes to stderr
  char DEBUG_STR[] = "debug,";
  char PRINT_STR[] = "print,";
  char LOG_STR[] = "log,";
  char LOGOPEN_STR[] = "logopen,";
  char LOGCLOSE_STR[] = "logclose";
  int m, n, start;

  // step over leading white space in comment
  m = 0;
  while (isspace(comment[m]))
    m++;
  start = m;
  // copy lowercase comment to lc[]
  for (n = 0; n < LC_SIZE && comment[m] != 0; m++, n++) {
    lc[n] = tolower(comment[m]);
  }
  lc[n] = 0;                    // null terminate

  // compare with MSG, SYSTEM, DEBUG, PRINT
  if (startswith(lc, MSG_STR)) {
    MESSAGE(comment + start + strlen(MSG_STR));
    return INTERP_OK;
  }
  else if (startswith(lc, DEBUG_STR))
  {
      convert_param_comment(comment+start+strlen(DEBUG_STR), expanded,
                            EX_SIZE);
      MESSAGE(expanded);
      return INTERP_OK;
  }
  else if (startswith(lc, PRINT_STR)) 
  {
      convert_param_comment(comment+start+strlen(PRINT_STR), expanded,
                            EX_SIZE);
      fprintf(stdout, "%s\n", expanded);
      fflush(stdout);
      return INTERP_OK;
  }
  else if (startswith(lc, LOG_STR))
  {
      convert_param_comment(comment+start+strlen(LOG_STR), expanded,
                            EX_SIZE);
      LOG(expanded);
      return INTERP_OK;
  }
  else if (startswith(lc, LOGOPEN_STR))
  {
      LOGOPEN(comment + start + strlen(LOGOPEN_STR));
      return INTERP_OK;
  }
  else if (streq(lc, LOGCLOSE_STR))
  {
      LOGCLOSE();
      return INTERP_OK;
  }
  // else it's a real comment
  enqueue_COMMENT(comment + start);
  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x318, %rsp            # imm = 0x318
movq %rsi, %rbx
movq %rdi, %r14
decq %rbx
movsbl 0x1(%rbx), %edi
incq %rbx
callq 0xb0c0
testl %eax, %eax
jne 0x10fe5
xorl %r15d, %r15d
cmpq $0x100, %r15            # imm = 0x100
je 0x1101c
movsbl (%rbx,%r15), %edi
testl %edi, %edi
je 0x1101c
callq 0xc080
movb %al, -0x120(%rbp,%r15)
incq %r15
jmp 0x10ff8
movb $0x0, -0x120(%rbp,%r15)
leaq 0x204c0(%rip), %rsi     # 0x314ec
leaq -0x120(%rbp), %rdi
callq 0x11178
testl %eax, %eax
je 0x11045
addq $0x4, %rbx
movq %rbx, %rdi
jmp 0x11078
leaq 0x204a5(%rip), %rsi     # 0x314f1
leaq -0x120(%rbp), %rdi
callq 0x11178
testl %eax, %eax
je 0x1108d
addq $0x6, %rbx
leaq -0x330(%rbp), %r15
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xbad0
movq %r15, %rdi
callq 0xb9f0
xorl %eax, %eax
addq $0x318, %rsp            # imm = 0x318
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x20464(%rip), %rsi     # 0x314f8
leaq -0x120(%rbp), %rdi
callq 0x11178
testl %eax, %eax
je 0x110e2
addq $0x6, %rbx
leaq -0x330(%rbp), %r15
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xbad0
movq 0x2bea4(%rip), %rbx     # 0x3cf68
movq (%rbx), %rdi
leaq 0x2501c(%rip), %rsi     # 0x360ea
movq %r15, %rdx
xorl %eax, %eax
callq 0xc030
movq (%rbx), %rdi
callq 0xbdc0
jmp 0x1107d
leaq 0x20416(%rip), %rsi     # 0x314ff
leaq -0x120(%rbp), %rdi
callq 0x11178
testl %eax, %eax
je 0x1111f
addq $0x4, %rbx
leaq -0x330(%rbp), %r15
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xbad0
movq %r15, %rdi
callq 0xb930
jmp 0x1107d
leaq 0x203de(%rip), %rsi     # 0x31504
leaq -0x120(%rbp), %rdi
callq 0x11178
testl %eax, %eax
je 0x11147
addq $0x8, %rbx
movq %rbx, %rdi
callq 0xbff0
jmp 0x1107d
leaq 0x203bf(%rip), %rsi     # 0x3150d
leaq -0x120(%rbp), %rdi
pushq $0x9
popq %rdx
callq 0xbc00
testl %eax, %eax
je 0x1116e
movq %rbx, %rdi
callq 0xc4d0
jmp 0x1107d
callq 0xbaf0
jmp 0x1107d