// File: /workspace/github_cpp_makefile_star2_O1/sundale[P]gcode/rs274ngc/interp_convert.cc
// Function: Interp::convert_spline(int, block_struct*, setup_struct*)
int Interp::convert_spline(int mode,
       block_pointer block,     //!< pointer to a block of RS274 instructions
       setup_pointer settings)  //!< pointer to machine settings
{
    double x1, y1, x2, y2, x3, y3;
    double end_z, AA_end, BB_end, CC_end, u_end, v_end, w_end;
    CONTROL_POINT cp;

    CHKS((settings->cutter_comp_side != OFF), _("Cannot convert spline with cutter radius compensation")); // XXX

    if (settings->feed_mode == UNITS_PER_MINUTE) {
      CHKS((settings->feed_rate == 0.0),
        NCE_CANNOT_MAKE_ARC_WITH_ZERO_FEED_RATE);
    } else if (settings->feed_mode == INVERSE_TIME) {
      CHKS((block->f_number == -1.0),
        NCE_F_WORD_MISSING_WITH_INVERSE_TIME_ARC_MOVE);
    }

    CHKS((settings->plane != CANON_PLANE_XY), _("Splines must be in the XY plane")); // XXX
       //Error (for now): Splines must be in XY plane

    CHKS((block->z_flag == ON || block->a_flag == ON || block->b_flag == ON
          || block->c_flag == ON),
          ("Splines may not have motion in Z, A, B, or C"));

    if(mode == G_5_1) {
      CHKS(block->i_flag != ON || block->j_flag != ON,
                  ("Must specify both I and J with G5.1"));
      x1 = settings->current_x + block->i_number;
      y1 = settings->current_y + block->j_number;
      CHP(find_ends(block, settings, &x2, &y2, &end_z, &AA_end, &BB_end, &CC_end,
                    &u_end, &v_end, &w_end));
      cp.W = 1;
      cp.X = settings->current_x, cp.Y = settings->current_y;
      nurbs_control_points.push_back(cp);
      cp.X = x1, cp.Y = y1;
      nurbs_control_points.push_back(cp);
      cp.X = x2, cp.Y = y2;
      nurbs_control_points.push_back(cp);
      NURBS_FEED(block->line_number, nurbs_control_points, 3);
      nurbs_control_points.clear();
      settings->current_x = x2;
      settings->current_y = y2;
    } else {
      if(block->i_flag != ON || block->j_flag != ON) {
          CHKS(block->i_flag == ON || block->j_flag == ON,
                  ("Must specify both I and J, or neither"));
          x1 = settings->current_x + settings->cycle_i;
          y1 = settings->current_y + settings->cycle_j;
      } else {
          x1 = settings->current_x + block->i_number;
          y1 = settings->current_y + block->j_number;
      }
      CHP(find_ends(block, settings, &x3, &y3, &end_z, &AA_end, &BB_end, &CC_end,
                    &u_end, &v_end, &w_end));

      CHKS(block->p_flag != ON || block->q_flag != ON,
	      ("Must specify both P and Q with G5"));
      x2 = x3 + block->p_number;
      y2 = y3 + block->q_number;

      cp.W = 1;
      cp.X = settings->current_x, cp.Y = settings->current_y;
      nurbs_control_points.push_back(cp);
      cp.X = x1, cp.Y = y1;
      nurbs_control_points.push_back(cp);
      cp.X = x2, cp.Y = y2;
      nurbs_control_points.push_back(cp);
      cp.X = x3, cp.Y = y3;
      nurbs_control_points.push_back(cp);
      NURBS_FEED(block->line_number, nurbs_control_points, 4);
      nurbs_control_points.clear();

      settings->cycle_i = -block->p_number;
      settings->cycle_j = -block->q_number;
      settings->current_x = x3;
      settings->current_y = y3;
    }
    return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %r15
cmpl $0x0, 0x624(%rcx)
je 0xd146
leaq 0x2ac42(%rip), %rdi     # 0x37d1f
callq 0xa1f0
movq %r15, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
movq 0x36e6a(%rip), %rbx     # 0x43f60
movl $0x0, 0xd670(%rbx)
leaq 0xc6d0(%rbx), %rdi
leaq 0x2a083(%rip), %rsi     # 0x37191
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
movl $0x5, %r12d
movl %r12d, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, %rbx
movq %rdx, %r14
movl 0x670(%rcx), %eax
cmpl $0x1, %eax
je 0xd17b
testl %eax, %eax
jne 0xd19c
movsd 0x678(%rbx), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xd19c
jp 0xd19c
leaq 0x2abdf(%rip), %rdi     # 0x37d55
jmp 0xd0dd
movsd 0x148(%r14), %xmm0
ucomisd 0x296e4(%rip), %xmm0    # 0x36870
jne 0xd19c
jp 0xd19c
leaq 0x2abe2(%rip), %rdi     # 0x37d79
jmp 0xd0dd
cmpl $0x1, 0xc67c(%rbx)
jne 0xd1d2
cmpb $0x0, 0x290(%r14)
jne 0xd1c3
cmpb $0x0, (%r14)
jne 0xd1c3
cmpb $0x0, 0x10(%r14)
jne 0xd1c3
cmpb $0x1, 0x20(%r14)
jne 0xd1de
leaq 0x2abf9(%rip), %rsi     # 0x37dc3
movq %r15, %rdi
jmp 0xd0e8
leaq 0x2abca(%rip), %rdi     # 0x37da3
jmp 0xd0dd
movb 0x198(%r14), %al
cmpl $0x33, %esi
jne 0xd2df
testb %al, %al
je 0xd30c
cmpb $0x0, 0x1a8(%r14)
je 0xd30c
movsd 0x600(%rbx), %xmm0
movsd 0x608(%rbx), %xmm1
addsd 0x1a0(%r14), %xmm0
movsd %xmm0, -0x50(%rbp)
addsd 0x1b0(%r14), %xmm1
movsd %xmm1, -0x48(%rbp)
leaq -0x78(%rbp), %rax
leaq -0x80(%rbp), %r10
leaq -0x88(%rbp), %r11
leaq -0x90(%rbp), %r12
leaq -0x98(%rbp), %r13
leaq -0x60(%rbp), %rcx
leaq -0x58(%rbp), %r8
leaq -0xa8(%rbp), %r9
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
pushq %rax
pushq %r10
pushq %r11
pushq %r12
pushq %r13
leaq -0xa0(%rbp), %rax
pushq %rax
callq 0xaa70
addq $0x30, %rsp
testl %eax, %eax
jne 0xd3b2
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, -0x30(%rbp)
movsd 0x600(%rbx), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd 0x608(%rbx), %xmm0
movsd %xmm0, -0x38(%rbp)
movq 0x5609a(%rip), %rsi     # 0x63350
cmpq 0x5609b(%rip), %rsi     # 0x63358
je 0xd4bf
movq -0x30(%rbp), %rax
movq %rax, 0x10(%rsi)
movups -0x40(%rbp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x56076(%rip)    # 0x63350
jmp 0xd4cf
testb %al, %al
je 0xd318
cmpb $0x0, 0x1a8(%r14)
je 0xd318
movsd 0x600(%rbx), %xmm0
addsd 0x1a0(%r14), %xmm0
movsd %xmm0, -0x50(%rbp)
leaq 0x1b0(%r14), %rax
jmp 0xd34e
leaq 0x2aadd(%rip), %rsi     # 0x37df0
jmp 0xd1ca
testb %al, %al
jne 0xd326
cmpb $0x1, 0x1a8(%r14)
jne 0xd332
leaq 0x2aae7(%rip), %rsi     # 0x37e14
jmp 0xd1ca
movsd 0x600(%rbx), %xmm0
addsd 0x630(%rbx), %xmm0
movsd %xmm0, -0x50(%rbp)
leaq 0x638(%rbx), %rax
movsd 0x608(%rbx), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
leaq -0x78(%rbp), %rax
leaq -0x80(%rbp), %r10
leaq -0x88(%rbp), %r11
leaq -0x90(%rbp), %r12
leaq -0x98(%rbp), %r13
leaq -0x70(%rbp), %rcx
leaq -0x68(%rbp), %r8
leaq -0xa8(%rbp), %r9
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
pushq %rax
pushq %r10
pushq %r11
pushq %r12
pushq %r13
leaq -0xa0(%rbp), %rax
pushq %rax
callq 0xaa70
addq $0x30, %rsp
testl %eax, %eax
je 0xd41d
movl %eax, %r12d
movq 0x36ba4(%rip), %rbx     # 0x43f60
movslq 0xd670(%rbx), %rax
cmpq $0x30, %rax
jg 0xd131
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
leaq (%rbx,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0x29daa(%rip), %rsi     # 0x37191
movl $0x50, %edx
callq 0xa8a0
movslq 0xd670(%rbx), %rax
leaq (%rax,%rax,4), %rcx
shlq $0x4, %rcx
xorl %edx, %edx
movb %dl, 0xc71f(%rbx,%rcx)
incl %eax
movl %eax, 0xd670(%rbx)
movb %dl, 0xc720(%rbx,%rcx)
jmp 0xd131
cmpb $0x0, 0x218(%r14)
je 0xd4b3
cmpb $0x0, 0x228(%r14)
je 0xd4b3
movsd -0x70(%rbp), %xmm0
addsd 0x210(%r14), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x68(%rbp), %xmm0
addsd 0x220(%r14), %xmm0
movsd %xmm0, -0x58(%rbp)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, -0x30(%rbp)
movsd 0x600(%rbx), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd 0x608(%rbx), %xmm0
movsd %xmm0, -0x38(%rbp)
movq 0x55ec6(%rip), %rsi     # 0x63350
cmpq 0x55ec7(%rip), %rsi     # 0x63358
je 0xd5e6
movq -0x30(%rbp), %rax
movq %rax, 0x10(%rsi)
movups -0x40(%rbp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x55ea2(%rip)    # 0x63350
jmp 0xd5f6
leaq 0x2a980(%rip), %rsi     # 0x37e3a
jmp 0xd1ca
leaq 0x55e82(%rip), %rdi     # 0x63348
leaq -0x40(%rbp), %rdx
callq 0xb410
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq 0x55e66(%rip), %rsi     # 0x63350
cmpq 0x55e67(%rip), %rsi     # 0x63358
je 0xd50c
movq -0x30(%rbp), %rax
movq %rax, 0x10(%rsi)
movups -0x40(%rbp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x55e46(%rip)    # 0x63350
jmp 0xd51c
leaq 0x55e35(%rip), %rdi     # 0x63348
leaq -0x40(%rbp), %rdx
callq 0xb410
movsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq 0x55e19(%rip), %rsi     # 0x63350
cmpq 0x55e1a(%rip), %rsi     # 0x63358
je 0xd559
movq -0x30(%rbp), %rax
movq %rax, 0x10(%rsi)
movups -0x40(%rbp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x55df9(%rip)    # 0x63350
jmp 0xd569
leaq 0x55de8(%rip), %rdi     # 0x63348
leaq -0x40(%rbp), %rdx
callq 0xb410
leaq -0xc8(%rbp), %r13
movl 0x1d0(%r14), %r14d
leaq 0x55dca(%rip), %rsi     # 0x63348
leaq -0xd8(%rbp), %r15
movq %r15, %rdi
callq 0xa5e0
movl %r14d, %edi
movq %r15, %rsi
movl $0x3, %edx
callq 0xa430
movq -0xd8(%rbp), %rdi
testq %rdi, %rdi
je 0xd5b8
movq -0xc8(%rbp), %rsi
subq %rdi, %rsi
callq 0xaae0
movq 0x55d89(%rip), %rax     # 0x63348
cmpq %rax, 0x55d8a(%rip)     # 0x63350
je 0xd5cf
movq %rax, 0x55d81(%rip)     # 0x63350
movsd -0x60(%rbp), %xmm0
movsd %xmm0, 0x600(%rbx)
movsd -0x58(%rbp), %xmm0
jmp 0xd787
leaq 0x55d5b(%rip), %rdi     # 0x63348
leaq -0x40(%rbp), %rdx
callq 0xb410
movsd -0x48(%rbp), %xmm1
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd %xmm1, -0x38(%rbp)
movq 0x55d3f(%rip), %rsi     # 0x63350
cmpq 0x55d40(%rip), %rsi     # 0x63358
je 0xd633
movq -0x30(%rbp), %rax
movq %rax, 0x10(%rsi)
movups -0x40(%rbp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x55d1f(%rip)    # 0x63350
jmp 0xd643
leaq 0x55d0e(%rip), %rdi     # 0x63348
leaq -0x40(%rbp), %rdx
callq 0xb410
movsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq 0x55cf2(%rip), %rsi     # 0x63350
cmpq 0x55cf3(%rip), %rsi     # 0x63358
je 0xd680
movq -0x30(%rbp), %rax
movq %rax, 0x10(%rsi)
movups -0x40(%rbp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x55cd2(%rip)    # 0x63350
jmp 0xd690
leaq 0x55cc1(%rip), %rdi     # 0x63348
leaq -0x40(%rbp), %rdx
callq 0xb410
movsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq 0x55ca5(%rip), %rsi     # 0x63350
cmpq 0x55ca6(%rip), %rsi     # 0x63358
je 0xd6cd
movq -0x30(%rbp), %rax
movq %rax, 0x10(%rsi)
movups -0x40(%rbp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x55c85(%rip)    # 0x63350
jmp 0xd6dd
leaq 0x55c74(%rip), %rdi     # 0x63348
leaq -0x40(%rbp), %rdx
callq 0xb410
leaq -0xb0(%rbp), %r13
movl 0x1d0(%r14), %r15d
leaq 0x55c56(%rip), %rsi     # 0x63348
leaq -0xc0(%rbp), %r12
movq %r12, %rdi
callq 0xa5e0
movl %r15d, %edi
movq %r12, %rsi
movl $0x4, %edx
callq 0xa430
movq -0xc0(%rbp), %rdi
testq %rdi, %rdi
je 0xd72c
movq -0xb0(%rbp), %rsi
subq %rdi, %rsi
callq 0xaae0
movq 0x55c15(%rip), %rax     # 0x63348
cmpq %rax, 0x55c16(%rip)     # 0x63350
je 0xd743
movq %rax, 0x55c0d(%rip)     # 0x63350
movsd 0x210(%r14), %xmm0
movapd 0x297bc(%rip), %xmm1    # 0x36f10
xorpd %xmm1, %xmm0
movlpd %xmm0, 0x630(%rbx)
movsd 0x220(%r14), %xmm0
xorpd %xmm1, %xmm0
movlpd %xmm0, 0x638(%rbx)
movsd -0x70(%rbp), %xmm0
movsd %xmm0, 0x600(%rbx)
movsd -0x68(%rbp), %xmm0
movsd %xmm0, 0x608(%rbx)
xorl %r12d, %r12d
jmp 0xd131
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
jmp 0xd7ad
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
testq %rdi, %rdi
je 0xd7be
movq (%r13), %rsi
subq %rdi, %rsi
callq 0xaae0
movq %rbx, %rdi
callq 0xb3b0