// File: sundale[P]gcode/rs274ngc/interp_arc.cc
// Function: Interp::arc_data_ijk(int, int, double, double, double, double, int, double, double, double*, double*, int*, double)
int Interp::arc_data_ijk(int move,       //!< either G_2 (cw arc) or G_3 (ccw arc)
                         int plane,
                        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 no. of full or partial circles CCW
                        double tolerance)       //!< tolerance of differing radii
{
  double radius;                /* radius to current point */
  double radius2;               /* radius to end point     */
  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);
  }
  radius = hypot((*center_x - current_x), (*center_y - current_y));
  radius2 = hypot((*center_x - end_x), (*center_y - end_y));
  CHKS(((radius < min_radius) || (radius2 < min_radius)), NCE_ZERO_RADIUS_ARC);
  CHKS((fabs(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, radius, radius2);
  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 $0xa0, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movsd %xmm0, -0x20(%rbp)
movsd %xmm1, -0x28(%rbp)
movsd %xmm2, -0x30(%rbp)
movsd %xmm3, -0x38(%rbp)
movl %ecx, -0x3c(%rbp)
movsd %xmm4, -0x48(%rbp)
movsd %xmm5, -0x50(%rbp)
movq %r8, -0x58(%rbp)
movq %r9, -0x60(%rbp)
movsd %xmm6, -0x68(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x90(%rbp)
movsd 0x63e06(%rip), %xmm0    # 0x77000
mulsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
movl -0x18(%rbp), %esi
callq 0x10860
movq -0x90(%rbp), %rdi
movb %al, -0x81(%rbp)
movl -0x18(%rbp), %esi
callq 0x10640
movb %al, -0x82(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x13249
movsd -0x48(%rbp), %xmm0
movq -0x58(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x50(%rbp), %xmm0
movq -0x60(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x1326d
movsd -0x20(%rbp), %xmm0
addsd -0x48(%rbp), %xmm0
movq -0x58(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x28(%rbp), %xmm0
addsd -0x50(%rbp), %xmm0
movq -0x60(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x58(%rbp), %rax
movsd (%rax), %xmm0
subsd -0x20(%rbp), %xmm0
movq -0x60(%rbp), %rax
movsd (%rax), %xmm1
subsd -0x28(%rbp), %xmm1
callq 0x10460
movsd %xmm0, -0x70(%rbp)
movq -0x58(%rbp), %rax
movsd (%rax), %xmm0
subsd -0x30(%rbp), %xmm0
movq -0x60(%rbp), %rax
movsd (%rax), %xmm1
subsd -0x38(%rbp), %xmm1
callq 0x10460
movsd %xmm0, -0x78(%rbp)
movsd -0x70(%rbp), %xmm1
movsd -0x80(%rbp), %xmm0
ucomisd %xmm1, %xmm0
ja 0x132d9
movsd -0x78(%rbp), %xmm1
movsd -0x80(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x133b1
jmp 0x132db
leaq 0x63d6e(%rip), %rdi     # 0x77050
callq 0x10380
movq -0x90(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x73c61(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x73c50(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x73c42(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x63f01(%rip), %rsi     # 0x77234
movl $0x50, %edx
callq 0x10840
movq 0x73c1c(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x73c0e(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x73bf6(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x73be6(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x73bd9(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x73bcb(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x1361a
jmp 0x133b3
jmp 0x133b5
movsd -0x70(%rbp), %xmm0
subsd -0x78(%rbp), %xmm0
movaps 0x63c5a(%rip), %xmm1    # 0x77020
pand %xmm1, %xmm0
ucomisd -0x68(%rbp), %xmm0
jbe 0x13510
jmp 0x133d7
leaq 0x63d0f(%rip), %rdi     # 0x770ed
callq 0x10380
movq -0x90(%rbp), %rdi
movq %rax, %rsi
movsbl -0x81(%rbp), %edx
movsd -0x20(%rbp), %xmm0
movsbl -0x82(%rbp), %ecx
movsd -0x28(%rbp), %xmm1
movsbl -0x81(%rbp), %r8d
movq -0x58(%rbp), %rax
movsd (%rax), %xmm2
movsbl -0x82(%rbp), %r9d
movq -0x60(%rbp), %rax
movsd (%rax), %xmm3
movsbl -0x81(%rbp), %r10d
movsd -0x30(%rbp), %xmm4
movsbl -0x82(%rbp), %eax
movsd -0x38(%rbp), %xmm5
movsd -0x70(%rbp), %xmm6
movsd -0x78(%rbp), %xmm7
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x8, %al
callq 0x10df0
movq 0x73b02(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x73af1(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x73ae3(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x63da2(%rip), %rsi     # 0x77234
movl $0x50, %edx
callq 0x10840
movq 0x73abd(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x73aaf(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x73a97(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x73a87(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x73a7a(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x73a6c(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x1361a
jmp 0x13512
cmpl $0x14, -0x14(%rbp)
jne 0x13527
movq 0x10(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
jmp 0x13613
cmpl $0x1e, -0x14(%rbp)
jne 0x1353c
movq 0x10(%rbp), %rax
movl $0x1, (%rax)
jmp 0x13611
jmp 0x1353e
leaq 0x63c5b(%rip), %rdi     # 0x771a0
callq 0x10380
movq -0x90(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x739fe(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x739ed(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x739df(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x63c9e(%rip), %rsi     # 0x77234
movl $0x50, %edx
callq 0x10840
movq 0x739b9(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x739ab(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x73993(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x73983(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x73976(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x73968(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x1361a
jmp 0x13613
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nop
nopl (%rax,%rax)