// File: /workspace/github_cpp_makefile_star2_O1/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 0xb290
cmpl $-0x1, %eax
je 0x33f5d
leaq 0x86c2(%rip), %rsi      # 0x3c427
movq %r14, %rdi
callq 0xace0
movq %rax, %rbx
leaq 0xa1dc(%rip), %rsi      # 0x3df53
xorl %r12d, %r12d
leaq -0x140(%rbp), %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0xa170
testq %rbx, %rbx
je 0x33dea
movq %rbx, %rdi
callq 0xb070
testl %eax, %eax
je 0x33e39
movq %rbx, %rdi
callq 0xaa80
xorl %ebx, %ebx
cmpl $0x1525, %r12d          # imm = 0x1525
jg 0x33f5d
movslq %r12d, %rax
movq 0x1019f(%rip), %rcx     # 0x43f60
leaq (%rcx,%rax,8), %rdi
addq $0x17c0, %rdi           # imm = 0x17C0
movl $0x1525, %eax           # imm = 0x1525
subl %r12d, %eax
leaq 0x8(,%rax,8), %rdx
xorl %ebx, %ebx
xorl %esi, %esi
callq 0xa570
jmp 0x33f5d
leaq -0x140(%rbp), %rsi
xorl %eax, %eax
callq 0xa850
movq 0x10161(%rip), %rbx     # 0x43f60
movl $0x0, 0xd670(%rbx)
leaq 0xc6d0(%rbx), %rdi
leaq 0xa3b9(%rip), %rsi      # 0x3e1d0
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
jmp 0x33f58
leaq -0x140(%rbp), %r14
movq 0x10119(%rip), %r15     # 0x43f60
movabsq $0x100000000, %r13      # imm = 0x100000000
xorl %r12d, %r12d
movq %r14, %rdi
movl $0x100, %esi            # imm = 0x100
movq %rbx, %rdx
callq 0xb0f0
testq %rax, %rax
je 0x33da0
movq %r14, %rdi
leaq 0xa100(%rip), %rsi      # 0x3df77
leaq -0x2c(%rbp), %rdx
leaq -0x38(%rbp), %rcx
xorl %eax, %eax
callq 0xaa50
cmpl $0x2, %eax
jne 0x33ef5
movl -0x2c(%rbp), %eax
leal -0x1526(%rax), %ecx
cmpl $0xffffeadb, %ecx       # imm = 0xFFFFEADB
jb 0x33f71
cmpl $0x1525, %r12d          # imm = 0x1525
jg 0x33ef5
movslq %r12d, %rdx
movq %rdx, %rcx
shlq $0x20, %rcx
incl %r12d
cmpq %rax, %rdx
jg 0x33f0a
je 0x33ee2
movq $0x0, 0x17c0(%r15,%rdx,8)
incq %rdx
addq %r13, %rcx
incl %r12d
cmpl $0x1526, %edx           # imm = 0x1526
jne 0x33eb6
movl $0x1526, %r12d          # imm = 0x1526
jmp 0x33ef5
movsd -0x38(%rbp), %xmm0
sarq $0x1d, %rcx
movsd %xmm0, 0x17c0(%r15,%rcx)
movq %rbx, %rdi
callq 0xb070
testl %eax, %eax
je 0x33e54
jmp 0x33da0
leaq 0xa06d(%rip), %rdi      # 0x3df7e
callq 0xa1f0
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
movl $0x0, 0xd670(%r15)
leaq 0xc6d0(%r15), %rdi
leaq 0xa297(%rip), %rsi      # 0x3e1d0
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%r15)
movl $0x1, 0xd670(%r15)
movl $0x5, %ebx
movl %ebx, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8a0e(%rip), %rdi      # 0x3c986
jmp 0x33f11