// File: /workspace/github_cpp_makefile_star2_O2/sundale[P]gcode/rs274ngc/rs274ngc_pre.cc
// Function: Interp::restore_parameters(char const*)
int Interp::restore_parameters(const char *filename)   //!< name of parameter file to read  
{
  FILE *infile;
  char line[256];
  int variable;
  double value;
  int required;                 // number of next required parameter
  int index;                    // index into _required_parameters
  double *pars;                 // short name for _setup.parameters
  int k;

  // it's OK if the parameter file doesn't exist yet
  // it'll be created in due course with some default values
  if(access(filename, F_OK) == -1)
      return INTERP_OK;
  // open original for reading
  infile = fopen(filename, "r");
  sprintf(line,"Unable to open parameter file: '%s'", filename);
  CHKS((infile == NULL), line);

  pars = _setup.parameters;
  k = 0;
  index = 0;
  required = _required_parameters[index++];
  while (feof(infile) == 0) {
    if (fgets(line, 256, infile) == NULL) {
      break;
    }
    // try for a variable-value match in the file
    if (sscanf(line, "%d %lf", &variable, &value) == 2) {
      CHKS(((variable <= 0)
           || (variable >= RS274NGC_MAX_PARAMETERS)),
          NCE_PARAMETER_NUMBER_OUT_OF_RANGE);
      for (; k < RS274NGC_MAX_PARAMETERS; k++) {
        if (k > variable)
          ERS(NCE_PARAMETER_FILE_OUT_OF_ORDER);
        else if (k == variable) {
          pars[k] = value;
          if (k == required)
            required = _required_parameters[index++];
          k++;
          break;
        } else                  // if (k < variable)
        {
          if (k == required)
            required = _required_parameters[index++];
          pars[k] = 0;
        }
      }
    }
  }
  fclose(infile);
  for (; k < RS274NGC_MAX_PARAMETERS; k++) {
    pars[k] = 0;
  }
  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rsi, %r14
xorl %ebx, %ebx
movq %rsi, %rdi
xorl %esi, %esi
callq 0xc3f0
cmpl $-0x1, %eax
je 0x2d4a5
leaq 0x80ba(%rip), %rsi      # 0x3541f
movq %r14, %rdi
callq 0xbdd0
movq %rax, %rbx
leaq 0x9b8c(%rip), %rsi      # 0x36f03
leaq -0x140(%rbp), %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0xb190
testq %rbx, %rbx
je 0x2d460
leaq -0x140(%rbp), %r14
leaq -0x38(%rbp), %r13
movq 0xfbbd(%rip), %r15      # 0x3cf60
xorl %r12d, %r12d
movq %rbx, %rdi
callq 0xc1b0
testl %eax, %eax
jne 0x2d43a
movq %r14, %rdi
movl $0x100, %esi            # imm = 0x100
movq %rbx, %rdx
callq 0xc230
testq %rax, %rax
je 0x2d43a
movq %r14, %rdi
leaq 0x9b52(%rip), %rsi      # 0x36f27
leaq -0x2c(%rbp), %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0xbb10
cmpl $0x2, %eax
jne 0x2d3a6
movl -0x2c(%rbp), %eax
leal -0x1526(%rax), %ecx
cmpl $0xffffeadb, %ecx       # imm = 0xFFFFEADB
jb 0x2d4ca
movslq %r12d, %r12
cmpq $0x1525, %r12           # imm = 0x1525
jg 0x2d3a6
cmpq %rax, %r12
jg 0x2d4b9
je 0x2d422
andq $0x0, 0x17c0(%r15,%r12,8)
incq %r12
jmp 0x2d400
movsd -0x38(%rbp), %xmm0
movsd %xmm0, 0x17c0(%r15,%rax,8)
leal 0x1(%rax), %r12d
jmp 0x2d3a6
movslq %r12d, %r14
movq %rbx, %rdi
callq 0xbb40
cmpq $0x1525, %r14           # imm = 0x1525
jg 0x2d45c
andq $0x0, 0x17c0(%r15,%r14,8)
incq %r14
jmp 0x2d445
xorl %ebx, %ebx
jmp 0x2d4a5
leaq -0x140(%rbp), %rsi
xorl %eax, %eax
callq 0xb8e0
movl $0xc6d0, %edi           # imm = 0xC6D0
addq 0xfae6(%rip), %rdi      # 0x3cf60
leaq 0x9cff(%rip), %rsi      # 0x37180
pushq $0x50
popq %rdx
callq 0xb940
movq 0xfad0(%rip), %rax      # 0x3cf60
andw $0x0, 0xc71f(%rax)
movl $0x1, 0xd670(%rax)
pushq $0x5
popq %rbx
movl %ebx, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9a6e(%rip), %rdi      # 0x36f2e
callq 0xb220
movq %rax, %rsi
jmp 0x2d467
leaq 0x84aa(%rip), %rdi      # 0x3597b
jmp 0x2d4c0
nop