// File: /workspace/github_cpp_makefile_star2_O1/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 0x2a45a
movq %rcx, %r14
incl %eax
movl %eax, (%rdx)
leaq -0x20(%rbp), %rcx
movq %rbx, %rdi
callq 0xaf10
testl %eax, %eax
je 0x2a4c3
movl %eax, %r15d
movq 0x19b64(%rip), %rbx     # 0x43f60
movslq 0xd670(%rbx), %rax
cmpq $0x30, %rax
jg 0x2a4b5
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
leaq (%rbx,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0x10ee4(%rip), %rsi     # 0x3b30b
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 0x2a4b5
leaq 0xfdf6(%rip), %rdi      # 0x3a257
callq 0xa1f0
movq %rbx, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
movq 0x19ae6(%rip), %rbx     # 0x43f60
movl $0x0, 0xd670(%rbx)
leaq 0xc6d0(%rbx), %rdi
leaq 0x10e79(%rip), %rsi     # 0x3b30b
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 0xc9f0(%rip), %xmm0     # 0x36ec0
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 0x10994(%rip), %xmm1    # 0x3ae90
jbe 0x2a509
movapd %xmm3, %xmm0
callq 0xa160
jmp 0x2a513
ucomisd 0x10987(%rip), %xmm1    # 0x3ae98
ja 0x2a51e
cvttsd2si %xmm0, %eax
cmpl $0x3e8, %eax            # imm = 0x3E8
jl 0x2a52a
leaq 0x11b02(%rip), %rdi     # 0x3c027
jmp 0x2a461
testl %eax, %eax
js 0x2a57f
movl %eax, %ecx
movq 0x19a59(%rip), %rdx     # 0x43f90
movslq (%rdx,%rcx,4), %rcx
cmpq $-0x1, %rcx
je 0x2a58b
cmpl $0x320, %eax            # imm = 0x320
jne 0x2a55a
xorl %r15d, %r15d
cmpl $-0x1, 0x150(%r14,%rcx,4)
jne 0x2a4b5
movl 0x150(%r14,%rcx,4), %edx
cmpl $-0x1, %edx
je 0x2a56f
cmpl $0x320, %edx            # imm = 0x320
jne 0x2a597
movl %eax, 0x150(%r14,%rcx,4)
xorl %r15d, %r15d
jmp 0x2a4b5
leaq 0x11ab5(%rip), %rdi     # 0x3c03b
jmp 0x2a461
leaq 0x11abe(%rip), %rdi     # 0x3c050
jmp 0x2a461
leaq 0x11ac6(%rip), %rdi     # 0x3c064
jmp 0x2a461
nop