// File: /workspace/github_cpp_makefile_star2_O1/sundale[P]gcode/rs274ngc/interp_inverse.cc
// Function: Interp::inverse_time_rate_straight(double, double, double, double, double, double, double, double, double, block_struct*, setup_struct*)
int Interp::inverse_time_rate_straight(double end_x,     //!< x coordinate of end point of straight line
                                       double end_y,     //!< y coordinate of end point of straight line
                                       double end_z,     //!< z coordinate of end point of straight line
                                       double AA_end,    //!< A coordinate of end point of straight line/*AA*/
                                       double BB_end,    //!< B coordinate of end point of straight line/*BB*/
                                       double CC_end,    //!< C coordinate of end point of straight line/*CC*/
                                       double u_end, double v_end, double w_end,
                                       block_pointer block,      //!< pointer to a block of RS274 instructions  
                                       setup_pointer settings)   //!< pointer to machine settings               
{
  double length;
  double rate;
  double cx, cy, cz;

  if (settings->feed_mode != INVERSE_TIME) return -1;

  if (settings->cutter_comp_side != OFF && settings->cutter_comp_radius > 0.0 &&
      settings->cutter_comp_firstmove == OFF) {
      cx = settings->program_x;
      cy = settings->program_y;
      cz = settings->program_z;
  } else {
      cx = settings->current_x;
      cy = settings->current_y;
      cz = settings->current_z;
  }

  length = find_straight_length(end_x, end_y, end_z,
                                AA_end, BB_end, CC_end,
                                u_end, v_end, w_end,
                                cx, cy, cz,
                                settings->AA_current, settings->BB_current, settings->CC_current,
                                settings->u_current, settings->v_current, settings->w_current);

  rate = MAX(0.1, (length * block->f_number));
  enqueue_SET_FEED_RATE(rate);
  settings->feed_rate = rate;

  return INTERP_OK;
}

// Assembly:
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl $0x1, 0x670(%rdx)
jne 0x2937a
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x60, %rsp
movq %rdx, %rbx
movq %rsi, %r14
cmpl $0x0, 0x624(%rdx)
movsd %xmm7, -0x18(%rbp)
je 0x292a7
movsd 0x618(%rbx), %xmm9
xorpd %xmm10, %xmm10
ucomisd %xmm10, %xmm9
jbe 0x292a7
cmpb $0x0, 0xc689(%rbx)
je 0x2937b
movl $0x610, %eax            # imm = 0x610
movl $0x608, %ecx            # imm = 0x608
movl $0x600, %edx            # imm = 0x600
movsd (%rbx,%rax), %xmm9
movsd (%rbx,%rcx), %xmm10
movsd (%rbx,%rdx), %xmm11
movsd 0x8(%rbx), %xmm12
movsd 0x20(%rbx), %xmm13
movsd 0x38(%rbx), %xmm14
movsd 0x50(%rbx), %xmm15
movsd 0x68(%rbx), %xmm8
movsd 0x80(%rbx), %xmm7
movsd %xmm7, 0x48(%rsp)
movsd %xmm8, 0x40(%rsp)
movsd %xmm15, 0x38(%rsp)
movsd %xmm14, 0x30(%rsp)
movsd %xmm13, 0x28(%rsp)
movsd %xmm12, 0x20(%rsp)
movsd %xmm9, 0x18(%rsp)
movsd %xmm10, 0x10(%rsp)
movsd %xmm11, 0x8(%rsp)
movsd 0x10(%rbp), %xmm7
movsd %xmm7, (%rsp)
movsd -0x18(%rbp), %xmm7
callq 0xa4c0
mulsd 0x148(%r14), %xmm0
movsd 0xbcaf(%rip), %xmm1     # 0x35000
maxsd %xmm0, %xmm1
movsd %xmm1, -0x18(%rbp)
movapd %xmm1, %xmm0
callq 0xa7a0
movsd -0x18(%rbp), %xmm0
movsd %xmm0, 0x678(%rbx)
xorl %eax, %eax
addq $0x60, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movl $0xc6a0, %eax           # imm = 0xC6A0
movl $0xc698, %ecx           # imm = 0xC698
movl $0xc690, %edx           # imm = 0xC690
jmp 0x292b6
nop