// File: /workspace/github_cpp_makefile_star2_O3/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 0x30555
leaq 0x909a(%rip), %rsi      # 0x3941f
movq %r14, %rdi
callq 0xace0
movq %rax, %rbx
leaq 0xab6c(%rip), %rsi      # 0x3af03
leaq -0x140(%rbp), %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0xa170
testq %rbx, %rbx
je 0x303fa
movq %rbx, %rdi
callq 0xb070
testl %eax, %eax
je 0x3043f
movq %rbx, %rdi
callq 0xaa80
xorl %r12d, %r12d
movslq %r12d, %rax
movq 0x10b8e(%rip), %rcx     # 0x40f60
leaq (%rcx,%rax,8), %rdi
addq $0x17c0, %rdi           # imm = 0x17C0
movl $0x1525, %ecx           # imm = 0x1525
subl %eax, %ecx
leaq 0x8(,%rcx,8), %rdx
xorl %ebx, %ebx
xorl %esi, %esi
callq 0xa570
jmp 0x30555
leaq -0x140(%rbp), %rsi
xorl %eax, %eax
callq 0xa850
movq 0x10b51(%rip), %rbx     # 0x40f60
leaq 0xc6d0(%rbx), %rdi
leaq 0xad63(%rip), %rsi      # 0x3b180
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
jmp 0x30550
leaq -0x140(%rbp), %r14
leaq -0x38(%rbp), %r13
movq 0x10b0f(%rip), %r15     # 0x40f60
xorl %r12d, %r12d
movq %r14, %rdi
movl $0x100, %esi            # imm = 0x100
movq %rbx, %rdx
callq 0xb0f0
testq %rax, %rax
je 0x304f4
movq %r14, %rdi
leaq 0xaab0(%rip), %rsi      # 0x3af27
leaq -0x2c(%rbp), %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0xaa50
cmpl $0x2, %eax
jne 0x304e4
movl -0x2c(%rbp), %eax
leal -0x1526(%rax), %ecx
cmpl $0xffffeadb, %ecx       # imm = 0xFFFFEADB
jb 0x30569
cmpl $0x1525, %r12d          # imm = 0x1525
jg 0x304e4
movslq %r12d, %rcx
cmpq %rax, %rcx
jg 0x3050d
je 0x304d1
movq $0x0, 0x17c0(%r15,%rcx,8)
incq %rcx
cmpl $0x1526, %ecx           # imm = 0x1526
jne 0x304ab
movl $0x1526, %r12d          # imm = 0x1526
jmp 0x304e4
movsd -0x38(%rbp), %xmm0
movsd %xmm0, 0x17c0(%r15,%rax,8)
leal 0x1(%rax), %r12d
movq %rbx, %rdi
callq 0xb070
testl %eax, %eax
je 0x30454
movq %rbx, %rdi
callq 0xaa80
xorl %ebx, %ebx
cmpl $0x1525, %r12d          # imm = 0x1525
jle 0x303c8
jmp 0x30555
leaq 0xaa1a(%rip), %rdi      # 0x3af2e
callq 0xa1f0
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
leaq 0xc6d0(%r15), %rdi
leaq 0xac4f(%rip), %rsi      # 0x3b180
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 0x940b(%rip), %rdi      # 0x3997b
jmp 0x30514