// File: sundale[P]gcode/rs274ngc/interp_read.cc
// Function: Interp::read_parameter(char*, int*, double*, double*)
int Interp::read_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                    
{
  int index;

  CHKS((line[*counter] != '#'), NCE_BUG_FUNCTION_SHOULD_NOT_HAVE_BEEN_CALLED);

  *counter = (*counter + 1);

  // named parameters look like '<letter...>' or '<_.....>'
  if(line[*counter] == '<')
  {
      //_setup.stack_index = 0; -- reminder of variable we need
      // find the matching string (if any) -- or create it
      // then get the value and store it
      CHP(read_named_parameter(line, counter, double_ptr, parameters));
  }
  else
  {
      CHP(read_integer_value(line, counter, &index, parameters));
      CHKS(((index < 1) || (index >= RS274NGC_MAX_PARAMETERS)),
          NCE_PARAMETER_NUMBER_OUT_OF_RANGE);
      *double_ptr = parameters[index];
  }
  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
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, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x23, %eax
je 0x65ef1
jmp 0x65e1e
leaq 0x165c0(%rip), %rdi     # 0x7c3e5
callq 0x10380
movq -0x48(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x21121(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x21110(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x21102(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x18524(%rip), %rsi     # 0x7e397
movl $0x50, %edx
callq 0x10840
movq 0x210dc(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x210ce(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x210b6(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x210a6(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x21099(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x2108b(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x661f2
jmp 0x65ef3
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3c, %eax
jne 0x66006
jmp 0x65f1c
movq -0x48(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x11690
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
je 0x65fff
jmp 0x65f44
movq 0x21015(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x65ff4
movq 0x21001(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x20ff3(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x18415(%rip), %rsi     # 0x7e397
movl $0x50, %edx
callq 0x10840
movq 0x20fcd(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x20fbf(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x20fa7(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x20f97(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x20f8a(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x20f7c(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x38(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x661f2
jmp 0x66001
jmp 0x661eb
jmp 0x66008
movq -0x48(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %r8
leaq -0x34(%rbp), %rcx
callq 0x11250
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x660eb
jmp 0x66030
movq 0x20f29(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x660e0
movq 0x20f15(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x20f07(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x18329(%rip), %rsi     # 0x7e397
movl $0x50, %edx
callq 0x10840
movq 0x20ee1(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x20ed3(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x20ebb(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x20eab(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x20e9e(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x20e90(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x661f2
jmp 0x660ed
jmp 0x660ef
cmpl $0x1, -0x34(%rbp)
jl 0x66102
cmpl $0x1526, -0x34(%rbp)    # imm = 0x1526
jl 0x661d4
jmp 0x66104
leaq 0x182ca(%rip), %rdi     # 0x7e3d5
callq 0x10380
movq -0x48(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x20e3b(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x20e2a(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x20e1c(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x1823e(%rip), %rsi     # 0x7e397
movl $0x50, %edx
callq 0x10840
movq 0x20df6(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x20de8(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x20dd0(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x20dc0(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x20db3(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x20da5(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x661f2
jmp 0x661d6
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)