// File: /workspace/github_cpp_makefile_star2_O1/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 0xa0b0
testl %eax, %eax
jne 0x106a9
xorl %r15d, %r15d
movsbl (%rbx,%r15), %edi
testl %edi, %edi
je 0x106e4
callq 0xaf50
movb %al, -0x120(%rbp,%r15)
incq %r15
cmpq $0x100, %r15            # imm = 0x100
jne 0x106bc
movl $0x100, %r15d           # imm = 0x100
movl %r15d, %eax
movb $0x0, -0x120(%rbp,%rax)
cmpl $0x2c67736d, -0x120(%rbp) # imm = 0x2C67736D
jne 0x10707
addq $0x4, %rbx
movq %rbx, %rdi
jmp 0x1078e
movl $0x75626564, %eax       # imm = 0x75626564
xorl -0x120(%rbp), %eax
movzwl -0x11c(%rbp), %ecx
xorl $0x2c67, %ecx           # imm = 0x2C67
orl %eax, %ecx
je 0x10772
movl $0x6e697270, %eax       # imm = 0x6E697270
xorl -0x120(%rbp), %eax
movzwl -0x11c(%rbp), %ecx
xorl $0x2c74, %ecx           # imm = 0x2C74
orl %eax, %ecx
je 0x107a3
cmpl $0x2c676f6c, -0x120(%rbp) # imm = 0x2C676F6C
jne 0x107e1
addq $0x4, %rbx
leaq -0x330(%rbp), %r15
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xaa10
movq %r15, %rdi
callq 0xa890
jmp 0x10793
addq $0x6, %rbx
leaq -0x330(%rbp), %r15
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xaa10
movq %r15, %rdi
callq 0xa950
xorl %eax, %eax
addq $0x318, %rsp            # imm = 0x318
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
addq $0x6, %rbx
leaq -0x330(%rbp), %r15
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xaa10
movq 0x337a5(%rip), %rbx     # 0x43f68
movq (%rbx), %rdi
leaq 0x2c928(%rip), %rsi     # 0x3d0f5
movq %r15, %rdx
xorl %eax, %eax
callq 0xaf00
movq (%rbx), %rdi
callq 0xacd0
jmp 0x10793
leaq 0x27d12(%rip), %rsi     # 0x384fa
leaq -0x120(%rbp), %rdi
callq 0x1083a
testl %eax, %eax
je 0x10806
addq $0x8, %rbx
movq %rbx, %rdi
callq 0xaed0
jmp 0x10793
movabsq $0x65736f6c63676f6c, %rax # imm = 0x65736F6C63676F6C
xorq -0x120(%rbp), %rax
movzbl -0x118(%rbp), %ecx
orq %rax, %rcx
je 0x10830
movq %rbx, %rdi
callq 0xb370
jmp 0x10793
callq 0xaa30
jmp 0x10793