// File: /workspace/github_cpp_makefile_star2_O3/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 0x10309
xorl %r15d, %r15d
movsbl (%rbx,%r15), %edi
testl %edi, %edi
je 0x10344
callq 0xaf50
movb %al, -0x120(%rbp,%r15)
incq %r15
cmpq $0x100, %r15            # imm = 0x100
jne 0x1031c
movl $0x100, %r15d           # imm = 0x100
movl %r15d, %eax
movb $0x0, -0x120(%rbp,%rax)
movl -0x120(%rbp), %eax
cmpl $0x2c67736d, %eax       # imm = 0x2C67736D
jne 0x10368
addq $0x4, %rbx
movq %rbx, %rdi
jmp 0x103ea
movl $0x75626564, %ecx       # imm = 0x75626564
xorl -0x120(%rbp), %ecx
movzwl -0x11c(%rbp), %edx
xorl $0x2c67, %edx           # imm = 0x2C67
orl %ecx, %edx
je 0x103ce
movl $0x6e697270, %ecx       # imm = 0x6E697270
xorl -0x120(%rbp), %ecx
movzwl -0x11c(%rbp), %edx
xorl $0x2c74, %edx           # imm = 0x2C74
orl %ecx, %edx
je 0x103ff
cmpl $0x2c676f6c, %eax       # imm = 0x2C676F6C
jne 0x1043d
addq $0x4, %rbx
leaq -0x330(%rbp), %r15
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xaa10
movq %r15, %rdi
callq 0xa890
jmp 0x103ef
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 0x30b49(%rip), %rbx     # 0x40f68
movq (%rbx), %rdi
leaq 0x29cc1(%rip), %rsi     # 0x3a0ea
movq %r15, %rdx
xorl %eax, %eax
callq 0xaf00
movq (%rbx), %rdi
callq 0xacd0
jmp 0x103ef
leaq 0x250b6(%rip), %rsi     # 0x354fa
leaq -0x120(%rbp), %rdi
callq 0x10496
testl %eax, %eax
je 0x10462
addq $0x8, %rbx
movq %rbx, %rdi
callq 0xaed0
jmp 0x103ef
movabsq $0x65736f6c63676f6c, %rax # imm = 0x65736F6C63676F6C
xorq -0x120(%rbp), %rax
movzbl -0x118(%rbp), %ecx
orq %rax, %rcx
je 0x1048c
movq %rbx, %rdi
callq 0xb370
jmp 0x103ef
callq 0xaa30
jmp 0x103ef