// File: /workspace/github_cpp_makefile_star2_O3/sundale[P]gcode/rs274ngc/interp_read.cc
// Function: Interp::read_parameter_setting(char*, int*, block_struct*, double*)
int Interp::read_parameter_setting(
    char *line,   //!< string: line of RS274/NGC code being processed
    int *counter, //!< pointer to a counter for position on the line 
    block_pointer block,  //!< pointer to a block being filled from the line 
    double *parameters)   //!< array of system parameters
{
  static char name[] = "read_parameter_setting";
  int index;
  double value;
  char *param;
  char *dup;

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

  // named parameters look like '<letter...>' or '<_letter.....>'
  if((line[*counter] == '<') || isalpha(line[*(counter)]))
  {
      CHP(read_named_parameter_setting(line, counter, &param, parameters));

      CHKS((line[*counter] != '='),
          NCE_EQUAL_SIGN_MISSING_IN_PARAMETER_SETTING);
      *counter = (*counter + 1);
      CHP(read_real_value(line, counter, &value, parameters));

      logDebug("setting up named param[%d]:|%s| value:%lf",
               _setup.named_parameter_occurrence, param, value);

      dup = strdup(param);
      if(dup == 0)
      {
          ERS(NCE_OUT_OF_MEMORY);
      }
      logDebug("%s strdup[0x%x]:|%s|", name, dup, dup);
      _setup.named_parameters[_setup.named_parameter_occurrence] = dup;

      _setup.named_parameter_values[_setup.named_parameter_occurrence] = value;
      _setup.named_parameter_occurrence++;
      logDebug("done setting up named param[%d]:|%s| value:%lf",
               _setup.named_parameter_occurrence, param, value);
  }
  else
  {
      CHP(read_integer_value(line, counter, &index, parameters));
      CHKS(((index < 1) || (index >= RS274NGC_MAX_PARAMETERS)),
          NCE_PARAMETER_NUMBER_OUT_OF_RANGE);
      CHKS((isreadonly(index)), NCE_PARAMETER_NUMBER_READONLY);
      CHKS((line[*counter] != '='),
          NCE_EQUAL_SIGN_MISSING_IN_PARAMETER_SETTING);
      *counter = (*counter + 1);
      CHP(read_real_value(line, counter, &value, parameters));
      _setup.parameter_numbers[_setup.parameter_occurrence] = index;
      _setup.parameter_values[_setup.parameter_occurrence] = value;
      _setup.parameter_occurrence++;
  }
  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movslq (%rdx), %rax
cmpb $0x23, (%rsi,%rax)
jne 0x29a37
movq %r8, %r15
movq %rdx, %r12
movq %rsi, %r13
leaq 0x1(%rax), %rcx
movl %ecx, (%rdx)
movsbl 0x1(%rsi,%rax), %edi
cmpl $0x3c, %edi
je 0x299b5
callq 0xb140
testl %eax, %eax
je 0x29b26
leaq -0x38(%rbp), %rcx
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0xb240
testl %eax, %eax
je 0x29a9a
movl %eax, %r14d
movq 0x17587(%rip), %rbx     # 0x40f60
movslq 0xd670(%rbx), %rax
cmpq $0x30, %rax
jg 0x29a88
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
leaq (%rbx,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0xefac(%rip), %rsi      # 0x389b0
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 0x29a88
leaq 0xd811(%rip), %rdi      # 0x3724f
callq 0xa1f0
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
movq 0x17509(%rip), %rbx     # 0x40f60
leaq 0xc6d0(%rbx), %rdi
leaq 0xef4b(%rip), %rsi      # 0x389b0
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
movl $0x5, %r14d
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq (%r12), %rax
cmpb $0x3d, (%r13,%rax)
jne 0x29d3b
incl %eax
movl %eax, (%r12)
leaq -0x30(%rbp), %rcx
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %r8
callq 0xaf10
testl %eax, %eax
jne 0x299cf
movq 0x1748c(%rip), %r13     # 0x40f60
cmpl $0x0, 0x1b6b4(%r13)
jle 0x29ba7
callq 0xaf80
movl 0xc350(%r13), %r10d
movq -0x38(%rbp), %r15
movsd -0x30(%rbp), %xmm0
leaq 0xfec3(%rip), %rsi      # 0x399c1
leaq 0xf9a9(%rip), %r8       # 0x394ae
movq %rbx, %rdi
xorl %edx, %edx
movl %eax, %ecx
movl $0x8a3, %r9d            # imm = 0x8A3
movb $0x1, %al
pushq %r15
pushq %r10
callq 0xb470
addq $0x10, %rsp
jmp 0x29bab
leaq -0x38(%rbp), %rcx
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %r8
callq 0xab30
testl %eax, %eax
jne 0x299cf
movl -0x38(%rbp), %edi
movl $0xffffeada, %eax       # imm = 0xFFFFEADA
leal (%rdi,%rax), %ecx
cmpl %eax, %ecx
ja 0x29b5e
leaq 0xfe22(%rip), %rdi      # 0x3997b
jmp 0x29a3e
movq 0x1740b(%rip), %rax     # 0x40f70
movslq (%rax), %rax
testq %rax, %rax
jle 0x29cd0
movq 0x17430(%rip), %rcx     # 0x40fa8
cmpl %edi, (%rcx)
je 0x29b9b
movl $0x1, %esi
movq %rsi, %rdx
cmpq %rsi, %rax
je 0x29b92
leaq 0x1(%rdx), %rsi
cmpl %edi, (%rcx,%rdx,4)
jne 0x29b81
cmpq %rax, %rdx
jae 0x29cd0
leaq 0xfe9e(%rip), %rdi      # 0x39a40
jmp 0x29a3e
movq -0x38(%rbp), %r15
movq %r15, %rdi
callq 0xb4e0
testq %rax, %rax
je 0x29c85
movq %rax, %r12
cmpl $0x0, 0x1b6b4(%r13)
jle 0x29d47
callq 0xaf80
subq $0x8, %rsp
leaq 0x17fe3(%rip), %r10     # 0x41bc0
leaq 0xfd0b(%rip), %rsi      # 0x398ef
leaq 0xf8c3(%rip), %r8       # 0x394ae
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %edx, %edx
movl %eax, %ecx
movl $0x8aa, %r9d            # imm = 0x8AA
xorl %eax, %eax
pushq %r12
pushq %r12
pushq %r10
callq 0xb470
addq $0x20, %rsp
movslq 0xc350(%r13), %rax
leal 0x1(%rax), %ecx
cmpl $0x0, 0x1b6b4(%r13)
movq %r12, 0xc358(%r13,%rax,8)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, 0xc4e8(%r13,%rax,8)
movl %ecx, 0xc350(%r13)
jle 0x29a88
callq 0xaf80
movl 0xc350(%r13), %r10d
movsd -0x30(%rbp), %xmm0
leaq 0xfda4(%rip), %rsi      # 0x399fe
leaq 0xf84d(%rip), %r8       # 0x394ae
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %edx, %edx
movl %eax, %ecx
movl $0x8b0, %r9d            # imm = 0x8B0
movb $0x1, %al
pushq %r15
pushq %r10
callq 0xb470
addq $0x10, %rsp
jmp 0x29a88
leaq 0xfc55(%rip), %rdi      # 0x398e1
callq 0xa1f0
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
leaq 0xc6d0(%r13), %rdi
leaq 0xed04(%rip), %rsi      # 0x389b0
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%r13)
movl $0x1, 0xd670(%r13)
jmp 0x29a82
movslq (%r12), %rax
cmpb $0x3d, (%r13,%rax)
jne 0x29d3b
movq %rdi, -0x40(%rbp)
incl %eax
movl %eax, (%r12)
leaq -0x30(%rbp), %rcx
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %r8
callq 0xaf10
testl %eax, %eax
jne 0x299cf
movq 0x17256(%rip), %rax     # 0x40f60
movslq 0xc0f0(%rax), %rcx
movq -0x40(%rbp), %rdx
movl %edx, 0xc0f4(%rax,%rcx,4)
movsd -0x30(%rbp), %xmm0
movslq 0xc0f0(%rax), %rcx
movsd %xmm0, 0xc1c0(%rax,%rcx,8)
incl %ecx
movl %ecx, 0xc0f0(%rax)
jmp 0x29d6e
leaq 0xfc57(%rip), %rdi      # 0x39999
jmp 0x29a3e
movslq 0xc350(%r13), %rax
movq %r12, 0xc358(%r13,%rax,8)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, 0xc4e8(%r13,%rax,8)
incl %eax
movl %eax, 0xc350(%r13)
xorl %r14d, %r14d
jmp 0x29a88