// File: /workspace/github_cpp_makefile_star2_O1/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 0x2cc57
movq %rcx, %r14
leaq -0x140(%rbp), %rcx
movq %rbx, %rdi
callq 0xa9a0
testl %eax, %eax
je 0x2ccb1
movl %eax, %r12d
movq 0x1736a(%rip), %rbx     # 0x43f60
movslq 0xd670(%rbx), %rax
cmpq $0x30, %rax
jg 0x2cde3
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
leaq (%rbx,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0xeced(%rip), %rsi      # 0x3b90e
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 0x2cde3
leaq 0xd5f9(%rip), %rdi      # 0x3a257
callq 0xa1f0
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
movq 0x172e9(%rip), %rbx     # 0x43f60
movl $0x0, 0xd670(%rbx)
leaq 0xc6d0(%rbx), %rdi
leaq 0xec7f(%rip), %rsi      # 0x3b90e
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
jmp 0x2cddd
movq %r14, -0x30(%rbp)
xorl %eax, %eax
cmpb $0x5f, -0x140(%rbp)
movq 0x1729b(%rip), %rcx     # 0x43f60
je 0x2cccd
movl 0xef90(%rcx), %eax
movq %rax, -0x40(%rbp)
cltq
imulq $0x128, %rax, %rax      # imm = 0x128
movslq 0xf0ac(%rcx,%rax), %r14
testq %r14, %r14
jle 0x2cd25
movq 0x17272(%rip), %rcx     # 0x43f60
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 0x2cdf8
incq %r13
cmpq %r13, %r14
jne 0x2cd09
movq -0x30(%rbp), %rax
movq $0x0, (%rax)
movq 0x17229(%rip), %r14     # 0x43f60
cmpl $0x0, 0x1b6b4(%r14)
jle 0x2cd85
callq 0xaf80
subq $0x8, %rsp
leaq 0x17e4f(%rip), %r10     # 0x44ba0
leaq 0xfbca(%rip), %rsi      # 0x3c922
leaq 0xf757(%rip), %r8       # 0x3c4b6
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 0xfbd8(%rip), %rdi      # 0x3c964
callq 0xa1f0
leaq -0x140(%rbp), %rdx
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
movl $0x0, 0xd670(%r14)
leaq 0xc6d0(%r14), %rdi
leaq 0xeb50(%rip), %rsi      # 0x3b90e
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 0x2cde3
nop