// File: /workspace/github_cpp_makefile_star2_O1/sundale[P]gcode/rs274ngc/rs274ngc_pre.cc
// Function: Interp::read(char const*)
int Interp::read(const char *command)  //!< may be NULL or a string to read
{
  static char name[] = "Interp::read";
  int read_status;

  if (_setup.probe_flag == ON) {
    CHKS((GET_EXTERNAL_QUEUE_EMPTY() == 0),
        NCE_QUEUE_IS_NOT_EMPTY_AFTER_PROBING);
    set_probe_data(&_setup);
    _setup.probe_flag = OFF;
  }
  if (_setup.toolchange_flag == ON) {
    CHKS((GET_EXTERNAL_QUEUE_EMPTY() == 0),
         _("Queue is not empty after tool change"));
    refresh_actual_position(&_setup);
    load_tool_table();
    _setup.toolchange_flag = OFF;
  }
  if (_setup.input_flag == ON) {
    CHKS((GET_EXTERNAL_QUEUE_EMPTY() == 0),
        NCE_QUEUE_IS_NOT_EMPTY_AFTER_INPUT);
    if (_setup.input_digital == ON) { // we are checking for a digital input
	_setup.parameters[5399] =
	    GET_EXTERNAL_DIGITAL_INPUT(_setup.input_index,
				      (_setup.parameters[5399] != 0.0));
    } else { // checking for analog input
	_setup.parameters[5399] =
	    GET_EXTERNAL_ANALOG_INPUT(_setup.input_index, _setup.parameters[5399]);
    }
    _setup.input_flag = OFF;
  }
  CHKN(((command == NULL) && (_setup.file_pointer == NULL)),
      INTERP_FILE_NOT_OPEN);

  if(_setup.file_pointer)
  {
     _setup.block1.offset = ftell(_setup.file_pointer);
  }

  read_status =
    read_text(command, _setup.file_pointer, _setup.linetext,
              _setup.blocktext, &_setup.line_length);

  if (read_status == INTERP_ERROR && _setup.skipping_to_sub) {
    free(_setup.skipping_to_sub);
    _setup.skipping_to_sub = 0;
  }

  if(command)logDebug("%s:[cmd]:|%s|", name, command);
  else logDebug("%s:|%s|", name, _setup.linetext);

  if ((read_status == INTERP_EXECUTE_FINISH)
      || (read_status == INTERP_OK)) {
    if (_setup.line_length != 0) {
      CHP(parse_line(_setup.blocktext, &(_setup.block1), &_setup));
    }

    else // Blank line (zero length)
    {
          /* RUM - this case reached when the block delete '/' character 
             is used, or READ_FULL_COMMENT is OFF and a comment is the
             only content of a line. 
             If a block o-type is in effect, block->o_number needs to be 
             incremented to allow o-extensions to work. 
             Note that the the block is 'refreshed' by init_block(),
             not created new, so this is a legal operation on block1. */
        if (_setup.block1.o_type != O_none)
        {
            // Clear o_type, this isn't line isn't a command...
            _setup.block1.o_type = 0;
            // increment o_number
            _setup.block1.o_number++;
        }
    }
  } else if (read_status == INTERP_ENDFILE);
  else
    ERP(read_status);
  return read_status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r12
movq %rdi, %r14
movq 0x11c8d(%rip), %rbx     # 0x43f60
cmpb $0x1, 0xc680(%rbx)
jne 0x322fb
callq 0xb310
testl %eax, %eax
je 0x32377
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa500
movb $0x0, 0xc680(%rbx)
cmpb $0x1, 0xc682(%rbx)
jne 0x32327
callq 0xb310
testl %eax, %eax
je 0x32380
movq %r14, %rdi
movq %rbx, %rsi
callq 0xad90
movq %r14, %rdi
callq 0xb0c0
movb $0x0, 0xc682(%rbx)
cmpb $0x1, 0xc681(%rbx)
jne 0x323f3
callq 0xb310
testl %eax, %eax
je 0x32389
movl 0xc684(%rbx), %edi
movsd 0xc078(%rbx), %xmm0
cmpb $0x1, 0xc688(%rbx)
jne 0x323df
xorpd %xmm1, %xmm1
cmpneqsd %xmm1, %xmm0
movq %xmm0, %rsi
andl $0x1, %esi
callq 0xae30
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
jmp 0x323e4
leaq 0xbb2b(%rip), %rdi      # 0x3dea9
jmp 0x32390
leaq 0xbb43(%rip), %rdi      # 0x3deca
jmp 0x32390
leaq 0xbb5f(%rip), %rdi      # 0x3deef
callq 0xa1f0
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
movl $0x0, 0xd670(%rbx)
leaq 0xc6d0(%rbx), %rdi
leaq 0xbd26(%rip), %rsi      # 0x3e0dd
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
movl $0x5, %r15d
jmp 0x3263e
callq 0xa8b0
movsd %xmm0, 0xc078(%rbx)
movb $0x0, 0xc681(%rbx)
movq 0x1680(%rbx), %rdi
movq %r12, %rax
orq %rdi, %rax
jne 0x32442
movl $0x0, 0xd670(%rbx)
leaq 0xc6d0(%rbx), %rdi
leaq 0xbcc3(%rip), %rsi      # 0x3e0dd
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
movl $0x4, %r15d
jmp 0x3263e
testq %rdi, %rdi
je 0x32453
callq 0xa030
movq %rax, 0x3f0(%rbx)
movq 0x1680(%rbx), %rdx
leaq 0x1698(%rbx), %rcx
leaq 0x4f8(%rbx), %r13
leaq 0x1694(%rbx), %r9
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %r8
callq 0xa340
movl %eax, %r15d
cmpl $0x5, %eax
sete %al
movq 0xef78(%rbx), %rdi
testq %rdi, %rdi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x324aa
callq 0xacf0
movq $0x0, 0xef78(%rbx)
movl 0x1b6b4(%rbx), %eax
testq %r12, %r12
je 0x324e8
testl %eax, %eax
jle 0x3252f
callq 0xaf80
leaq 0x1278b(%rip), %r10     # 0x44c50
leaq 0xba4b(%rip), %rsi      # 0x3df17
leaq 0xb5af(%rip), %r8       # 0x3da82
movq %r14, %rdi
xorl %edx, %edx
movl %eax, %ecx
movl $0x34c, %r9d            # imm = 0x34C
xorl %eax, %eax
pushq %r12
pushq %r10
jmp 0x32526
testl %eax, %eax
jle 0x3252f
callq 0xaf80
movl $0x1698, %r10d          # imm = 0x1698
addq 0x11a62(%rip), %r10     # 0x43f60
leaq 0x1274b(%rip), %r11     # 0x44c50
leaq 0xba2c(%rip), %rsi      # 0x3df38
leaq 0xb56f(%rip), %r8       # 0x3da82
movq %r14, %rdi
xorl %edx, %edx
movl %eax, %ecx
movl $0x34d, %r9d            # imm = 0x34D
xorl %eax, %eax
pushq %r10
pushq %r11
callq 0xb470
addq $0x10, %rsp
testl $0xfffffffd, %r15d      # imm = 0xFFFFFFFD
je 0x325a3
cmpl $0x3, %r15d
je 0x3263e
movslq 0xd670(%rbx), %rax
cmpq $0x30, %rax
jg 0x3263e
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
leaq (%rbx,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0xbb70(%rip), %rsi      # 0x3e0dd
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 0x3263e
cmpl $0x0, 0x1694(%rbx)
je 0x32625
leaq 0x130(%rbx), %rdx
movq %r14, %rdi
movq %r13, %rsi
movq %rbx, %rcx
callq 0xac40
testl %eax, %eax
je 0x3263e
movl %eax, %r14d
movslq 0xd670(%rbx), %rax
cmpq $0x30, %rax
jg 0x32620
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
leaq (%rbx,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0xbaee(%rip), %rsi      # 0x3e0dd
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)
movl %r14d, %r15d
jmp 0x3263e
cmpl $0x0, 0x3f8(%rbx)
je 0x3263e
movl $0x0, 0x3f8(%rbx)
incl 0x3fc(%rbx)
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq