// File: /workspace/github_cpp_makefile_star2_O2/sundale[P]gcode/rs274ngc/interp_read.cc
// Function: Interp::read_g(char*, int*, block_struct*, double*)
int Interp::read_g(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                    
{
  double value_read;
  int value;
  int mode;

  CHKS((line[*counter] != 'g'), NCE_BUG_FUNCTION_SHOULD_NOT_HAVE_BEEN_CALLED);
  *counter = (*counter + 1);
  CHP(read_real_value(line, counter, &value_read, parameters));
  value_read = (10.0 * value_read);
  value = (int) floor(value_read);

  if ((value_read - value) > 0.999)
    value = (int) ceil(value_read);
  else if ((value_read - value) > 0.001)
    ERS(NCE_G_CODE_OUT_OF_RANGE);

  CHKS((value > 999), NCE_G_CODE_OUT_OF_RANGE);
  CHKS((value < 0), NCE_NEGATIVE_G_CODE_USED);
  mode = _gees[value];
  CHKS((mode == -1), NCE_UNKNOWN_G_CODE_USED);
  if ((value == G_80) && (block->g_modes[mode] != -1));
  else {
    if (block->g_modes[mode] == G_80);
    else {
      CHKS((block->g_modes[mode] != -1),
          NCE_TWO_G_CODES_USED_FROM_SAME_MODAL_GROUP);
    }
    block->g_modes[mode] = value;
  }
  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movslq (%rdx), %rax
cmpb $0x67, (%rsi,%rax)
jne 0x248ac
movq %rcx, %r14
incl %eax
movl %eax, (%rdx)
leaq -0x20(%rbp), %rcx
movq %rbx, %rdi
callq 0xc040
testl %eax, %eax
je 0x24906
movl %eax, %r15d
movq 0x18708(%rip), %rbx     # 0x3cf60
movslq 0xd670(%rbx), %rax
cmpq $0x30, %rax
jg 0x248f8
imulq $0x50, %rax, %rax
leaq (%rbx,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0xfa8c(%rip), %rsi      # 0x3430b
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 0x248f8
leaq 0xe99c(%rip), %rdi      # 0x3324f
callq 0xb220
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xb8e0
movq 0x18694(%rip), %rbx     # 0x3cf60
leaq 0xc6d0(%rbx), %rdi
leaq 0xfa31(%rip), %rsi      # 0x3430b
pushq $0x50
popq %rdx
callq 0xb940
andw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
pushq $0x5
popq %r15
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movsd -0x20(%rbp), %xmm0
mulsd 0xb5ad(%rip), %xmm0     # 0x2fec0
movsd %xmm0, -0x28(%rbp)
movsd %xmm0, -0x20(%rbp)
callq 0xc450
movsd -0x28(%rbp), %xmm3
cvttpd2dq %xmm0, %xmm1
cvtdq2pd %xmm1, %xmm2
movapd %xmm3, %xmm1
subsd %xmm2, %xmm1
ucomisd 0xf551(%rip), %xmm1     # 0x33e90
jbe 0x2494c
movapd %xmm3, %xmm0
callq 0xb170
jmp 0x24956
ucomisd 0xf544(%rip), %xmm1     # 0x33e98
ja 0x24961
cvttsd2si %xmm0, %eax
cmpl $0x3e8, %eax            # imm = 0x3E8
jl 0x2496d
leaq 0x106bf(%rip), %rdi     # 0x35027
jmp 0x248b3
testl %eax, %eax
js 0x249a1
movl %eax, %ecx
movq 0x18616(%rip), %rdx     # 0x3cf90
movslq (%rdx,%rcx,4), %rcx
cmpq $-0x1, %rcx
je 0x249ad
movl 0x150(%r14,%rcx,4), %edx
cmpl $0x320, %eax            # imm = 0x320
jne 0x249b9
xorl %r15d, %r15d
cmpl $-0x1, %edx
jne 0x248f8
jmp 0x249c6
leaq 0x10693(%rip), %rdi     # 0x3503b
jmp 0x248b3
leaq 0x1069c(%rip), %rdi     # 0x35050
jmp 0x248b3
cmpl $-0x1, %edx
je 0x249c6
cmpl $0x320, %edx            # imm = 0x320
jne 0x249d6
movl %eax, 0x150(%r14,%rcx,4)
xorl %r15d, %r15d
jmp 0x248f8
leaq 0x10687(%rip), %rdi     # 0x35064
jmp 0x248b3