// File: /workspace/github_cpp_makefile_star2_O3/sundale[P]gcode/rs274ngc/interp_read.cc
// Function: Interp::read_named_parameter(char*, int*, double*, double*)
int Interp::read_named_parameter(
    char *line,   //!< string: line of RS274/NGC code being processed
    int *counter, //!< pointer to a counter for position on the line 
    double *double_ptr,   //!< pointer to double to be read
    double *parameters)   //!< array of system parameters
{
  static char name[] = "read_named_parameter";

  char paramNameBuf[LINELEN+1];
  int level;
  int i;

  struct named_parameters_struct *nameList;
  
  CHKS((line[*counter] != '<'),
      NCE_BUG_FUNCTION_SHOULD_NOT_HAVE_BEEN_CALLED);

  CHP(read_name(line, counter, paramNameBuf));

  // now look it up
  if(paramNameBuf[0] != '_') // local scope
  {
      level = _setup.call_level;
  }
  else
  {
      // call level zero is global scope
      level = 0;
  }

  nameList = &_setup.sub_context[level].named_parameters;

  for(i=0; i<nameList->named_parameter_used_size; i++)
  {
      if(0 == strcmp(nameList->named_parameters[i], paramNameBuf))
      {
          *double_ptr = nameList->named_param_values[i];
          return INTERP_OK;
      }
  }

  *double_ptr = 0.0;
  
  logDebug("%s: level[%d] param:|%s| returning not defined", name, level,
           paramNameBuf);
  ERS(_("Named parameter #<%s> not defined"), paramNameBuf);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %rbx
movslq (%rdx), %rax
cmpb $0x3c, (%rsi,%rax)
jne 0x29637
movq %rcx, %r14
leaq -0x140(%rbp), %rcx
movq %rbx, %rdi
callq 0xa9a0
testl %eax, %eax
je 0x29687
movl %eax, %r12d
movq 0x1798a(%rip), %rbx     # 0x40f60
movslq 0xd670(%rbx), %rax
cmpq $0x30, %rax
jg 0x297ae
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
leaq (%rbx,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0xf30d(%rip), %rsi      # 0x3890e
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 0x297ae
leaq 0xdc11(%rip), %rdi      # 0x3724f
callq 0xa1f0
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
movq 0x17909(%rip), %rbx     # 0x40f60
leaq 0xc6d0(%rbx), %rdi
leaq 0xf2a9(%rip), %rsi      # 0x3890e
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
jmp 0x297a8
movq %r14, -0x30(%rbp)
xorl %eax, %eax
cmpb $0x5f, -0x140(%rbp)
movq 0x178c5(%rip), %rcx     # 0x40f60
je 0x296a3
movl 0xef90(%rcx), %eax
movq %rax, -0x40(%rbp)
cltq
imulq $0x128, %rax, %rax      # imm = 0x128
movslq 0xf0ac(%rcx,%rax), %r14
testq %r14, %r14
jle 0x296fb
movq 0x1789c(%rip), %rcx     # 0x40f60
addq %rcx, %rax
addq $0xf0a8, %rax           # imm = 0xF0A8
movq %rax, -0x38(%rbp)
movq 0x8(%rax), %r15
xorl %r13d, %r13d
leaq -0x140(%rbp), %r12
movq (%r15,%r13,8), %rdi
movq %r12, %rsi
callq 0xaeb0
testl %eax, %eax
je 0x297c3
incq %r13
cmpq %r13, %r14
jne 0x296df
movq -0x30(%rbp), %rax
movq $0x0, (%rax)
movq 0x17853(%rip), %r14     # 0x40f60
cmpl $0x0, 0x1b6b4(%r14)
jle 0x2975b
callq 0xaf80
subq $0x8, %rsp
leaq 0x18479(%rip), %r10     # 0x41ba0
leaq 0x101e9(%rip), %rsi     # 0x39917
leaq 0xfd79(%rip), %r8       # 0x394ae
movq %rbx, %rdi
xorl %edx, %edx
movl %eax, %ecx
movl $0x7e3, %r9d            # imm = 0x7E3
xorl %eax, %eax
leaq -0x140(%rbp), %r11
pushq %r11
pushq -0x40(%rbp)
pushq %r10
callq 0xb470
addq $0x20, %rsp
leaq 0x101f7(%rip), %rdi     # 0x39959
callq 0xa1f0
leaq -0x140(%rbp), %rdx
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
leaq 0xc6d0(%r14), %rdi
leaq 0xf185(%rip), %rsi      # 0x3890e
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%r14)
movl $0x1, 0xd670(%r14)
movl $0x5, %r12d
movl %r12d, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movsd (%rax,%r13,8), %xmm0
movq -0x30(%rbp), %rax
movsd %xmm0, (%rax)
xorl %r12d, %r12d
jmp 0x297ae