// File: /workspace/github_cpp_makefile_star2_O1/sundale[P]gcode/rs274ngc/interp_arc.cc
// Function: Interp::arc_data_comp_ijk(int, int, int, double, double, double, double, double, int, double, double, double*, double*, int*, double)
int Interp::arc_data_comp_ijk(int move,  //!<either G_2 (cw arc) or G_3 (ccw arc)
                              int plane, //!<active plane
                             int side,  //!<either RIGHT or LEFT
                             double tool_radius,        //!<radius of the tool
                             double current_x,  //!<first coordinate of current point
                             double current_y,  //!<second coordinate of current point
                             double end_x,      //!<first coordinate of arc end point
                             double end_y,      //!<second coordinate of arc end point
                             int ij_absolute,   //!<how to interpret i/j numbers
                             double i_number,   //!<first coordinate of center (abs or incr)
                             double j_number,   //!<second coordinate of center (abs or incr)
                             double *center_x,  //!<pointer to first coordinate of center of arc
                             double *center_y,  //!<pointer to second coordinate of center of arc
                             int *turn, //!<pointer to number of full or partial circles CCW
                             double tolerance)  //!<tolerance of differing radii
{
  double arc_radius;
  double radius2;
  double min_radius = 0.1 * tolerance;	/* smaller than this is treated as zero */
  char a = arc_axis1(plane), b = arc_axis2(plane);

  if ( ij_absolute ) {
    *center_x = (i_number);
    *center_y = (j_number);
  } else {
    *center_x = (current_x + i_number);
    *center_y = (current_y + j_number);
  }
  arc_radius = hypot((*center_x - current_x), (*center_y - current_y));
  radius2 = hypot((*center_x - end_x), (*center_y - end_y));
  CHKS(((arc_radius < min_radius) || (radius2 < min_radius)), _("Zero radius arc"));
  CHKS((fabs(arc_radius - radius2) > tolerance),
      _("Radius to end of arc differs from radius to start: "
       "start=(%c%.4f,%c%.4f) center=(%c%.4f,%c%.4f) end=(%c%.4f,%c%.4f) r1=%.4f r2=%.4f"),
       a, current_x, b, current_y, 
       a, *center_x, b, *center_y, 
       a, end_x, b, end_y, arc_radius, radius2);

  CHKS(((arc_radius <= tool_radius) && (((side == LEFT) && (move == G_3)) ||
                                       ((side == RIGHT) && (move == G_2)))),
      NCE_TOOL_RADIUS_NOT_LESS_THAN_ARC_RADIUS_WITH_COMP);

  /* This catches an arc too small for the tool, also */
  if (move == G_2)
    *turn = -1;
  else if (move == G_3)
    *turn = 1;
  else
    ERS(NCE_BUG_CODE_NOT_G2_OR_G3);
  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, %r13
movsd %xmm4, -0x58(%rbp)
movsd %xmm3, -0x50(%rbp)
movsd %xmm0, -0x60(%rbp)
movl %ecx, -0x2c(%rbp)
movl %edx, %r14d
movl %esi, %r15d
movq %rdi, -0x38(%rbp)
leal -0x1(%r14), %eax
addl $0x57, %r14d
movl $0x21, %r12d
cmpl $0x3, %eax
cmovael %r12d, %r14d
jae 0xb980
movl %eax, %eax
leaq 0x299f0(%rip), %rcx     # 0x3536c
movl (%rcx,%rax,4), %r12d
movq 0x10(%rbp), %rbx
movsd 0x29674(%rip), %xmm0    # 0x35000
mulsd %xmm7, %xmm0
testl %r8d, %r8d
movsd %xmm7, -0x78(%rbp)
movsd %xmm0, -0x40(%rbp)
je 0xb9a7
movsd %xmm5, (%r13)
jmp 0xb9b5
addsd %xmm1, %xmm5
movsd %xmm5, (%r13)
addsd %xmm2, %xmm6
movsd %xmm6, (%rbx)
movsd (%r13), %xmm0
movsd %xmm1, -0x68(%rbp)
subsd %xmm1, %xmm0
movsd %xmm2, -0x70(%rbp)
subsd %xmm2, %xmm6
movapd %xmm6, %xmm1
callq 0xa290
movsd %xmm0, -0x48(%rbp)
movsd (%r13), %xmm0
subsd -0x50(%rbp), %xmm0
movsd (%rbx), %xmm1
subsd -0x58(%rbp), %xmm1
callq 0xa290
movsd -0x48(%rbp), %xmm1
movsd -0x40(%rbp), %xmm2
ucomisd %xmm1, %xmm2
ja 0xba86
ucomisd %xmm0, %xmm2
ja 0xba86
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
andpd 0x29602(%rip), %xmm2    # 0x35020
ucomisd -0x78(%rbp), %xmm2
jbe 0xbaf0
leaq 0x296bd(%rip), %rdi     # 0x350ed
movsd %xmm0, -0x40(%rbp)
callq 0xa1f0
movsd (%r13), %xmm2
movsd (%rbx), %xmm3
movq -0x38(%rbp), %rdi
movq %rax, %rsi
movl %r14d, %edx
movsd -0x68(%rbp), %xmm0
movl %r12d, %ecx
movsd -0x70(%rbp), %xmm1
movl %r14d, %r8d
movl %r12d, %r9d
movsd -0x50(%rbp), %xmm4
movsd -0x58(%rbp), %xmm5
movsd -0x48(%rbp), %xmm6
movsd -0x40(%rbp), %xmm7
movb $0x8, %al
pushq %r12
pushq %r14
callq 0xa850
addq $0x10, %rsp
jmp 0xbaa0
leaq 0x295c3(%rip), %rdi     # 0x35050
callq 0xa1f0
movq -0x38(%rbp), %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
movq 0x384b9(%rip), %rbx     # 0x43f60
movl $0x0, 0xd670(%rbx)
leaq 0xc6d0(%rbx), %rdi
leaq 0x295a1(%rip), %rsi     # 0x35060
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
movl $0x5, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsd -0x60(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jae 0xbb0e
cmpl $0x14, %r15d
je 0xbb3a
cmpl $0x1e, %r15d
jne 0xbb49
movl $0x1, %eax
jmp 0xbb3f
movl -0x2c(%rbp), %eax
xorl $0x2, %eax
movl %r15d, %ecx
xorl $0x1e, %ecx
orl %eax, %ecx
je 0xbb2e
movl -0x2c(%rbp), %ecx
xorl $0x1, %ecx
movl %r15d, %eax
xorl $0x14, %eax
orl %ecx, %eax
jne 0xbafb
leaq 0x2963c(%rip), %rdi     # 0x35171
jmp 0xba8d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq 0x18(%rbp), %rcx
movl %eax, (%rcx)
xorl %eax, %eax
jmp 0xbae1
leaq 0x29650(%rip), %rdi     # 0x351a0
jmp 0xba8d
nop