// File: 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
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3c, %eax
je 0x65aba
jmp 0x659e4
leaq 0x169fa(%rip), %rdi     # 0x7c3e5
callq 0x10380
movq -0x150(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x21558(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x21547(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x21539(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x188b3(%rip), %rsi     # 0x7e2ef
movl $0x50, %edx
callq 0x10840
movq 0x21513(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x21505(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x214ed(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x214dd(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x214d0(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x214c2(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x65dce
jmp 0x65abc
jmp 0x65abe
movq -0x150(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq -0x130(%rbp), %rcx
callq 0x11040
movl %eax, -0x144(%rbp)
cmpl $0x0, -0x144(%rbp)
je 0x65bac
jmp 0x65aee
movq 0x2146b(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x65b9e
movq 0x21457(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x21449(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x187c3(%rip), %rsi     # 0x7e2ef
movl $0x50, %edx
callq 0x10840
movq 0x21423(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x21415(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x213fd(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x213ed(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x213e0(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x213d2(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x144(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x65dce
jmp 0x65bae
movsbl -0x130(%rbp), %eax
cmpl $0x5f, %eax
je 0x65bcf
movq 0x2139f(%rip), %rax     # 0x86f60
movl 0xef90(%rax), %eax
movl %eax, -0x134(%rbp)
jmp 0x65bd9
movl $0x0, -0x134(%rbp)
movslq -0x134(%rbp), %rcx
movq 0x21379(%rip), %rax     # 0x86f60
addq $0xef98, %rax           # imm = 0xEF98
imulq $0x128, %rcx, %rcx      # imm = 0x128
addq %rcx, %rax
addq $0x110, %rax            # imm = 0x110
movq %rax, -0x140(%rbp)
movl $0x0, -0x138(%rbp)
movl -0x138(%rbp), %eax
movq -0x140(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x65c88
movq -0x140(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x138(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq -0x130(%rbp), %rsi
callq 0x11820
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x65c75
movq -0x140(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x138(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x65dce
jmp 0x65c77
movl -0x138(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x138(%rbp)
jmp 0x65c0e
movq -0x28(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
xorl %eax, %eax
movq 0x212c4(%rip), %rcx     # 0x86f60
cmpl 0x1b6b4(%rcx), %eax
jge 0x65cf2
callq 0x11950
movq -0x150(%rbp), %rdi
movl %eax, %ecx
movl -0x134(%rbp), %r10d
leaq -0x130(%rbp), %rax
leaq 0x1866c(%rip), %rsi     # 0x7e333
xorl %edx, %edx
leaq 0x180f9(%rip), %r8      # 0x7ddc9
movl $0x7e3, %r9d            # imm = 0x7E3
leaq 0x22543(%rip), %r11     # 0x88220
movq %r11, (%rsp)
movl %r10d, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movb $0x0, %al
callq 0x12050
jmp 0x65cf4
jmp 0x65cf6
leaq 0x18678(%rip), %rdi     # 0x7e375
callq 0x10380
movq -0x150(%rbp), %rdi
movq %rax, %rsi
leaq -0x130(%rbp), %rdx
movb $0x0, %al
callq 0x10df0
movq 0x2123f(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x2122e(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x21220(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x1859a(%rip), %rsi     # 0x7e2ef
movl $0x50, %edx
callq 0x10840
movq 0x211fa(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x211ec(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x211d4(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x211c4(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x211b7(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x211a9(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
nopw (%rax,%rax)