// File: /workspace/github_cpp_makefile_star2_O3/sundale[P]gcode/rs274ngc/rs274ngc_pre.cc
// Function: Interp::execute(char const*)
int Interp::execute(const char *command)
{
  int status;
  int n;
  int MDImode = 0;

  if (NULL != command) {
    MDImode = 1;
    status = read(command);
    if (status != INTERP_OK) {
      return status;
    }
  }

  logDebug("MDImode = 1");
  logDebug("Interp::execute(%s)", command);
  // process control functions -- will skip if skipping
  //  if (_setup.block1.o_number != 0)
  if ((_setup.block1.o_number != 0) || (_setup.block1.o_name != 0) )
    {
      CHP(convert_control_functions(&(_setup.block1), &_setup));

#if 1
      // let MDI code call subroutines.
      // !!!KL not clear what happens if last execution failed while in
      // !!!KL a subroutine

      // NOTE: the last executed file will still be open, because "close"
      // is really a lazy close.
    
      logDebug("!!!KL Open file is:%s:", _setup.filename);
      logDebug("MDImode = %d", MDImode);
      while(MDImode && _setup.call_level) // we are still in a subroutine
      {
          status = read(0);  // reads from current file and calls parse
          if (status != INTERP_OK)
	    {
               return status;
	    }
          status = execute();  // special handling for mdi errors
          if (status != INTERP_OK) {
               reset();
               CHP(status);
          }
      }
#endif
      return INTERP_OK;
    }

  // skip if skipping
  if(_setup.skipping_o)
    {
      logDebug("skipping to line: %d", _setup.skipping_o);
      return INTERP_OK;
    }

  for (n = 0; n < _setup.parameter_occurrence; n++)
  {  // copy parameter settings from parameter buffer into parameter table
    _setup.parameters[_setup.parameter_numbers[n]]
          = _setup.parameter_values[n];
  }

  logDebug("_setup.named_parameter_occurrence = %d",
           _setup.named_parameter_occurrence);
  for (n = 0; n < _setup.named_parameter_occurrence; n++)
  {  // copy parameter settings from parameter buffer into parameter table

      logDebug("storing param");
      logDebug("storing param:|%s|", _setup.named_parameters[n]);
    CHP(store_named_param(_setup.named_parameters[n],
                          _setup.named_parameter_values[n]));

    // free the string
      logDebug("freeing param[%d]:|%s|:0x%x", n, _setup.named_parameters[n],
               _setup.named_parameters[n]);
    free(_setup.named_parameters[n]);
  }

  _setup.named_parameter_occurrence = 0;

  if (_setup.line_length != 0) {        /* line not blank */
    status = execute_block(&(_setup.block1), &_setup);
    write_g_codes(&(_setup.block1), &_setup);
    write_m_codes(&(_setup.block1), &_setup);
    write_settings(&_setup);
    if ((status != INTERP_OK) &&
        (status != INTERP_EXECUTE_FINISH) && (status != INTERP_EXIT))
      ERP(status);
  } else                        /* blank line is OK */
    status = INTERP_OK;
  return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r12
movq %rdi, %r14
testq %rsi, %rsi
je 0x2e4a7
movq %r14, %rdi
movq %r12, %rsi
callq 0xa130
testl %eax, %eax
je 0x2e4ac
movl %eax, %r15d
jmp 0x2e879
xorl %r13d, %r13d
jmp 0x2e4b2
movl $0x1, %r13d
movq 0x12aa7(%rip), %rbx     # 0x40f60
cmpl $0x0, 0x1b6b4(%rbx)
jle 0x2e51d
callq 0xaf80
leaq 0xc545(%rip), %rsi      # 0x3aa13
leaq 0xc55d(%rip), %r8       # 0x3aa32
movq %r14, %rdi
xorl %edx, %edx
movl %eax, %ecx
movl $0xdf, %r9d
xorl %eax, %eax
callq 0xb470
cmpl $0x0, 0x1b6b4(%rbx)
jle 0x2e51d
callq 0xaf80
movq %r12, (%rsp)
leaq 0xc540(%rip), %rsi      # 0x3aa42
leaq 0xc529(%rip), %r8       # 0x3aa32
movq %r14, %rdi
xorl %edx, %edx
movl %eax, %ecx
movl $0xe0, %r9d
xorl %eax, %eax
callq 0xb470
cmpl $0x0, 0x3fc(%rbx)
jne 0x2e585
cmpq $0x0, 0x400(%rbx)
jne 0x2e585
cmpq $0x0, 0xef70(%rbx)
je 0x2e6b0
cmpl $0x0, 0x1b6b4(%rbx)
jle 0x2e876
callq 0xaf80
movq 0xef70(%rbx), %rcx
movq %rcx, (%rsp)
leaq 0xc551(%rip), %rsi      # 0x3aab3
leaq 0xc4c9(%rip), %r8       # 0x3aa32
xorl %r15d, %r15d
movq %r14, %rdi
xorl %edx, %edx
movl %eax, %ecx
movl $0x105, %r9d            # imm = 0x105
xorl %eax, %eax
callq 0xb470
jmp 0x2e879
leaq 0x130(%rbx), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0xb280
testl %eax, %eax
je 0x2e5ff
movl %eax, %r15d
movslq 0xd670(%rbx), %rax
cmpq $0x30, %rax
jg 0x2e879
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
leaq (%rbx,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0xca73(%rip), %rsi      # 0x3b03c
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 0x2e879
cmpl $0x0, 0x1b6b4(%rbx)
jle 0x2e66e
callq 0xaf80
leaq 0x680(%rbx), %rcx
movq %rcx, (%rsp)
leaq 0xc44a(%rip), %rsi      # 0x3aa69
leaq 0xc40c(%rip), %r8       # 0x3aa32
movq %r14, %rdi
xorl %edx, %edx
movl %eax, %ecx
movl $0xef, %r9d
xorl %eax, %eax
callq 0xb470
cmpl $0x0, 0x1b6b4(%rbx)
jle 0x2e66e
callq 0xaf80
movl %r13d, (%rsp)
leaq 0xc440(%rip), %rsi      # 0x3aa93
leaq 0xc3d8(%rip), %r8       # 0x3aa32
movq %r14, %rdi
xorl %edx, %edx
movl %eax, %ecx
movl $0xf0, %r9d
xorl %eax, %eax
callq 0xb470
xorl %r15d, %r15d
testq %r12, %r12
je 0x2e879
cmpl $0x0, 0xef90(%rbx)
je 0x2e879
movq %r14, %rdi
xorl %esi, %esi
callq 0xa130
testl %eax, %eax
jne 0x2e49f
movq %r14, %rdi
xorl %esi, %esi
callq 0xadb0
testl %eax, %eax
jne 0x2e88b
xorl %r15d, %r15d
jmp 0x2e67a
movslq 0xc0f0(%rbx), %rax
testq %rax, %rax
jle 0x2e6e0
xorl %ecx, %ecx
movsd 0xc1c0(%rbx,%rcx,8), %xmm0
movslq 0xc0f4(%rbx,%rcx,4), %rdx
movsd %xmm0, 0x17c0(%rbx,%rdx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x2e6be
cmpl $0x0, 0x1b6b4(%rbx)
jle 0x2e719
callq 0xaf80
movl 0xc350(%rbx), %ecx
movl %ecx, (%rsp)
leaq 0xc3dd(%rip), %rsi      # 0x3aadb
leaq 0xc32d(%rip), %r8       # 0x3aa32
movq %r14, %rdi
xorl %edx, %edx
movl %eax, %ecx
movl $0x110, %r9d            # imm = 0x110
xorl %eax, %eax
callq 0xb470
cmpl $0x0, 0xc350(%rbx)
jle 0x2e818
leaq 0xc305(%rip), %r13      # 0x3aa32
xorl %r12d, %r12d
cmpl $0x0, 0x1b6b4(%rbx)
jle 0x2e794
callq 0xaf80
movq %r14, %rdi
leaq 0xc3cd(%rip), %rsi      # 0x3ab15
xorl %edx, %edx
movl %eax, %ecx
movq %r13, %r8
movl $0x114, %r9d            # imm = 0x114
xorl %eax, %eax
callq 0xb470
cmpl $0x0, 0x1b6b4(%rbx)
jle 0x2e794
callq 0xaf80
movq 0xc358(%rbx,%r12,8), %rcx
movq %rcx, (%rsp)
movq %r14, %rdi
leaq 0xc3b6(%rip), %rsi      # 0x3ab36
xorl %edx, %edx
movl %eax, %ecx
movq %r13, %r8
movl $0x115, %r9d            # imm = 0x115
xorl %eax, %eax
callq 0xb470
movq 0xc358(%rbx,%r12,8), %rsi
movsd 0xc4e8(%rbx,%r12,8), %xmm0
movq %r14, %rdi
callq 0xb6a0
testl %eax, %eax
jne 0x2e59b
cmpl $0x0, 0x1b6b4(%rbx)
jle 0x2e7f8
callq 0xaf80
movq 0xc358(%rbx,%r12,8), %rcx
movq %rcx, 0x10(%rsp)
movq %rcx, 0x8(%rsp)
movl %r12d, (%rsp)
movq %r14, %rdi
leaq 0xc378(%rip), %rsi      # 0x3ab5c
xorl %edx, %edx
movl %eax, %ecx
movq %r13, %r8
movl $0x11b, %r9d            # imm = 0x11B
xorl %eax, %eax
callq 0xb470
movq 0xc358(%rbx,%r12,8), %rdi
callq 0xacf0
incq %r12
movslq 0xc350(%rbx), %rax
cmpq %rax, %r12
jl 0x2e730
movl $0x0, 0xc350(%rbx)
cmpl $0x0, 0x1694(%rbx)
je 0x2e876
leaq 0x130(%rbx), %r12
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0xa460
movl %eax, %r15d
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0xb600
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0xb5c0
movq %r14, %rdi
movq %rbx, %rsi
callq 0xad40
cmpl $0x3, %r15d
jae 0x2e59e
jmp 0x2e879
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %r15d
xorl %eax, %eax
movb %al, 0x1698(%rbx)
movb %al, 0x4f8(%rbx)
movl %eax, 0x1694(%rbx)
movl %eax, 0xef90(%rbx)
movl %eax, 0xef50(%rbx)
movq $0x0, 0xef70(%rbx)
movl %eax, 0xfb28(%rbx)
callq 0xa090
jmp 0x2e59e
nop