// File: /workspace/github_cpp_makefile_star2_O3/sundale[P]gcode/rs274ngc/interp_read.cc
// Function: Interp::read_text(char const*, _IO_FILE*, char*, char*, int*)
int Interp::read_text(
    const char *command,       //!< a string which may have input text, or null
    FILE * inport,     //!< a file pointer for an input file, or null
    char *raw_line,    //!< array to write raw input line into
    char *line,        //!< array for input line to be processed in
    int *length)       //!< a pointer to an integer to be set
{
  int index;
  int n;

  if (command == NULL) {
    if (fgets(raw_line, LINELEN, inport) == NULL) {
      if(_setup.skipping_to_sub)
      {
        ERS("EOF in file:%s seeking o-word: o<%s> from line: %d",
                 _setup.filename,
                 _setup.skipping_to_sub,
                 _setup.skipping_start);
      }
      if (_setup.percent_flag == ON)
      {
        ERS(NCE_FILE_ENDED_WITH_NO_PERCENT_SIGN);
      }
      else
      {
        ERS(NCE_FILE_ENDED_WITH_NO_PERCENT_SIGN_OR_PROGRAM_END);
      }
    }
    _setup.sequence_number++;   /* moved from version1, was outside if */
    if (strlen(raw_line) == (LINELEN - 1)) { // line is too long. need to finish reading the line to recover
      for (; fgetc(inport) != '\n';) {
      }                         // could also look for EOF
      ERS(NCE_COMMAND_TOO_LONG);
    }
    for (index = (strlen(raw_line) - 1);        // index set on last char
         (index >= 0) && (isspace(raw_line[index]));
         index--) { // remove space at end of raw_line, especially CR & LF
      raw_line[index] = 0;
    }
    strcpy(line, raw_line);
    CHP(close_and_downcase(line));
    if ((line[0] == '%') && (line[1] == 0) && (_setup.percent_flag == ON)) {
        FINISH();
        return INTERP_ENDFILE;
    }
  } else {
    CHKS((strlen(command) >= LINELEN), NCE_COMMAND_TOO_LONG);
    strcpy(raw_line, command);
    strcpy(line, command);
    CHP(close_and_downcase(line));
  }

  _setup.parameter_occurrence = 0;      /* initialize parameter buffer */

  // just in case free the strings
  if(_setup.named_parameter_occurrence != 0)
  {
      for (n = 0; n < _setup.named_parameter_occurrence; n++)
      {
          // free the string
          free(_setup.named_parameters[n]);
      }
  }
  _setup.named_parameter_occurrence = 0;      /* initialize parameter buffer */

  if ((line[0] == 0) || ((line[0] == '/') && (GET_BLOCK_DELETE() == ON)))
    *length = 0;
  else
    *length = strlen(line);

  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r9, -0x30(%rbp)
movq %r8, %r14
movq %rcx, %r12
movq %rdi, %r15
testq %rsi, %rsi
je 0x2a716
movq %rsi, %rbx
movq %rsi, %rdi
callq 0xa4a0
cmpq $0xff, %rax
jb 0x2a774
leaq 0xf5ae(%rip), %rdi      # 0x39ca6
callq 0xa1f0
movq %r15, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
movq 0x1684f(%rip), %rbx     # 0x40f60
jmp 0x2a7db
movq %rdx, %r13
movq %r12, %rdi
movl $0xff, %esi
callq 0xb0f0
movq 0x16833(%rip), %rbx     # 0x40f60
testq %rax, %rax
je 0x2a7ac
incl 0xc6b4(%rbx)
movq %r12, %rdi
callq 0xa4a0
cmpq $0xfe, %rax
jne 0x2a811
movq %r13, %rdi
callq 0xb0d0
cmpl $0xa, %eax
jne 0x2a74c
leaq 0xf546(%rip), %rdi      # 0x39ca6
callq 0xa1f0
movq %r15, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
jmp 0x2a7db
movq %r12, %rdi
movq %rbx, %rsi
callq 0xa9d0
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa9d0
movq %r15, %rdi
movq %r14, %rsi
callq 0xa750
testl %eax, %eax
je 0x2a8ef
movl %eax, %r15d
movq 0x167b9(%rip), %rbx     # 0x40f60
jmp 0x2a852
movq 0xef78(%rbx), %rcx
testq %rcx, %rcx
je 0x2a8b3
movl 0xef80(%rbx), %r8d
leaq 0x680(%rbx), %rdx
leaq 0xf453(%rip), %rsi      # 0x39c24
movq %r15, %rdi
xorl %eax, %eax
callq 0xa850
leaq 0xc6d0(%rbx), %rdi
leaq 0xe44f(%rip), %rsi      # 0x38c38
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
movl $0x5, %r15d
jmp 0x2a95e
decl %eax
js 0x2a835
movl %eax, %r13d
incq %r13
movsbl -0x1(%r12,%r13), %edi
callq 0xa0b0
testl %eax, %eax
je 0x2a835
movb $0x0, -0x1(%r12,%r13)
decq %r13
jg 0x2a81b
movq %r14, %rdi
movq %r12, %rsi
callq 0xa9d0
movq %r15, %rdi
movq %r14, %rsi
callq 0xa750
testl %eax, %eax
je 0x2a8cc
movl %eax, %r15d
movslq 0xd670(%rbx), %rax
cmpq $0x30, %rax
jg 0x2a95e
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
leaq (%rbx,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0xe3bb(%rip), %rsi      # 0x38c38
movl $0x50, %edx
callq 0xa8a0
movslq 0xd670(%rbx), %rax
leaq (%rax,%rax,4), %rcx
shlq $0x4, %rcx
xorl %edx, %edx
movb %dl, 0xc71f(%rbx,%rcx)
incl %eax
movl %eax, 0xd670(%rbx)
movb %dl, 0xc720(%rbx,%rcx)
jmp 0x2a95e
cmpb $0x1, 0xc678(%rbx)
jne 0x2a970
leaq 0xf390(%rip), %rdi      # 0x39c57
jmp 0x2a760
cmpb $0x25, (%r14)
jne 0x2a8ef
cmpb $0x0, 0x1(%r14)
jne 0x2a8ef
cmpb $0x1, 0xc678(%rbx)
jne 0x2a8ef
callq 0xac50
movl $0x3, %r15d
jmp 0x2a95e
movq 0x1666a(%rip), %rbx     # 0x40f60
movl $0x0, 0xc0f0(%rbx)
cmpl $0x0, 0xc350(%rbx)
jle 0x2a928
xorl %r15d, %r15d
movq 0xc358(%rbx,%r15,8), %rdi
callq 0xacf0
incq %r15
movslq 0xc350(%rbx), %rax
cmpq %rax, %r15
jl 0x2a90c
movl $0x0, 0xc350(%rbx)
movzbl (%r14), %ebx
testl %ebx, %ebx
je 0x2a955
cmpl $0x2f, %ebx
jne 0x2a94a
xorl %ebx, %ebx
callq 0xa230
testb %al, %al
jne 0x2a955
movq %r14, %rdi
callq 0xa4a0
movq %rax, %rbx
movq -0x30(%rbp), %rax
movl %ebx, (%rax)
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xf300(%rip), %rdi      # 0x39c77
jmp 0x2a760