// File: /workspace/github_cpp_makefile_star2_O2/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 0x26ff7
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 0x26f7f
callq 0xc290
testl %eax, %eax
je 0x270dc
leaq -0x38(%rbp), %rcx
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0xc3a0
testl %eax, %eax
je 0x27055
movl %eax, %r14d
movq 0x15fbd(%rip), %rbx     # 0x3cf60
movslq 0xd670(%rbx), %rax
cmpq $0x30, %rax
jg 0x27043
imulq $0x50, %rax, %rax
leaq (%rbx,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0xd9e6(%rip), %rsi      # 0x349b0
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 0x27043
leaq 0xc251(%rip), %rdi      # 0x3324f
callq 0xb220
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xb8e0
movq 0x15f49(%rip), %rbx     # 0x3cf60
leaq 0xc6d0(%rbx), %rdi
leaq 0xd98b(%rip), %rsi      # 0x349b0
pushq $0x50
popq %rdx
callq 0xb940
andw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
pushq $0x5
popq %r14
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 0x272c1
incl %eax
movl %eax, (%r12)
leaq -0x30(%rbp), %rcx
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %r8
callq 0xc040
testl %eax, %eax
jne 0x26f99
movq 0x15ed1(%rip), %r13     # 0x3cf60
cmpl $0x0, 0x1b6b4(%r13)
jle 0x27132
callq 0xc0b0
movl 0xc350(%r13), %r10d
movq -0x38(%rbp), %r15
movsd -0x30(%rbp), %xmm0
leaq 0xe908(%rip), %rsi      # 0x359c1
leaq 0xe3ee(%rip), %r8       # 0x354ae
movq %rbx, %rdi
xorl %edx, %edx
movl %eax, %ecx
movl $0x8a3, %r9d            # imm = 0x8A3
movb $0x1, %al
pushq %r15
pushq %r10
callq 0xc5e0
popq %rax
popq %rcx
jmp 0x27136
leaq -0x38(%rbp), %rcx
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %r8
callq 0xbc20
testl %eax, %eax
jne 0x26f99
movl -0x38(%rbp), %r14d
movl $0xffffeada, %eax       # imm = 0xFFFFEADA
leal (%r14,%rax), %ecx
cmpl %eax, %ecx
ja 0x27116
leaq 0xe86a(%rip), %rdi      # 0x3597b
jmp 0x26ffe
movl %r14d, %esi
callq 0xbb70
testb %al, %al
je 0x27256
leaq 0xe913(%rip), %rdi      # 0x35a40
jmp 0x26ffe
movq -0x38(%rbp), %r15
movq %r15, %rdi
callq 0xc650
testq %rax, %rax
je 0x2720e
movq %rax, %r12
cmpl $0x0, 0x1b6b4(%r13)
jle 0x272cd
callq 0xc0b0
subq $0x8, %rsp
leaq 0x16b18(%rip), %r10     # 0x3dc80
leaq 0xe780(%rip), %rsi      # 0x358ef
leaq 0xe338(%rip), %r8       # 0x354ae
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 0xc5e0
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 0x27043
callq 0xc0b0
movl 0xc350(%r13), %r10d
movsd -0x30(%rbp), %xmm0
leaq 0xe819(%rip), %rsi      # 0x359fe
leaq 0xe2c2(%rip), %r8       # 0x354ae
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 0xc5e0
popq %rax
popq %rcx
jmp 0x27043
leaq 0xe6cc(%rip), %rdi      # 0x358e1
callq 0xb220
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xb8e0
leaq 0xc6d0(%r13), %rdi
leaq 0xd77b(%rip), %rsi      # 0x349b0
pushq $0x50
popq %rdx
callq 0xb940
andw $0x0, 0xc71f(%r13)
movl $0x1, 0xd670(%r13)
jmp 0x2703f
movslq (%r12), %rax
cmpb $0x3d, (%r13,%rax)
jne 0x272c1
movq %r14, -0x40(%rbp)
incl %eax
movl %eax, (%r12)
leaq -0x30(%rbp), %rcx
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %r8
callq 0xc040
testl %eax, %eax
jne 0x26f99
movq 0x15cd0(%rip), %rax     # 0x3cf60
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 0x272f4
leaq 0xe6d1(%rip), %rdi      # 0x35999
jmp 0x26ffe
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 0x27043