// File: /workspace/github_cpp_makefile_star2_O2/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 0x26c32
movq %rcx, %r14
leaq -0x140(%rbp), %rcx
movq %rbx, %rdi
callq 0xba50
testl %eax, %eax
je 0x26c93
movl %eax, %r15d
movq 0x16382(%rip), %rbx     # 0x3cf60
movslq 0xd670(%rbx), %rax
cmpq $0x30, %rax
jg 0x26c7e
imulq $0x50, %rax, %rax
leaq (%rbx,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0xdd09(%rip), %rsi      # 0x3490e
pushq $0x50
popq %rdx
callq 0xb940
movslq 0xd670(%rbx), %rax
imulq $0x50, %rax, %rcx
xorl %edx, %edx
movb %dl, 0xc71f(%rbx,%rcx)
incl %eax
movl %eax, 0xd670(%rbx)
movb %dl, 0xc720(%rbx,%rcx)
jmp 0x26c7e
leaq 0xc616(%rip), %rdi      # 0x3324f
callq 0xb220
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xb8e0
movq 0x1630e(%rip), %rbx     # 0x3cf60
leaq 0xc6d0(%rbx), %rdi
leaq 0xdcae(%rip), %rsi      # 0x3490e
pushq $0x50
popq %rdx
callq 0xb940
andw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
pushq $0x5
popq %r15
movl %r15d, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, -0x30(%rbp)
xorl %r12d, %r12d
cmpb $0x5f, -0x140(%rbp)
movq 0x162b8(%rip), %rcx     # 0x3cf60
movl $0x0, %eax
je 0x26cb5
movl 0xef90(%rcx), %eax
movq %rax, -0x38(%rbp)
cltq
imulq $0x128, %rax, %rax      # imm = 0x128
leaq (%rcx,%rax), %r13
addq $0xf0a8, %r13           # imm = 0xF0A8
movl 0x4(%r13), %r14d
testl %r14d, %r14d
cmovlel %r12d, %r14d
leaq -0x140(%rbp), %r15
cmpq %r12, %r14
je 0x26d16
movq 0x8(%r13), %rax
movq (%rax,%r12,8), %rdi
movq %r15, %rsi
callq 0xbfd0
incq %r12
testl %eax, %eax
jne 0x26cdf
movq 0x10(%r13), %rax
movsd -0x8(%rax,%r12,8), %xmm0
movq -0x30(%rbp), %rax
movsd %xmm0, (%rax)
xorl %r15d, %r15d
jmp 0x26c7e
movq -0x30(%rbp), %rax
andq $0x0, (%rax)
movq 0x1623b(%rip), %r14     # 0x3cf60
cmpl $0x0, 0x1b6b4(%r14)
jle 0x26d6c
callq 0xc0b0
subq $0x8, %rsp
leaq 0x16f21(%rip), %r10     # 0x3dc60
leaq 0xebd1(%rip), %rsi      # 0x35917
leaq 0xe761(%rip), %r8       # 0x354ae
movq %rbx, %rdi
xorl %edx, %edx
movl %eax, %ecx
movl $0x7e3, %r9d            # imm = 0x7E3
xorl %eax, %eax
pushq %r15
pushq -0x38(%rbp)
pushq %r10
callq 0xc5e0
addq $0x20, %rsp
leaq 0xebe6(%rip), %rdi      # 0x35959
callq 0xb220
leaq -0x140(%rbp), %rdx
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xb8e0
leaq 0xc6d0(%r14), %rdi
leaq 0xdb74(%rip), %rsi      # 0x3490e
pushq $0x50
popq %rdx
callq 0xb940
andw $0x0, 0xc71f(%r14)
movl $0x1, 0xd670(%r14)
jmp 0x26c7a
nop