// File: /workspace/github_cpp_makefile_star2_O3/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 $0x88, %rsp
movq %rdi, %r14
movslq (%rdx), %rax
cmpb $0x5b, (%rsi,%rax)
jne 0x26806
movq %r8, %r12
movq %rdx, %r13
movq %rcx, -0x78(%rbp)
incl %eax
movl %eax, (%rdx)
leaq -0xb0(%rbp), %rcx
movq %r14, %rdi
movq %rsi, %r15
callq 0xaf10
testl %eax, %eax
jne 0x2679c
leaq -0x50(%rbp), %rcx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xb000
testl %eax, %eax
je 0x2686a
movl %eax, %ebx
movq 0x1a7bb(%rip), %r14     # 0x40f60
movslq 0xd670(%r14), %rax
cmpq $0x30, %rax
jg 0x26856
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
leaq (%r14,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0x118b3(%rip), %rsi     # 0x38083
movl $0x50, %edx
callq 0xa8a0
movslq 0xd670(%r14), %rax
leaq (%rax,%rax,4), %rcx
shlq $0x4, %rcx
xorl %edx, %edx
movb %dl, 0xc71f(%r14,%rcx)
incl %eax
movl %eax, 0xd670(%r14)
movb %dl, 0xc720(%r14,%rcx)
jmp 0x26856
leaq 0x10a42(%rip), %rdi     # 0x3724f
callq 0xa1f0
movq %r14, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
movq 0x1a73a(%rip), %rbx     # 0x40f60
leaq 0xc6d0(%rbx), %rdi
leaq 0x1184f(%rip), %rsi     # 0x38083
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
movl $0x5, %ebx
movl %ebx, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, -0x60(%rbp)
movq %r12, -0x68(%rbp)
cmpl $0xa, -0x50(%rbp)
jne 0x2688c
movsd -0xb0(%rbp), %xmm0
movq -0x78(%rbp), %rax
movsd %xmm0, (%rax)
xorl %ebx, %ebx
jmp 0x26856
movl $0x1, %eax
movq %r15, -0x58(%rbp)
movl %eax, -0x2c(%rbp)
movslq %eax, %r12
leaq -0xb0(,%r12,8), %rcx
addq %rbp, %rcx
movq %r14, %rdi
movq %r15, %rsi
movq -0x60(%rbp), %rdx
movq %rdx, %r13
movq %rcx, -0x70(%rbp)
movq -0x68(%rbp), %r8
callq 0xaf10
testl %eax, %eax
jne 0x2679c
leaq -0x50(,%r12,4), %rcx
addq %rbp, %rcx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xb000
testl %eax, %eax
jne 0x2679c
movl -0x50(%rbp,%r12,4), %esi
movq %r14, %rdi
movl %esi, -0x30(%rbp)
callq 0xa110
movl %eax, %ebx
movl -0x54(%rbp,%r12,4), %esi
movq %r14, %rdi
callq 0xa110
cmpl %eax, %ebx
jle 0x26916
movl -0x2c(%rbp), %eax
incl %eax
jmp 0x269b8
movq -0x70(%rbp), %r15
movl -0x2c(%rbp), %ecx
testl %ecx, %ecx
movl $0x1, %eax
cmovgl %eax, %ecx
movl %ecx, -0x2c(%rbp)
movq %r14, %r13
movl -0x30(%rbp), %r14d
movq %r13, %rdi
movl %r14d, %esi
callq 0xa110
movl %eax, %r14d
movl -0x54(%rbp,%r12,4), %ebx
movq %r13, %rdi
movl %ebx, %esi
callq 0xa110
cmpl %eax, %r14d
movq %r13, %r14
jg 0x269ad
movq %r15, %rcx
addq $-0x8, %r15
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0xa250
testl %eax, %eax
jne 0x2679c
movq %r14, %r13
movl -0x30(%rbp), %r14d
movl %r14d, -0x54(%rbp,%r12,4)
cmpq $0x2, %r12
jl 0x269b2
movq %r13, %rdi
movl %r14d, %esi
callq 0xa110
movl %eax, %ebx
movl -0x58(%rbp,%r12,4), %esi
movq %r13, %rdi
callq 0xa110
decq %r12
cmpl %eax, %ebx
jle 0x26931
incl %r12d
movl %r12d, %eax
jmp 0x269b5
movl %r12d, %eax
jmp 0x269b8
movl -0x2c(%rbp), %eax
movq %r13, %r14
cmpl $0xa, -0x50(%rbp)
movq -0x58(%rbp), %r15
jne 0x26895
jmp 0x26878
nop