// File: /workspace/github_cpp_makefile_star2_O3/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 0x27140
movq %rcx, %r14
incl %eax
movl %eax, (%rdx)
leaq -0x20(%rbp), %rcx
movq %rbx, %rdi
callq 0xaf10
testl %eax, %eax
je 0x2719f
movl %eax, %r15d
movq 0x19e7e(%rip), %rbx     # 0x40f60
movslq 0xd670(%rbx), %rax
cmpq $0x30, %rax
jg 0x27191
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
leaq (%rbx,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0x111fe(%rip), %rsi     # 0x3830b
movl $0x50, %edx
callq 0xa8a0
movslq 0xd670(%rbx), %rax
leaq (%rax,%rax,4), %rcx
shlq $0x4, %rcx
xorl %edx, %edx
movb %dl, 0xc71f(%rbx,%rcx)
incl %eax
movl %eax, 0xd670(%rbx)
movb %dl, 0xc720(%rbx,%rcx)
jmp 0x27191
leaq 0x10108(%rip), %rdi     # 0x3724f
callq 0xa1f0
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
movq 0x19e00(%rip), %rbx     # 0x40f60
leaq 0xc6d0(%rbx), %rdi
leaq 0x1119d(%rip), %rsi     # 0x3830b
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
movl $0x5, %r15d
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movsd -0x20(%rbp), %xmm0
mulsd 0xcd14(%rip), %xmm0     # 0x33ec0
movsd %xmm0, -0x28(%rbp)
movsd %xmm0, -0x20(%rbp)
callq 0xb2f0
movsd -0x28(%rbp), %xmm3
cvttpd2dq %xmm0, %xmm1
cvtdq2pd %xmm1, %xmm2
movapd %xmm3, %xmm1
subsd %xmm2, %xmm1
ucomisd 0x10cb8(%rip), %xmm1    # 0x37e90
jbe 0x271e5
movapd %xmm3, %xmm0
callq 0xa160
jmp 0x271ef
ucomisd 0x10cab(%rip), %xmm1    # 0x37e98
ja 0x271fa
cvttsd2si %xmm0, %eax
cmpl $0x3e8, %eax            # imm = 0x3E8
jl 0x27206
leaq 0x11e26(%rip), %rdi     # 0x39027
jmp 0x27147
testl %eax, %eax
js 0x2723a
movl %eax, %ecx
movq 0x19d7d(%rip), %rdx     # 0x40f90
movslq (%rdx,%rcx,4), %rcx
cmpq $-0x1, %rcx
je 0x27246
movl 0x150(%r14,%rcx,4), %edx
cmpl $0x320, %eax            # imm = 0x320
jne 0x27252
xorl %r15d, %r15d
cmpl $-0x1, %edx
jne 0x27191
jmp 0x2725f
leaq 0x11dfa(%rip), %rdi     # 0x3903b
jmp 0x27147
leaq 0x11e03(%rip), %rdi     # 0x39050
jmp 0x27147
cmpl $-0x1, %edx
je 0x2725f
cmpl $0x320, %edx            # imm = 0x320
jne 0x2726f
movl %eax, 0x150(%r14,%rcx,4)
xorl %r15d, %r15d
jmp 0x27191
leaq 0x11dee(%rip), %rdi     # 0x39064
jmp 0x27147
nop