// File: 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
subq $0xb0, %rsp
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movsd %xmm0, -0x28(%rbp)
movsd %xmm1, -0x30(%rbp)
movsd %xmm2, -0x38(%rbp)
movsd %xmm3, -0x40(%rbp)
movsd %xmm4, -0x48(%rbp)
movl %r8d, -0x4c(%rbp)
movsd %xmm5, -0x58(%rbp)
movsd %xmm6, -0x60(%rbp)
movq %r9, -0x68(%rbp)
movsd %xmm7, -0x70(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x98(%rbp)
movsd 0x64a0d(%rip), %xmm0    # 0x77000
mulsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movl -0x18(%rbp), %esi
callq 0x10860
movq -0x98(%rbp), %rdi
movb %al, -0x89(%rbp)
movl -0x18(%rbp), %esi
callq 0x10640
movb %al, -0x8a(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0x12645
movsd -0x58(%rbp), %xmm0
movq -0x68(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x60(%rbp), %xmm0
movq 0x10(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x12669
movsd -0x30(%rbp), %xmm0
addsd -0x58(%rbp), %xmm0
movq -0x68(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x38(%rbp), %xmm0
addsd -0x60(%rbp), %xmm0
movq 0x10(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x68(%rbp), %rax
movsd (%rax), %xmm0
subsd -0x30(%rbp), %xmm0
movq 0x10(%rbp), %rax
movsd (%rax), %xmm1
subsd -0x38(%rbp), %xmm1
callq 0x10460
movsd %xmm0, -0x78(%rbp)
movq -0x68(%rbp), %rax
movsd (%rax), %xmm0
subsd -0x40(%rbp), %xmm0
movq 0x10(%rbp), %rax
movsd (%rax), %xmm1
subsd -0x48(%rbp), %xmm1
callq 0x10460
movsd %xmm0, -0x80(%rbp)
movsd -0x78(%rbp), %xmm1
movsd -0x88(%rbp), %xmm0
ucomisd %xmm1, %xmm0
ja 0x126db
movsd -0x80(%rbp), %xmm1
movsd -0x88(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x127b3
jmp 0x126dd
leaq 0x6496c(%rip), %rdi     # 0x77050
callq 0x10380
movq -0x98(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x7485f(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x7484e(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x74840(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x6492b(%rip), %rsi     # 0x77060
movl $0x50, %edx
callq 0x10840
movq 0x7481a(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x7480c(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x747f4(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x747e4(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x747d7(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x747c9(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x12b2c
jmp 0x127b5
jmp 0x127b7
movsd -0x78(%rbp), %xmm0
subsd -0x80(%rbp), %xmm0
movaps 0x64858(%rip), %xmm1    # 0x77020
pand %xmm1, %xmm0
ucomisd -0x70(%rbp), %xmm0
jbe 0x12912
jmp 0x127d9
leaq 0x6490d(%rip), %rdi     # 0x770ed
callq 0x10380
movq -0x98(%rbp), %rdi
movq %rax, %rsi
movsbl -0x89(%rbp), %edx
movsd -0x30(%rbp), %xmm0
movsbl -0x8a(%rbp), %ecx
movsd -0x38(%rbp), %xmm1
movsbl -0x89(%rbp), %r8d
movq -0x68(%rbp), %rax
movsd (%rax), %xmm2
movsbl -0x8a(%rbp), %r9d
movq 0x10(%rbp), %rax
movsd (%rax), %xmm3
movsbl -0x89(%rbp), %r10d
movsd -0x40(%rbp), %xmm4
movsbl -0x8a(%rbp), %eax
movsd -0x48(%rbp), %xmm5
movsd -0x78(%rbp), %xmm6
movsd -0x80(%rbp), %xmm7
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x8, %al
callq 0x10df0
movq 0x74700(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x746ef(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x746e1(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x647cc(%rip), %rsi     # 0x77060
movl $0x50, %edx
callq 0x10840
movq 0x746bb(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x746ad(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x74695(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x74685(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x74678(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x7466a(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x12b2c
jmp 0x12914
jmp 0x12916
movsd -0x78(%rbp), %xmm1
movsd -0x28(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x12a22
cmpl $0x2, -0x1c(%rbp)
jne 0x12936
cmpl $0x1e, -0x14(%rbp)
je 0x1294a
cmpl $0x1, -0x1c(%rbp)
jne 0x12a22
cmpl $0x14, -0x14(%rbp)
jne 0x12a22
jmp 0x1294c
leaq 0x6481e(%rip), %rdi     # 0x77171
callq 0x10380
movq -0x98(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x745f0(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x745df(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x745d1(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x646bc(%rip), %rsi     # 0x77060
movl $0x50, %edx
callq 0x10840
movq 0x745ab(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x7459d(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x74585(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x74575(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x74568(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x7455a(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x12b2c
jmp 0x12a24
cmpl $0x14, -0x14(%rbp)
jne 0x12a39
movq 0x18(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
jmp 0x12b25
cmpl $0x1e, -0x14(%rbp)
jne 0x12a4e
movq 0x18(%rbp), %rax
movl $0x1, (%rax)
jmp 0x12b23
jmp 0x12a50
leaq 0x64749(%rip), %rdi     # 0x771a0
callq 0x10380
movq -0x98(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x744ec(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x744db(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x744cd(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x645b8(%rip), %rsi     # 0x77060
movl $0x50, %edx
callq 0x10840
movq 0x744a7(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x74499(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x74481(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x74471(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x74464(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x74456(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x12b2c
jmp 0x12b25
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax,%rax)