// File: 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
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq 0x15721(%rip), %rax     # 0x86f60
movb 0xc680(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x71958
jmp 0x71855
callq 0x11e70
cmpl $0x0, %eax
jne 0x71938
jmp 0x71865
leaq 0xe53a(%rip), %rdi      # 0x7fda6
callq 0x10380
movq -0x28(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x156da(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x156c9(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x156bb(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0xe50d(%rip), %rsi      # 0x7fdc7
movl $0x50, %edx
callq 0x10840
movq 0x15695(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x15687(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x1566f(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x1565f(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x15652(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x15644(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x72092
jmp 0x7193a
movq -0x28(%rbp), %rdi
movq 0x1561b(%rip), %rsi     # 0x86f60
callq 0x107c0
movq 0x1560f(%rip), %rax     # 0x86f60
movb $0x0, 0xc680(%rax)
movq 0x15601(%rip), %rax     # 0x86f60
movb 0xc682(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x71a81
jmp 0x71975
callq 0x11e70
cmpl $0x0, %eax
jne 0x71a58
jmp 0x71985
leaq 0xe45a(%rip), %rdi      # 0x7fde6
callq 0x10380
movq -0x28(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x155ba(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x155a9(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x1559b(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0xe3ed(%rip), %rsi      # 0x7fdc7
movl $0x50, %edx
callq 0x10840
movq 0x15575(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x15567(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x1554f(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x1553f(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x15532(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x15524(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x72092
jmp 0x71a5a
movq -0x28(%rbp), %rdi
movq 0x154fb(%rip), %rsi     # 0x86f60
callq 0x115e0
movq -0x28(%rbp), %rdi
callq 0x11b30
movq 0x154e6(%rip), %rax     # 0x86f60
movb $0x0, 0xc682(%rax)
movq 0x154d8(%rip), %rax     # 0x86f60
movb 0xc681(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x71c22
jmp 0x71a9e
callq 0x11e70
cmpl $0x0, %eax
jne 0x71b81
jmp 0x71aae
leaq 0xe356(%rip), %rdi      # 0x7fe0b
callq 0x10380
movq -0x28(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x15491(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x15480(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x15472(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0xe2c4(%rip), %rsi      # 0x7fdc7
movl $0x50, %edx
callq 0x10840
movq 0x1544c(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x1543e(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x15426(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x15416(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x15409(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x153fb(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x72092
jmp 0x71b83
movq 0x153d6(%rip), %rax     # 0x86f60
movb 0xc688(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x71be4
movq 0x153bf(%rip), %rax     # 0x86f60
movl 0xc684(%rax), %edi
movq 0x153b2(%rip), %rax     # 0x86f60
movsd 0xc078(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
setne %al
setp %cl
orb %cl, %al
andb $0x1, %al
movzbl %al, %esi
callq 0x116d0
cvtsi2sd %eax, %xmm0
movq 0x15386(%rip), %rax     # 0x86f60
movsd %xmm0, 0xc078(%rax)
jmp 0x71c14
movq 0x15375(%rip), %rax     # 0x86f60
movl 0xc684(%rax), %edi
movq 0x15368(%rip), %rax     # 0x86f60
movsd 0xc078(%rax), %xmm0
callq 0x10e70
movq 0x15354(%rip), %rax     # 0x86f60
movsd %xmm0, 0xc078(%rax)
movq 0x15345(%rip), %rax     # 0x86f60
movb $0x0, 0xc681(%rax)
jmp 0x71c24
cmpq $0x0, -0x18(%rbp)
jne 0x71cff
movq 0x1532a(%rip), %rax     # 0x86f60
cmpq $0x0, 0x1680(%rax)
jne 0x71cff
jmp 0x71c46
movq 0x15313(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x15302(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x152f4(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0xe146(%rip), %rsi      # 0x7fdc7
movl $0x50, %edx
callq 0x10840
movq 0x152ce(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x152c0(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x152a8(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x15298(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x1528b(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x1527d(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x4, -0x4(%rbp)
jmp 0x72092
jmp 0x71d01
movq 0x15258(%rip), %rax     # 0x86f60
cmpq $0x0, 0x1680(%rax)
je 0x71d36
movq 0x15247(%rip), %rax     # 0x86f60
movq 0x1680(%rax), %rdi
callq 0x10030
movq %rax, %rcx
movq 0x15231(%rip), %rax     # 0x86f60
movq %rcx, 0x3f0(%rax)
movq -0x28(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq 0x1521b(%rip), %rax     # 0x86f60
movq 0x1680(%rax), %rdx
movq 0x1520d(%rip), %r9      # 0x86f60
movq %r9, %rcx
addq $0x1698, %rcx           # imm = 0x1698
movq %r9, %r8
addq $0x4f8, %r8             # imm = 0x4F8
addq $0x1694, %r9            # imm = 0x1694
callq 0x10560
movl %eax, -0x1c(%rbp)
cmpl $0x5, -0x1c(%rbp)
jne 0x71db2
movq 0x151dd(%rip), %rax     # 0x86f60
cmpq $0x0, 0xef78(%rax)
je 0x71db2
movq 0x151cc(%rip), %rax     # 0x86f60
movq 0xef78(%rax), %rdi
callq 0x114b0
movq 0x151b9(%rip), %rax     # 0x86f60
movq $0x0, 0xef78(%rax)
cmpq $0x0, -0x18(%rbp)
je 0x71e0c
jmp 0x71dbb
xorl %eax, %eax
movq 0x1519c(%rip), %rcx     # 0x86f60
cmpl 0x1b6b4(%rcx), %eax
jge 0x71e08
callq 0x11950
movq -0x28(%rbp), %rdi
movl %eax, %ecx
movq -0x18(%rbp), %rax
leaq 0xe051(%rip), %rsi      # 0x7fe33
xorl %edx, %edx
leaq 0xdaef(%rip), %r8       # 0x7f8da
movl $0x34c, %r9d            # imm = 0x34C
leaq 0x164d8(%rip), %r10     # 0x882d0
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x12050
jmp 0x71e0a
jmp 0x71e68
jmp 0x71e0e
xorl %eax, %eax
movq 0x15149(%rip), %rcx     # 0x86f60
cmpl 0x1b6b4(%rcx), %eax
jge 0x71e64
callq 0x11950
movq -0x28(%rbp), %rdi
movl %eax, %ecx
leaq 0xe023(%rip), %rsi      # 0x7fe54
xorl %edx, %edx
leaq 0xdaa0(%rip), %r8       # 0x7f8da
movl $0x34d, %r9d            # imm = 0x34D
leaq 0x16489(%rip), %r10     # 0x882d0
movq 0x15112(%rip), %rax     # 0x86f60
addq $0x1698, %rax           # imm = 0x1698
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x12050
jmp 0x71e66
jmp 0x71e68
cmpl $0x2, -0x1c(%rbp)
je 0x71e78
cmpl $0x0, -0x1c(%rbp)
jne 0x71fc5
movq 0x150e1(%rip), %rax     # 0x86f60
cmpl $0x0, 0x1694(%rax)
je 0x71f80
jmp 0x71e8e
movq -0x28(%rbp), %rdi
movq 0x150c7(%rip), %rcx     # 0x86f60
movq %rcx, %rsi
addq $0x4f8, %rsi            # imm = 0x4F8
movq %rcx, %rdx
addq $0x130, %rdx            # imm = 0x130
callq 0x113d0
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
je 0x71f7c
jmp 0x71ec1
movq 0x15098(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x71f71
movq 0x15084(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x15076(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0xdec8(%rip), %rsi      # 0x7fdc7
movl $0x50, %edx
callq 0x10840
movq 0x15050(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x15042(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x1502a(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x1501a(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x1500d(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x14fff(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x72092
jmp 0x71f7e
jmp 0x71fc0
movq 0x14fd9(%rip), %rax     # 0x86f60
cmpl $0x0, 0x3f8(%rax)
je 0x71fbe
movq 0x14fc9(%rip), %rax     # 0x86f60
movl $0x0, 0x3f8(%rax)
movq 0x14fb8(%rip), %rax     # 0x86f60
movl 0x3fc(%rax), %ecx
addl $0x1, %ecx
movq 0x14fa8(%rip), %rax     # 0x86f60
movl %ecx, 0x3fc(%rax)
jmp 0x71fc0
jmp 0x7208c
cmpl $0x3, -0x1c(%rbp)
jne 0x71fd0
jmp 0x7208a
jmp 0x71fd2
movq 0x14f87(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x72082
movq 0x14f73(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x14f65(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0xddb7(%rip), %rsi      # 0x7fdc7
movl $0x50, %edx
callq 0x10840
movq 0x14f3f(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x14f31(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x14f19(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x14f09(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x14efc(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x14eee(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x72092
jmp 0x7208c
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)