// File: /workspace/github_cpp_makefile_star2_O2/sundale[P]gcode/rs274ngc/interp_read.cc
// Function: Interp::read_real_expression(char*, int*, double*, double*)
int Interp::read_real_expression(char *line,     //!< string: line of RS274/NGC code being processed
                                int *counter,   //!< pointer to a counter for position on the line 
                                double *value,  //!< pointer to double to be computed              
                                double *parameters)     //!< array of system parameters                    
{
  double values[MAX_STACK];
  int operators[MAX_STACK];
  int stack_index;

  CHKS((line[*counter] != '['), NCE_BUG_FUNCTION_SHOULD_NOT_HAVE_BEEN_CALLED);
  *counter = (*counter + 1);
  CHP(read_real_value(line, counter, values, parameters));
  CHP(read_operation(line, counter, operators));
  stack_index = 1;
  for (; operators[0] != RIGHT_BRACKET;) {
    CHP(read_real_value(line, counter, values + stack_index, parameters));
    CHP(read_operation(line, counter, operators + stack_index));
    if (precedence(operators[stack_index]) >
        precedence(operators[stack_index - 1]))
      stack_index++;
    else {                      /* precedence of latest operator is <= previous precedence */

      for (; precedence(operators[stack_index]) <=
           precedence(operators[stack_index - 1]);) {
        CHP(execute_binary((values + stack_index - 1),
                           operators[stack_index - 1],
                           (values + stack_index)));
        operators[stack_index - 1] = operators[stack_index];
        if ((stack_index > 1) &&
            (precedence(operators[stack_index - 1]) <=
             precedence(operators[stack_index - 2])))
          stack_index--;
        else
          break;
      }
    }
  }
  *value = values[0];
  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %r14
movslq (%rdx), %rax
cmpb $0x5b, (%rsi,%rax)
jne 0x23fe8
movq %rdx, %r12
movq %rsi, %r15
movq %rcx, -0x80(%rbp)
incl %eax
movl %eax, (%rdx)
leaq -0xc0(%rbp), %rcx
movq %r14, %rdi
movq %r8, %r13
callq 0xc040
testl %eax, %eax
jne 0x23f88
leaq -0x70(%rbp), %rcx
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xc130
testl %eax, %eax
je 0x24047
movl %eax, %ebx
movq 0x18fcf(%rip), %r14     # 0x3cf60
movslq 0xd670(%r14), %rax
cmpq $0x30, %rax
jg 0x24033
imulq $0x50, %rax, %rax
leaq (%r14,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0x100cb(%rip), %rsi     # 0x34083
pushq $0x50
popq %rdx
callq 0xb940
movslq 0xd670(%r14), %rax
imulq $0x50, %rax, %rcx
xorl %edx, %edx
movb %dl, 0xc71f(%r14,%rcx)
incl %eax
movl %eax, 0xd670(%r14)
movb %dl, 0xc720(%r14,%rcx)
jmp 0x24033
leaq 0xf260(%rip), %rdi      # 0x3324f
callq 0xb220
movq %r14, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xb8e0
movq 0x18f58(%rip), %rbx     # 0x3cf60
leaq 0xc6d0(%rbx), %rdi
leaq 0x1006d(%rip), %rsi     # 0x34083
pushq $0x50
popq %rdx
callq 0xb940
andw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
pushq $0x5
popq %rbx
movl %ebx, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %rax
movl %eax, -0x2c(%rbp)
movq %r13, %rax
movq %r13, -0x50(%rbp)
movq %r12, -0x38(%rbp)
movq %r15, -0x48(%rbp)
cmpl $0xa, -0x70(%rbp)
je 0x241a4
movq %r12, %rdx
movslq -0x2c(%rbp), %r12
leaq -0xc0(,%r12,8), %rcx
addq %rbp, %rcx
movq %r14, %rdi
movq %r15, %rsi
movq %rcx, -0x78(%rbp)
movq %rax, %r8
callq 0xc040
testl %eax, %eax
jne 0x23f88
leaq -0x70(,%r12,4), %r13
addq %rbp, %r13
movq %r14, %rdi
movq %r15, %rsi
movq -0x38(%rbp), %rdx
movq %r13, %rcx
callq 0xc130
testl %eax, %eax
jne 0x23f88
movl (%r13), %esi
movq %r14, %rdi
movl %esi, -0x3c(%rbp)
callq 0xb120
movl %eax, %r15d
movl -0x2c(%rbp), %ebx
movslq %ebx, %rax
movl -0x74(%rbp,%rax,4), %esi
movq %r14, %rdi
callq 0xb120
cmpl %eax, %r15d
jle 0x240ea
incl %ebx
movl %ebx, -0x2c(%rbp)
jmp 0x24193
movq -0x78(%rbp), %r15
testl %ebx, %ebx
pushq $0x1
popq %rax
cmovgl %eax, %ebx
movl %ebx, -0x2c(%rbp)
movq %r14, %r13
movl -0x3c(%rbp), %r14d
movq %r13, %rdi
movl %r14d, %esi
callq 0xb120
movl %eax, %r14d
movl -0x74(%rbp,%r12,4), %ebx
movq %r13, %rdi
movl %ebx, %esi
callq 0xb120
cmpl %eax, %r14d
movq %r13, %r14
jg 0x2418f
movq %r15, %rcx
addq $-0x8, %r15
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0xb280
testl %eax, %eax
jne 0x23f88
movq %r14, %r13
movl -0x3c(%rbp), %r14d
movl %r14d, -0x74(%rbp,%r12,4)
cmpq $0x2, %r12
jl 0x2417b
movq %r13, %rdi
movl %r14d, %esi
callq 0xb120
movl %eax, %ebx
movl -0x78(%rbp,%r12,4), %esi
movq %r13, %rdi
callq 0xb120
decq %r12
cmpl %eax, %ebx
jle 0x24100
incl %r12d
movl %r12d, -0x2c(%rbp)
movq -0x50(%rbp), %rax
movq -0x38(%rbp), %r12
movq -0x48(%rbp), %r15
movq %r13, %r14
jmp 0x2405c
movl %r12d, -0x2c(%rbp)
movq -0x50(%rbp), %rax
movq -0x38(%rbp), %r12
movq -0x48(%rbp), %r15
jmp 0x2405c
movsd -0xc0(%rbp), %xmm0
movq -0x80(%rbp), %rax
movsd %xmm0, (%rax)
xorl %ebx, %ebx
jmp 0x24033
nop