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

  c = line[*counter];
  CHKS((c == 0), NCE_NO_CHARACTERS_FOUND_IN_READING_REAL_VALUE);

  c1 = line[*counter+1];

  if (c == '[')
    CHP(read_real_expression(line, counter, double_ptr, parameters));
  else if (c == '#')
  {
    CHP(read_parameter(line, counter, double_ptr, parameters));
  }
  else if (c == '+' && c1 && !isdigit(c1) && c1 != '.')
  {
    (*counter)++;
    CHP(read_real_value(line, counter, double_ptr, parameters));
  }
  else if (c == '-' && c1 && !isdigit(c1) && c1 != '.')
  {
    (*counter)++;
    CHP(read_real_value(line, counter, double_ptr, parameters));
    *double_ptr = -*double_ptr;
  }
  else if ((c >= 'a') && (c <= 'z'))
    CHP(read_unary(line, counter, double_ptr, parameters));
  else
    CHP(read_real_number(line, counter, double_ptr));

  CHKS(isnan(*double_ptr),
          "Calculation resulted in 'not a number'");
  CHKS(isinf(*double_ptr),
          "Calculation resulted in 'infinity'");

  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %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, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rcx), %rcx
movb (%rax,%rcx), %al
movb %al, -0x31(%rbp)
movsbl -0x31(%rbp), %eax
cmpl $0x0, %eax
jne 0x5c577
jmp 0x5c4a4
leaq 0x22279(%rip), %rdi     # 0x7e724
callq 0x10380
movq -0x58(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x2aa9b(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x2aa8a(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x2aa7c(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x22255(%rip), %rsi     # 0x7e74e
movl $0x50, %edx
callq 0x10840
movq 0x2aa56(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x2aa48(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x2aa30(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x2aa20(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x2aa13(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x2aa05(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x5cdc3
jmp 0x5c579
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movl (%rcx), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %al
movb %al, -0x32(%rbp)
movsbl -0x31(%rbp), %eax
cmpl $0x5b, %eax
jne 0x5c688
jmp 0x5c59e
movq -0x58(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x119e0
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
je 0x5c681
jmp 0x5c5c6
movq 0x2a993(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x5c676
movq 0x2a97f(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x2a971(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x2214a(%rip), %rsi     # 0x7e74e
movl $0x50, %edx
callq 0x10840
movq 0x2a94b(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x2a93d(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x2a925(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x2a915(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x2a908(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x2a8fa(%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 0x5cdc3
jmp 0x5c683
jmp 0x5cbf1
movsbl -0x31(%rbp), %eax
cmpl $0x23, %eax
jne 0x5c781
jmp 0x5c697
movq -0x58(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x10ff0
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x5c77a
jmp 0x5c6bf
movq 0x2a89a(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x5c76f
movq 0x2a886(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x2a878(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x22051(%rip), %rsi     # 0x7e74e
movl $0x50, %edx
callq 0x10840
movq 0x2a852(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x2a844(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x2a82c(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x2a81c(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x2a80f(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x2a801(%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 0x5cdc3
jmp 0x5c77c
jmp 0x5cbef
movsbl -0x31(%rbp), %eax
cmpl $0x2b, %eax
jne 0x5c8ac
cmpb $0x0, -0x32(%rbp)
je 0x5c8ac
movsbl -0x32(%rbp), %edi
callq 0x10f80
cmpl $0x0, %eax
jne 0x5c8ac
movsbl -0x32(%rbp), %eax
cmpl $0x2e, %eax
je 0x5c8ac
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x58(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x118a0
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
je 0x5c8a5
jmp 0x5c7ea
movq 0x2a76f(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x5c89a
movq 0x2a75b(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x2a74d(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x21f26(%rip), %rsi     # 0x7e74e
movl $0x50, %edx
callq 0x10840
movq 0x2a727(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x2a719(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x2a701(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x2a6f1(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x2a6e4(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x2a6d6(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5cdc3
jmp 0x5c8a7
jmp 0x5cbed
movsbl -0x31(%rbp), %eax
cmpl $0x2d, %eax
jne 0x5c9fe
cmpb $0x0, -0x32(%rbp)
je 0x5c9fe
movsbl -0x32(%rbp), %edi
callq 0x10f80
cmpl $0x0, %eax
jne 0x5c9fe
movsbl -0x32(%rbp), %eax
cmpl $0x2e, %eax
je 0x5c9fe
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x58(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x118a0
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x5c9d0
jmp 0x5c915
movq 0x2a644(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x5c9c5
movq 0x2a630(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x2a622(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x21dfb(%rip), %rsi     # 0x7e74e
movl $0x50, %edx
callq 0x10840
movq 0x2a5fc(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x2a5ee(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x2a5d6(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x2a5c6(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x2a5b9(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x2a5ab(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5cdc3
jmp 0x5c9d2
movq -0x28(%rbp), %rax
movsd (%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x5cbeb
movsbl -0x31(%rbp), %eax
cmpl $0x61, %eax
jl 0x5cb04
movsbl -0x31(%rbp), %eax
cmpl $0x7a, %eax
jg 0x5cb04
jmp 0x5ca1a
movq -0x58(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x102f0
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
je 0x5cafd
jmp 0x5ca42
movq 0x2a517(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x5caf2
movq 0x2a503(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x2a4f5(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x21cce(%rip), %rsi     # 0x7e74e
movl $0x50, %edx
callq 0x10840
movq 0x2a4cf(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x2a4c1(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x2a4a9(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x2a499(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x2a48c(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x2a47e(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x48(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5cdc3
jmp 0x5caff
jmp 0x5cbe9
jmp 0x5cb06
movq -0x58(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x123b0
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0x5cbe5
jmp 0x5cb2a
movq 0x2a42f(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x5cbda
movq 0x2a41b(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x2a40d(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x21be6(%rip), %rsi     # 0x7e74e
movl $0x50, %edx
callq 0x10840
movq 0x2a3e7(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x2a3d9(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x2a3c1(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x2a3b1(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x2a3a4(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x2a396(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x4c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5cdc3
jmp 0x5cbe7
jmp 0x5cbe9
jmp 0x5cbeb
jmp 0x5cbed
jmp 0x5cbef
jmp 0x5cbf1
jmp 0x5cbf3
movq -0x28(%rbp), %rax
movsd (%rax), %xmm0
callq 0x100c0
testb $0x1, %al
jne 0x5cc09
jmp 0x5ccd6
jmp 0x5cc0b
movq -0x58(%rbp), %rdi
leaq 0x21b77(%rip), %rsi     # 0x7e78d
movb $0x0, %al
callq 0x10df0
movq 0x2a33c(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x2a32b(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x2a31d(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x21af6(%rip), %rsi     # 0x7e74e
movl $0x50, %edx
callq 0x10840
movq 0x2a2f7(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x2a2e9(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x2a2d1(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x2a2c1(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x2a2b4(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x2a2a6(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x5cdc3
jmp 0x5ccd8
jmp 0x5ccda
movq -0x28(%rbp), %rax
movsd (%rax), %xmm0
callq 0x104c0
testb $0x1, %al
jne 0x5ccf0
jmp 0x5cdba
jmp 0x5ccf2
movq -0x58(%rbp), %rdi
leaq 0x21ab7(%rip), %rsi     # 0x7e7b4
movb $0x0, %al
callq 0x10df0
movq 0x2a255(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x2a244(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x2a236(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x21a0f(%rip), %rsi     # 0x7e74e
movl $0x50, %edx
callq 0x10840
movq 0x2a210(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x2a202(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x2a1ea(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x2a1da(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x2a1cd(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x2a1bf(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x5cdc3
jmp 0x5cdbc
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)