// File: sundale[P]gcode/rs274ngc/interp_convert.cc
// Function: Interp::convert_arc2(int, block_struct*, setup_struct*, double*, double*, double*, double, double, double, double, double, double, double, double, double, double, double)
int Interp::convert_arc2(int move,       //!< either G_2 (cw arc) or G_3 (ccw arc)    
                        block_pointer block,    //!< pointer to a block of RS274 instructions
                        setup_pointer settings, //!< pointer to machine settings             
                        double *current1,       //!< pointer to current value of coordinate 1
                        double *current2,       //!< pointer to current value of coordinate 2
                        double *current3,       //!< pointer to current value of coordinate 3
                        double end1,    //!< coordinate 1 value at end of arc        
                        double end2,    //!< coordinate 2 value at end of arc        
                        double end3,    //!< coordinate 3 value at end of arc        
                        double AA_end,  //!< a-value at end of arc                   
                        double BB_end,  //!< b-value at end of arc                   
                        double CC_end,  //!< c-value at end of arc                   
                         double u, double v, double w, //!< values at end of arc
                        double offset1, //!< center, either abs or offset from current
                        double offset2)
{
  double center1;
  double center2;
  double tolerance;             /* tolerance for difference of radii          */
  int turn;                     /* number of full or partial turns CCW in arc */
  int plane = settings->plane;

  tolerance = (settings->length_units == CANON_UNITS_INCHES) ?
    TOLERANCE_INCH : TOLERANCE_MM;

  if (block->r_flag) {
      CHP(arc_data_r(move, plane, *current1, *current2, end1, end2,
                   block->r_number, &center1, &center2, &turn, tolerance));
  } else {
      CHP(arc_data_ijk(move, plane, *current1, *current2, end1, end2,
                       (settings->ijk_distance_mode == MODE_ABSOLUTE),
                       offset1, offset2,
                       &center1, &center2, &turn, tolerance));
  }
  inverse_time_rate_arc(*current1, *current2, *current3, center1, center2,
                        turn, end1, end2, end3, block, settings);

  ARC_FEED(block->line_number, end1, end2, center1, center2, turn, end3,
           AA_end, BB_end, CC_end, u, v, w);
  *current1 = end1;
  *current2 = end2;
  *current3 = end3;
  settings->AA_current = AA_end;
  settings->BB_current = BB_end;
  settings->CC_current = CC_end;
  settings->u_current = u;
  settings->v_current = v;
  settings->w_current = w;
  
  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movsd 0x28(%rbp), %xmm8
movsd 0x20(%rbp), %xmm8
movsd 0x18(%rbp), %xmm8
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movsd %xmm0, -0x40(%rbp)
movsd %xmm1, -0x48(%rbp)
movsd %xmm2, -0x50(%rbp)
movsd %xmm3, -0x58(%rbp)
movsd %xmm4, -0x60(%rbp)
movsd %xmm5, -0x68(%rbp)
movsd %xmm6, -0x70(%rbp)
movsd %xmm7, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x28(%rbp), %rax
movl 0xc67c(%rax), %eax
movl %eax, -0x98(%rbp)
movq -0x28(%rbp), %rax
movl 0x1690(%rax), %eax
movsd 0x5f0bb(%rip), %xmm0    # 0x78e18
movsd 0x5f0bb(%rip), %xmm1    # 0x78e20
movsd %xmm1, -0xb0(%rbp)
cmpl $0x1, %eax
movsd %xmm0, -0xa8(%rbp)
je 0x19d8a
movsd -0xb0(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd -0xa8(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
movq -0x20(%rbp), %rax
testb $0x1, 0x229(%rax)
je 0x19edc
jmp 0x19dad
movq -0xb8(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x98(%rbp), %edx
movq -0x30(%rbp), %rax
movsd (%rax), %xmm0
movq -0x38(%rbp), %rax
movsd (%rax), %xmm1
movsd -0x40(%rbp), %xmm2
movsd -0x48(%rbp), %xmm3
movq -0x20(%rbp), %rax
movsd 0x230(%rax), %xmm4
movsd -0x90(%rbp), %xmm5
leaq -0x80(%rbp), %rcx
leaq -0x88(%rbp), %r8
leaq -0x94(%rbp), %r9
callq 0x11400
movl %eax, -0x9c(%rbp)
cmpl $0x0, -0x9c(%rbp)
je 0x19ed5
jmp 0x19e17
movq 0x6d142(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x19ec7
movq 0x6d12e(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x6d120(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x5f88e(%rip), %rsi     # 0x796e3
movl $0x50, %edx
callq 0x10840
movq 0x6d0fa(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x6d0ec(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x6d0d4(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x6d0c4(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x6d0b7(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x6d0a9(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0x9c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1a158
jmp 0x19ed7
jmp 0x1a01f
jmp 0x19ede
movq -0xb8(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x98(%rbp), %edx
movq -0x30(%rbp), %rax
movsd (%rax), %xmm0
movq -0x38(%rbp), %rax
movsd (%rax), %xmm1
movsd -0x40(%rbp), %xmm2
movsd -0x48(%rbp), %xmm3
movq -0x28(%rbp), %rax
cmpl $0x0, 0x66c(%rax)
sete %al
andb $0x1, %al
movzbl %al, %ecx
movsd 0x20(%rbp), %xmm4
movsd 0x28(%rbp), %xmm5
movsd -0x90(%rbp), %xmm6
leaq -0x80(%rbp), %r8
leaq -0x88(%rbp), %r9
leaq -0x94(%rbp), %rax
movq %rax, (%rsp)
callq 0x11570
movl %eax, -0xa0(%rbp)
cmpl $0x0, -0xa0(%rbp)
je 0x1a01b
jmp 0x19f5d
movq 0x6cffc(%rip), %rax     # 0x86f60
cmpl $0x31, 0xd670(%rax)
jge 0x1a00d
movq 0x6cfe8(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x6cfda(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x5f748(%rip), %rsi     # 0x796e3
movl $0x50, %edx
callq 0x10840
movq 0x6cfb4(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x6cfa6(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x6cf8e(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x6cf7e(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x6cf71(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x6cf63(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl -0xa0(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1a158
jmp 0x1a01d
jmp 0x1a01f
movq -0xb8(%rbp), %rdi
movq -0x30(%rbp), %rax
movsd (%rax), %xmm0
movq -0x38(%rbp), %rax
movsd (%rax), %xmm1
movq 0x10(%rbp), %rax
movsd (%rax), %xmm2
movsd -0x80(%rbp), %xmm3
movsd -0x88(%rbp), %xmm4
movl -0x94(%rbp), %esi
movsd -0x40(%rbp), %xmm5
movsd -0x48(%rbp), %xmm6
movsd -0x50(%rbp), %xmm7
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x113c0
movq -0x20(%rbp), %rax
movl 0x1d0(%rax), %edi
movsd -0x40(%rbp), %xmm0
movsd -0x48(%rbp), %xmm1
movsd -0x80(%rbp), %xmm2
movsd -0x88(%rbp), %xmm3
movl -0x94(%rbp), %esi
movsd -0x50(%rbp), %xmm4
movsd -0x58(%rbp), %xmm5
movsd -0x60(%rbp), %xmm6
movsd -0x68(%rbp), %xmm7
movsd -0x70(%rbp), %xmm10
movsd -0x78(%rbp), %xmm9
movsd 0x18(%rbp), %xmm8
movsd %xmm10, (%rsp)
movsd %xmm9, 0x8(%rsp)
movsd %xmm8, 0x10(%rsp)
callq 0x12120
movsd -0x40(%rbp), %xmm0
movq -0x30(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x48(%rbp), %xmm0
movq -0x38(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x50(%rbp), %xmm0
movq 0x10(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x58(%rbp), %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movsd -0x60(%rbp), %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x20(%rax)
movsd -0x68(%rbp), %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x38(%rax)
movsd -0x70(%rbp), %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x50(%rax)
movsd -0x78(%rbp), %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x68(%rax)
movsd 0x18(%rbp), %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x80(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)