// File: /workspace/github_cpp_makefile_star2_O3/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 $0xc8, %rsp
movq %rdi, %r15
cmpl $0x0, 0x624(%rcx)
je 0xcfdc
leaq 0x27da2(%rip), %rdi     # 0x34d1f
callq 0xa1f0
movq %r15, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0xa850
movq 0x33fca(%rip), %rbx     # 0x40f60
leaq 0xc6d0(%rbx), %rdi
leaq 0x271ed(%rip), %rsi     # 0x34191
movl $0x50, %edx
callq 0xa8a0
movw $0x0, 0xc71f(%rbx)
movl $0x1, 0xd670(%rbx)
movl $0x5, %r12d
movl %r12d, %eax
addq $0xc8, %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 0xd011
testl %eax, %eax
jne 0xd032
movsd 0x678(%rbx), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xd032
jp 0xd032
leaq 0x27d49(%rip), %rdi     # 0x34d55
jmp 0xcf7d
movsd 0x148(%r14), %xmm0
ucomisd 0x2684e(%rip), %xmm0    # 0x33870
jne 0xd032
jp 0xd032
leaq 0x27d4c(%rip), %rdi     # 0x34d79
jmp 0xcf7d
cmpl $0x1, 0xc67c(%rbx)
jne 0xd068
cmpb $0x0, 0x290(%r14)
jne 0xd059
cmpb $0x0, (%r14)
jne 0xd059
cmpb $0x0, 0x10(%r14)
jne 0xd059
cmpb $0x1, 0x20(%r14)
jne 0xd074
leaq 0x27d63(%rip), %rsi     # 0x34dc3
movq %r15, %rdi
jmp 0xcf88
leaq 0x27d34(%rip), %rdi     # 0x34da3
jmp 0xcf7d
movb 0x198(%r14), %al
cmpl $0x33, %esi
jne 0xd185
testb %al, %al
je 0xd1b3
cmpb $0x0, 0x1a8(%r14)
je 0xd1b3
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 -0x88(%rbp), %rax
leaq -0x90(%rbp), %r10
leaq -0x98(%rbp), %r11
leaq -0xa0(%rbp), %r12
leaq -0xa8(%rbp), %r13
leaq -0x70(%rbp), %rcx
leaq -0x68(%rbp), %r8
leaq -0xb8(%rbp), %r9
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
pushq %rax
pushq %r10
pushq %r11
pushq %r12
pushq %r13
leaq -0xb0(%rbp), %rax
pushq %rax
callq 0xaa70
addq $0x30, %rsp
testl %eax, %eax
jne 0xd255
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 0x531fe(%rip), %rsi     # 0x60350
cmpq 0x531ff(%rip), %rsi     # 0x60358
je 0xd370
movq -0x30(%rbp), %rax
movq %rax, 0x10(%rsi)
movups -0x40(%rbp), %xmm0
movups %xmm0, (%rsi)
movq 0x531db(%rip), %rsi     # 0x60350
addq $0x18, %rsi
movq %rsi, 0x531d0(%rip)     # 0x60350
jmp 0xd387
movb 0x1a8(%r14), %cl
testb %al, %al
je 0xd1bf
testb %cl, %cl
je 0xd1c3
movsd 0x600(%rbx), %xmm0
addsd 0x1a0(%r14), %xmm0
movsd %xmm0, -0x50(%rbp)
leaq 0x1b0(%r14), %rax
jmp 0xd1eb
leaq 0x27c36(%rip), %rsi     # 0x34df0
jmp 0xd060
testb %cl, %cl
je 0xd1cf
leaq 0x27c4a(%rip), %rsi     # 0x34e14
jmp 0xd060
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 -0x88(%rbp), %rax
leaq -0x90(%rbp), %r10
leaq -0x98(%rbp), %r11
leaq -0xa0(%rbp), %r12
leaq -0xa8(%rbp), %r13
leaq -0x60(%rbp), %rcx
leaq -0x58(%rbp), %r8
leaq -0xb8(%rbp), %r9
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
pushq %rax
pushq %r10
pushq %r11
pushq %r12
pushq %r13
leaq -0xb0(%rbp), %rax
pushq %rax
callq 0xaa70
addq $0x30, %rsp
testl %eax, %eax
je 0xd2c0
movl %eax, %r12d
movq 0x33d01(%rip), %rbx     # 0x40f60
movslq 0xd670(%rbx), %rax
cmpq $0x30, %rax
jg 0xcfc7
leaq (%rax,%rax,4), %rax
shlq $0x4, %rax
leaq (%rbx,%rax), %rdi
addq $0xc6d0, %rdi           # imm = 0xC6D0
leaq 0x26f07(%rip), %rsi     # 0x34191
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 0xcfc7
cmpb $0x0, 0x218(%r14)
je 0xd364
cmpb $0x0, 0x228(%r14)
je 0xd364
movsd -0x60(%rbp), %xmm0
addsd 0x210(%r14), %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x58(%rbp), %xmm0
addsd 0x220(%r14), %xmm0
movsd %xmm0, -0x78(%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 0x5301f(%rip), %rsi     # 0x60350
cmpq 0x53020(%rip), %rsi     # 0x60358
je 0xd4a1
movq -0x30(%rbp), %rax
movq %rax, 0x10(%rsi)
movups -0x40(%rbp), %xmm0
movups %xmm0, (%rsi)
movq 0x52ffc(%rip), %rsi     # 0x60350
addq $0x18, %rsi
movq %rsi, 0x52ff1(%rip)     # 0x60350
jmp 0xd4b8
leaq 0x27acf(%rip), %rsi     # 0x34e3a
jmp 0xd060
leaq 0x52fd1(%rip), %rdi     # 0x60348
leaq -0x40(%rbp), %rdx
callq 0xb410
movq 0x52fc9(%rip), %rsi     # 0x60350
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
cmpq 0x52fb6(%rip), %rsi     # 0x60358
je 0xd3c7
movq -0x30(%rbp), %rax
movq %rax, 0x10(%rsi)
movups -0x40(%rbp), %xmm0
movups %xmm0, (%rsi)
movq 0x52f96(%rip), %rsi     # 0x60350
addq $0x18, %rsi
movq %rsi, 0x52f8b(%rip)     # 0x60350
jmp 0xd3de
leaq 0x52f7a(%rip), %rdi     # 0x60348
leaq -0x40(%rbp), %rdx
callq 0xb410
movq 0x52f72(%rip), %rsi     # 0x60350
movsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
cmpq 0x52f5f(%rip), %rsi     # 0x60358
je 0xd414
movq -0x30(%rbp), %rax
movq %rax, 0x10(%rsi)
movups -0x40(%rbp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x52f3e(%rip)    # 0x60350
jmp 0xd424
leaq 0x52f2d(%rip), %rdi     # 0x60348
leaq -0x40(%rbp), %rdx
callq 0xb410
leaq -0xd8(%rbp), %r13
movl 0x1d0(%r14), %r14d
leaq 0x52f0f(%rip), %rsi     # 0x60348
leaq -0xe8(%rbp), %r15
movq %r15, %rdi
callq 0xa5e0
movl %r14d, %edi
movq %r15, %rsi
movl $0x3, %edx
callq 0xa430
movq -0xe8(%rbp), %rdi
testq %rdi, %rdi
je 0xd473
movq -0xd8(%rbp), %rsi
subq %rdi, %rsi
callq 0xaae0
movq 0x52ece(%rip), %rax     # 0x60348
cmpq %rax, 0x52ecf(%rip)     # 0x60350
je 0xd48a
movq %rax, 0x52ec6(%rip)     # 0x60350
movsd -0x70(%rbp), %xmm0
movsd %xmm0, 0x600(%rbx)
movsd -0x68(%rbp), %xmm0
jmp 0xd656
leaq 0x52ea0(%rip), %rdi     # 0x60348
leaq -0x40(%rbp), %rdx
callq 0xb410
movq 0x52e98(%rip), %rsi     # 0x60350
movsd -0x48(%rbp), %xmm1
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd %xmm1, -0x38(%rbp)
cmpq 0x52e85(%rip), %rsi     # 0x60358
je 0xd4f8
movq -0x30(%rbp), %rax
movq %rax, 0x10(%rsi)
movups -0x40(%rbp), %xmm0
movups %xmm0, (%rsi)
movq 0x52e65(%rip), %rsi     # 0x60350
addq $0x18, %rsi
movq %rsi, 0x52e5a(%rip)     # 0x60350
jmp 0xd50f
leaq 0x52e49(%rip), %rdi     # 0x60348
leaq -0x40(%rbp), %rdx
callq 0xb410
movq 0x52e41(%rip), %rsi     # 0x60350
movsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
cmpq 0x52e2e(%rip), %rsi     # 0x60358
je 0xd54f
movq -0x30(%rbp), %rax
movq %rax, 0x10(%rsi)
movups -0x40(%rbp), %xmm0
movups %xmm0, (%rsi)
movq 0x52e0e(%rip), %rsi     # 0x60350
addq $0x18, %rsi
movq %rsi, 0x52e03(%rip)     # 0x60350
jmp 0xd566
leaq 0x52df2(%rip), %rdi     # 0x60348
leaq -0x40(%rbp), %rdx
callq 0xb410
movq 0x52dea(%rip), %rsi     # 0x60350
movsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
cmpq 0x52dd7(%rip), %rsi     # 0x60358
je 0xd59c
movq -0x30(%rbp), %rax
movq %rax, 0x10(%rsi)
movups -0x40(%rbp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x52db6(%rip)    # 0x60350
jmp 0xd5ac
leaq 0x52da5(%rip), %rdi     # 0x60348
leaq -0x40(%rbp), %rdx
callq 0xb410
leaq -0xc0(%rbp), %r13
movl 0x1d0(%r14), %r15d
leaq 0x52d87(%rip), %rsi     # 0x60348
leaq -0xd0(%rbp), %r12
movq %r12, %rdi
callq 0xa5e0
movl %r15d, %edi
movq %r12, %rsi
movl $0x4, %edx
callq 0xa430
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0xd5fb
movq -0xc0(%rbp), %rsi
subq %rdi, %rsi
callq 0xaae0
movq 0x52d46(%rip), %rax     # 0x60348
cmpq %rax, 0x52d47(%rip)     # 0x60350
je 0xd612
movq %rax, 0x52d3e(%rip)     # 0x60350
movsd 0x210(%r14), %xmm0
movapd 0x268ed(%rip), %xmm1    # 0x33f10
xorpd %xmm1, %xmm0
movlpd %xmm0, 0x630(%rbx)
movsd 0x220(%r14), %xmm0
xorpd %xmm1, %xmm0
movlpd %xmm0, 0x638(%rbx)
movsd -0x60(%rbp), %xmm0
movsd %xmm0, 0x600(%rbx)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, 0x608(%rbx)
xorl %r12d, %r12d
jmp 0xcfc7
movq %rax, %rbx
movq -0xd0(%rbp), %rdi
jmp 0xd67c
movq %rax, %rbx
movq -0xe8(%rbp), %rdi
testq %rdi, %rdi
je 0xd68d
movq (%r13), %rsi
subq %rdi, %rsi
callq 0xaae0
movq %rbx, %rdi
callq 0xb3b0
nop