// File: /workspace/github_cpp_makefile_star2_O2/marxn[P]pupp/3rdparty/gmp/mpn/toom_interpolate_6pts.c
// Function: _gmpn_toom_interpolate_6pts
void
mpn_toom_interpolate_6pts (mp_ptr pp, mp_size_t n, enum toom6_flags flags,
			   mp_ptr w4, mp_ptr w2, mp_ptr w1,
			   mp_size_t w0n)
{
  mp_limb_t cy;
  /* cy6 can be stored in w1[2*n], cy4 in w4[0], embankment in w2[0] */
  mp_limb_t cy4, cy6, embankment;

  ASSERT( n > 0 );
  ASSERT( 2*n >= w0n && w0n > 0 );

#define w5  pp					/* 2n   */
#define w3  (pp + 2 * n)			/* 2n+1 */
#define w0  (pp + 5 * n)			/* w0n  */

  /* Interpolate with sequence:
     W2 =(W1 - W2)>>2
     W1 =(W1 - W5)>>1
     W1 =(W1 - W2)>>1
     W4 =(W3 - W4)>>1
     W2 =(W2 - W4)/3
     W3 = W3 - W4 - W5
     W1 =(W1 - W3)/3
     // Last steps are mixed with recomposition...
     W2 = W2 - W0<<2
     W4 = W4 - W2
     W3 = W3 - W1
     W2 = W2 - W0
  */

  /* W2 =(W1 - W2)>>2 */
  if (flags & toom6_vm2_neg)
    mpn_add_n (w2, w1, w2, 2 * n + 1);
  else
    mpn_sub_n (w2, w1, w2, 2 * n + 1);
  mpn_rshift (w2, w2, 2 * n + 1, 2);

  /* W1 =(W1 - W5)>>1 */
  w1[2*n] -= mpn_sub_n (w1, w1, w5, 2*n);
  mpn_rshift (w1, w1, 2 * n + 1, 1);

  /* W1 =(W1 - W2)>>1 */
#if HAVE_NATIVE_mpn_rsh1sub_n
  mpn_rsh1sub_n (w1, w1, w2, 2 * n + 1);
#else
  mpn_sub_n (w1, w1, w2, 2 * n + 1);
  mpn_rshift (w1, w1, 2 * n + 1, 1);
#endif

  /* W4 =(W3 - W4)>>1 */
  if (flags & toom6_vm1_neg)
    {
#if HAVE_NATIVE_mpn_rsh1add_n
      mpn_rsh1add_n (w4, w3, w4, 2 * n + 1);
#else
      mpn_add_n (w4, w3, w4, 2 * n + 1);
      mpn_rshift (w4, w4, 2 * n + 1, 1);
#endif
    }
  else
    {
#if HAVE_NATIVE_mpn_rsh1sub_n
      mpn_rsh1sub_n (w4, w3, w4, 2 * n + 1);
#else
      mpn_sub_n (w4, w3, w4, 2 * n + 1);
      mpn_rshift (w4, w4, 2 * n + 1, 1);
#endif
    }

  /* W2 =(W2 - W4)/3 */
  mpn_sub_n (w2, w2, w4, 2 * n + 1);
  mpn_divexact_by3 (w2, w2, 2 * n + 1);

  /* W3 = W3 - W4 - W5 */
  mpn_sub_n (w3, w3, w4, 2 * n + 1);
  w3[2 * n] -= mpn_sub_n (w3, w3, w5, 2 * n);

  /* W1 =(W1 - W3)/3 */
  mpn_sub_n (w1, w1, w3, 2 * n + 1);
  mpn_divexact_by3 (w1, w1, 2 * n + 1);

  /*
    [1 0 0 0 0 0;
     0 1 0 0 0 0;
     1 0 1 0 0 0;
     0 1 0 1 0 0;
     1 0 1 0 1 0;
     0 0 0 0 0 1]

    pp[] prior to operations:
     |_H w0__|_L w0__|______||_H w3__|_L w3__|_H w5__|_L w5__|

    summation scheme for remaining operations:
     |______________5|n_____4|n_____3|n_____2|n______|n______|pp
     |_H w0__|_L w0__|______||_H w3__|_L w3__|_H w5__|_L w5__|
				    || H w4  | L w4  |
		    || H w2  | L w2  |
	    || H w1  | L w1  |
			    ||-H w1  |-L w1  |
		     |-H w0  |-L w0 ||-H w2  |-L w2  |
  */
  cy = mpn_add_n (pp + n, pp + n, w4, 2 * n + 1);
  MPN_INCR_U (pp + 3 * n + 1, n, cy);

  /* W2 -= W0<<2 */
#if HAVE_NATIVE_mpn_sublsh_n || HAVE_NATIVE_mpn_sublsh2_n_ip1
#if HAVE_NATIVE_mpn_sublsh2_n_ip1
  cy = mpn_sublsh2_n_ip1 (w2, w0, w0n);
#else
  cy = mpn_sublsh_n (w2, w2, w0, w0n, 2);
#endif
#else
  /* {W4,2*n+1} is now free and can be overwritten. */
  cy = mpn_lshift(w4, w0, w0n, 2);
  cy+= mpn_sub_n(w2, w2, w4, w0n);
#endif
  MPN_DECR_U (w2 + w0n, 2 * n + 1 - w0n, cy);

  /* W4L = W4L - W2L */
  cy = mpn_sub_n (pp + n, pp + n, w2, n);
  MPN_DECR_U (w3, 2 * n + 1, cy);

  /* W3H = W3H + W2L */
  cy4 = w3[2 * n] + mpn_add_n (pp + 3 * n, pp + 3 * n, w2, n);
  /* W1L + W2H */
  cy = w2[2 * n] + mpn_add_n (pp + 4 * n, w1, w2 + n, n);
  MPN_INCR_U (w1 + n, n + 1, cy);

  /* W0 = W0 + W1H */
  if (LIKELY (w0n > n))
    cy6 = w1[2 * n] + mpn_add_n (w0, w0, w1 + n, n);
  else
    cy6 = mpn_add_n (w0, w0, w1 + n, w0n);

  /*
    summation scheme for the next operation:
     |...____5|n_____4|n_____3|n_____2|n______|n______|pp
     |...w0___|_w1_w2_|_H w3__|_L w3__|_H w5__|_L w5__|
		     ...-w0___|-w1_w2 |
  */
  /* if(LIKELY(w0n>n)) the two operands below DO overlap! */
  cy = mpn_sub_n (pp + 2 * n, pp + 2 * n, pp + 4 * n, n + w0n);

  /* embankment is a "dirty trick" to avoid carry/borrow propagation
     beyond allocated memory */
  embankment = w0[w0n - 1] - 1;
  w0[w0n - 1] = 1;
  if (LIKELY (w0n > n)) {
    if (cy4 > cy6)
      MPN_INCR_U (pp + 4 * n, w0n + n, cy4 - cy6);
    else
      MPN_DECR_U (pp + 4 * n, w0n + n, cy6 - cy4);
    MPN_DECR_U (pp + 3 * n + w0n, 2 * n, cy);
    MPN_INCR_U (w0 + n, w0n - n, cy6);
  } else {
    MPN_INCR_U (pp + 4 * n, w0n + n, cy4);
    MPN_DECR_U (pp + 3 * n + w0n, 2 * n, cy + cy6);
  }
  w0[w0n - 1] += embankment;

#undef w5
#undef w3
#undef w0

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, %rbx
movq %r8, %r13
movq %rdi, %r14
leaq (%rsi,%rsi), %r12
movq %rsi, 0x40(%rsp)
leaq 0x1(,%rsi,2), %rbp
movl %edx, 0x8(%rsp)
testb $0x2, %dl
movq %rcx, (%rsp)
movq %r8, %rdi
movq %r9, %rsi
movq %r8, %rdx
movq %rbp, %rcx
jne 0x230e4
callq 0x17ed0
jmp 0x230e9
callq 0x17cf0
pushq $0x2
popq %rcx
movq %r13, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x2a0a0
movq %rbx, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0x17ed0
subq %rax, (%rbx,%r12,8)
pushq $0x1
popq %rcx
movq %rbx, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x2a0a0
movq %rbx, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %rbp, %rcx
callq 0x29630
leaq (%r14,%r12,8), %r15
testb $0x1, 0x8(%rsp)
movq %rbx, 0x20(%rsp)
jne 0x23158
movq (%rsp), %rdi
movq %r15, %rsi
movq %rdi, %rbx
movq %rdi, %rdx
movq %rbp, %rcx
callq 0x29630
jmp 0x2316d
movq (%rsp), %rdi
movq %r15, %rsi
movq %rdi, %rbx
movq %rdi, %rdx
movq %rbp, %rcx
callq 0x294f0
movq %r13, %rdi
movq %r13, %rsi
movq %rbx, %rdx
movq %rbp, %rcx
callq 0x17ed0
movabsq $0x5555555555555555, %rcx # imm = 0x5555555555555555
movq %r13, %rdi
movq %r13, %rsi
movq %rbp, %rdx
xorl %r8d, %r8d
callq 0x29020
movq %r15, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %rbp, %rcx
callq 0x17ed0
movq %r15, %rdi
movq %r15, %rsi
movq %r14, %rbx
movq %r14, %rdx
movq %r12, 0x38(%rsp)
movq %r12, %rcx
callq 0x17ed0
subq %rax, (%r15,%r12,8)
movq 0x20(%rsp), %r14
movq %r14, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rbp, %rcx
callq 0x17ed0
movq %r14, %rdi
movq %r14, %rsi
movq %rbp, %rdx
movabsq $0x5555555555555555, %rcx # imm = 0x5555555555555555
xorl %r8d, %r8d
callq 0x29020
movq 0x40(%rsp), %r12
leaq (%rbx,%r12,8), %r14
movq %r14, %rdi
movq %r14, %rsi
movq (%rsp), %rdx
movq %rbp, %rcx
callq 0x17cf0
imulq $0x18, %r12, %rcx
movq %rbx, 0x28(%rsp)
leaq (%rbx,%rcx), %rdx
movq %rdx, 0x8(%rsp)
addq %rbx, %rcx
addq $0x8, %rcx
addq %rax, (%rcx)
jae 0x2323c
addq $0x1, 0x8(%rcx)
leaq 0x8(%rcx), %rcx
jb 0x23231
imulq $0x28, %r12, %rsi
addq %rbx, %rsi
pushq $0x2
popq %rcx
movq (%rsp), %rbp
movq %rbp, %rdi
movq %rsi, 0x18(%rsp)
movq 0x80(%rsp), %rbx
movq %rbx, %rdx
callq 0x181a0
movq %rax, 0x10(%rsp)
movq %r13, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x17ed0
addq 0x10(%rsp), %rax
leaq (,%rbx,8), %rcx
addq %r13, %rcx
subq %rax, (%rcx)
jae 0x23298
subq $0x1, 0x8(%rcx)
leaq 0x8(%rcx), %rcx
jb 0x2328d
movq %r14, %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0x17ed0
movq %r15, %rcx
subq %rax, (%rcx)
jae 0x232bc
subq $0x1, 0x8(%rcx)
leaq 0x8(%rcx), %rcx
jb 0x232b1
movq %r15, (%rsp)
movq 0x38(%rsp), %rax
movq (%r15,%rax,8), %rcx
movq %rcx, 0x30(%rsp)
movq %rax, %r15
movq 0x8(%rsp), %rdi
movq %rdi, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0x17cf0
movq %rax, 0x10(%rsp)
movq (%r13,%r15,8), %rbp
movq %r12, %r14
shlq $0x5, %r14
addq 0x28(%rsp), %r14
leaq (,%r12,8), %rdx
addq %r13, %rdx
movq %r12, %r13
movq %rbx, %r12
movq 0x20(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rcx
callq 0x17cf0
addq %rbp, %rax
leaq (%rbx,%r13,8), %rdx
movq %rdx, %rcx
addq %rax, (%rcx)
jae 0x23338
addq $0x1, 0x8(%rcx)
leaq 0x8(%rcx), %rcx
jb 0x2332d
cmpq %r13, %r12
jle 0x23415
movq (%rbx,%r15,8), %rbx
movq 0x18(%rsp), %rbp
movq %rbp, %rdi
movq %rbp, %rsi
movq %r13, %rcx
callq 0x17cf0
movq %rax, %r15
addq %rbx, %r15
movq 0x10(%rsp), %rbx
addq 0x30(%rsp), %rbx
leaq (%r12,%r13), %rcx
movq (%rsp), %rdi
movq %rdi, %rsi
movq %r14, %rdx
callq 0x17ed0
movq -0x8(%rbp,%r12,8), %rcx
movq $0x1, -0x8(%rbp,%r12,8)
cmpq %r13, %r12
jle 0x23430
movq %rbx, %rdx
subq %r15, %rdx
jbe 0x233ac
addq %rdx, (%r14)
jae 0x233aa
addq $0x1, 0x8(%r14)
leaq 0x8(%r14), %r14
jb 0x2339f
jmp 0x233c2
movq %r15, %rdx
subq %rbx, %rdx
subq %rdx, (%r14)
jae 0x233c2
subq $0x1, 0x8(%r14)
leaq 0x8(%r14), %r14
jb 0x233b7
movq 0x8(%rsp), %rdx
leaq (%rdx,%r12,8), %rdx
subq %rax, (%rdx)
jae 0x233db
subq $0x1, 0x8(%rdx)
leaq 0x8(%rdx), %rdx
jb 0x233d0
leaq (,%r13,8), %rax
addq %rbp, %rax
addq %r15, (%rax)
jae 0x233f6
addq $0x1, 0x8(%rax)
leaq 0x8(%rax), %rax
jb 0x233eb
movq -0x8(%rbp,%r12,8), %rax
addq %rcx, %rax
decq %rax
movq %rax, -0x8(%rbp,%r12,8)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rsp), %rbp
movq %rbp, %rdi
movq %rbp, %rsi
movq %r12, %rcx
callq 0x17cf0
movq %rax, %r15
jmp 0x2335e
addq %rbx, (%r14)
jae 0x23440
addq $0x1, 0x8(%r14)
leaq 0x8(%r14), %r14
jb 0x23435
addq %r15, %rax
movq 0x8(%rsp), %rdx
leaq (%rdx,%r12,8), %rdx
subq %rax, (%rdx)
jae 0x2345c
subq $0x1, 0x8(%rdx)
leaq 0x8(%rdx), %rdx
jb 0x23451
jmp 0x233f6
nop