// File: 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
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x68d0a
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rdx
movl $0xff, %esi
callq 0x11b60
cmpq $0x0, %rax
jne 0x68a70
movq 0x1e7ba(%rip), %rax     # 0x86f60
cmpq $0x0, 0xef78(%rax)
je 0x688ab
jmp 0x687b6
movq -0x50(%rbp), %rdi
movq 0x1e79f(%rip), %rax     # 0x86f60
movq 0xef78(%rax), %rcx
movq 0x1e791(%rip), %rax     # 0x86f60
movl 0xef80(%rax), %r8d
leaq 0x160dc(%rip), %rsi     # 0x7e8b9
movq 0x1e77c(%rip), %rdx     # 0x86f60
addq $0x680, %rdx            # imm = 0x680
movb $0x0, %al
callq 0x10df0
movq 0x1e767(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x1e756(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x1e748(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x160bf(%rip), %rsi     # 0x7e8ec
movl $0x50, %edx
callq 0x10840
movq 0x1e722(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x1e714(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x1e6fc(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x1e6ec(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x1e6df(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x1e6d1(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x68fa8
movq 0x1e6ae(%rip), %rax     # 0x86f60
movb 0xc678(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x6899b
jmp 0x688c8
leaq 0x16060(%rip), %rdi     # 0x7e92f
callq 0x10380
movq -0x50(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x1e677(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x1e666(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x1e658(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x15fcf(%rip), %rsi     # 0x7e8ec
movl $0x50, %edx
callq 0x10840
movq 0x1e632(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x1e624(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x1e60c(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x1e5fc(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x1e5ef(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x1e5e1(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x68fa8
jmp 0x6899d
leaq 0x15fab(%rip), %rdi     # 0x7e94f
callq 0x10380
movq -0x50(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x1e5a2(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x1e591(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x1e583(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x15efa(%rip), %rsi     # 0x7e8ec
movl $0x50, %edx
callq 0x10840
movq 0x1e55d(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x1e54f(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x1e537(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x1e527(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x1e51a(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x1e50c(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x68fa8
movq 0x1e4e9(%rip), %rax     # 0x86f60
movl 0xc6b4(%rax), %ecx
addl $0x1, %ecx
movq 0x1e4d9(%rip), %rax     # 0x86f60
movl %ecx, 0xc6b4(%rax)
movq -0x28(%rbp), %rdi
callq 0x10740
cmpq $0xfe, %rax
jne 0x68b89
jmp 0x68aa4
movq -0x20(%rbp), %rdi
callq 0x11b40
cmpl $0xa, %eax
je 0x68ab4
jmp 0x68aa4
jmp 0x68ab6
leaq 0x15ec1(%rip), %rdi     # 0x7e97e
callq 0x10380
movq -0x50(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x1e489(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x1e478(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x1e46a(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x15de1(%rip), %rsi     # 0x7e8ec
movl $0x50, %edx
callq 0x10840
movq 0x1e444(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x1e436(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x1e41e(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x1e40e(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x1e401(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x1e3f3(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x68fa8
movq -0x28(%rbp), %rdi
callq 0x10740
subq $0x1, %rax
movl %eax, -0x3c(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x3c(%rbp)
movb %al, -0x51(%rbp)
jl 0x68bbe
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsbl (%rax,%rcx), %edi
callq 0x10120
cmpl $0x0, %eax
setne %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0x68bc7
jmp 0x68bde
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x68b99
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x11080
movq -0x50(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x10c20
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x68cc2
jmp 0x68c07
movq 0x1e352(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x68cb7
movq 0x1e33e(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x1e330(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x15ca7(%rip), %rsi     # 0x7e8ec
movl $0x50, %edx
callq 0x10840
movq 0x1e30a(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x1e2fc(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x1e2e4(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x1e2d4(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x1e2c7(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x1e2b9(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x68fa8
jmp 0x68cc4
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x25, %eax
jne 0x68d05
movq -0x30(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x68d05
movq 0x1e27c(%rip), %rax     # 0x86f60
movb 0xc678(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x68d05
callq 0x113f0
movl $0x3, -0x4(%rbp)
jmp 0x68fa8
jmp 0x68eed
jmp 0x68d0c
movq -0x18(%rbp), %rdi
callq 0x10740
cmpq $0xff, %rax
jb 0x68df6
jmp 0x68d23
leaq 0x15c54(%rip), %rdi     # 0x7e97e
callq 0x10380
movq -0x50(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x1e21c(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x1e20b(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x1e1fd(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x15b74(%rip), %rsi     # 0x7e8ec
movl $0x50, %edx
callq 0x10840
movq 0x1e1d7(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x1e1c9(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x1e1b1(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x1e1a1(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x1e194(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x1e186(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x68fa8
jmp 0x68df8
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x11080
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x11080
movq -0x50(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x10c20
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
je 0x68ee9
jmp 0x68e2e
movq 0x1e12b(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x68ede
movq 0x1e117(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x1e109(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x15a80(%rip), %rsi     # 0x7e8ec
movl $0x50, %edx
callq 0x10840
movq 0x1e0e3(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x1e0d5(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x1e0bd(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x1e0ad(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x1e0a0(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x1e092(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x48(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x68fa8
jmp 0x68eeb
jmp 0x68eed
movq 0x1e06c(%rip), %rax     # 0x86f60
movl $0x0, 0xc0f0(%rax)
movq 0x1e05b(%rip), %rax     # 0x86f60
cmpl $0x0, 0xc350(%rax)
je 0x68f4c
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq 0x1e041(%rip), %rcx     # 0x86f60
cmpl 0xc350(%rcx), %eax
jge 0x68f4a
movslq -0x40(%rbp), %rcx
movq 0x1e02e(%rip), %rax     # 0x86f60
movq 0xc358(%rax,%rcx,8), %rdi
callq 0x114b0
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x68f15
jmp 0x68f4c
movq 0x1e00d(%rip), %rax     # 0x86f60
movl $0x0, 0xc350(%rax)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x68f84
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
jne 0x68f90
callq 0x103f0
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x68f90
movq -0x38(%rbp), %rax
movl $0x0, (%rax)
jmp 0x68fa1
movq -0x30(%rbp), %rdi
callq 0x10740
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)