// File: /workspace/github_cpp_makefile_star2_O1/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 $0x58, %rsp
movq %r9, %r15
movq %r8, %r12
movq %rsi, %r14
movq %rdi, 0x20(%rsp)
leaq 0x1(,%rsi,2), %rbp
movl %edx, 0x8(%rsp)
testb $0x2, %dl
movq %rcx, 0x10(%rsp)
movq %r8, %rdi
movq %r9, %rsi
movq %r8, %rdx
movq %rbp, %rcx
jne 0x28671
callq 0x1c1c0
jmp 0x28676
callq 0x1bfa0
leaq (%r14,%r14), %rbx
movq %r12, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movl $0x2, %ecx
callq 0x30480
movq %r15, %rdi
movq %r15, %rsi
movq 0x20(%rsp), %r13
movq %r13, %rdx
movq %rbx, 0x18(%rsp)
movq %rbx, %rcx
callq 0x1c1c0
movq %r14, 0x50(%rsp)
shlq $0x4, %r14
subq %rax, (%r15,%r14)
movq %r15, %rdi
movq %r15, %rsi
movq %rbp, %rdx
movl $0x1, %ecx
callq 0x30480
movq %r15, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rbp, %rcx
callq 0x2fa30
addq %r13, %r14
testb $0x1, 0x8(%rsp)
movq %r15, 0x30(%rsp)
jne 0x28700
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %rbp, %rcx
callq 0x2fa30
jmp 0x28716
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %rbp, %rcx
callq 0x2f8f0
movq %r12, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %rbp, %rcx
callq 0x1c1c0
movabsq $0x5555555555555555, %r13 # imm = 0x5555555555555555
movq %r12, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r13, %rcx
xorl %r8d, %r8d
callq 0x2f410
movq %r12, 0x38(%rsp)
movq 0x20(%rsp), %r12
movq 0x18(%rsp), %r14
leaq (%r12,%r14,8), %r15
movq %r15, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %rbp, %rcx
callq 0x1c1c0
movq %r15, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x1c1c0
subq %rax, (%r15,%r14,8)
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %rbp, %rcx
callq 0x1c1c0
movq %rbx, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq %r13, %rcx
xorl %r8d, %r8d
callq 0x2f410
movq 0x50(%rsp), %rbx
leaq (%r12,%rbx,8), %r14
movq %r14, %rdi
movq %r14, %rsi
movq 0x10(%rsp), %r13
movq %r13, %rdx
movq %rbp, %rcx
callq 0x1bfa0
leaq (%rbx,%rbx,2), %rcx
leaq (%r12,%rcx,8), %rdx
movq %rdx, 0x8(%rsp)
leaq (%r12,%rcx,8), %rcx
addq $0x8, %rcx
addq %rax, (%rcx)
jae 0x287ec
addq $0x1, 0x8(%rcx)
leaq 0x8(%rcx), %rcx
jb 0x287e1
leaq (%rbx,%rbx,4), %rax
leaq (%r12,%rax,8), %rsi
movq %r13, %rdi
movq %r13, %rbp
movq %rsi, 0x28(%rsp)
movq 0x90(%rsp), %rdx
movl $0x2, %ecx
callq 0x1c4a0
movq %rax, %r12
movq 0x38(%rsp), %r13
movq %r13, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq 0x90(%rsp), %rcx
callq 0x1c1c0
addq %r12, %rax
movq 0x90(%rsp), %r12
leaq (,%r12,8), %rcx
addq %r13, %rcx
subq %rax, (%rcx)
jae 0x28855
subq $0x1, 0x8(%rcx)
leaq 0x8(%rcx), %rcx
jb 0x2884a
movq %r14, %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x1c1c0
movq %r15, %rcx
subq %rax, (%rcx)
jae 0x28879
subq $0x1, 0x8(%rcx)
leaq 0x8(%rcx), %rcx
jb 0x2886e
movq %r15, 0x10(%rsp)
movq 0x18(%rsp), %r14
movq (%r15,%r14,8), %rax
movq %rax, 0x40(%rsp)
movq 0x30(%rsp), %r15
movq 0x8(%rsp), %rdi
movq %rdi, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x1bfa0
movq %rax, 0x48(%rsp)
movq (%r13,%r14,8), %r14
movq %rbx, %rbp
shlq $0x5, %rbp
addq 0x20(%rsp), %rbp
leaq (,%rbx,8), %rdx
addq %r13, %rdx
movq %rbp, %rdi
movq %r15, %rsi
movq %rbx, %rcx
callq 0x1bfa0
addq %r14, %rax
movq %r12, %r13
leaq (%r15,%rbx,8), %rdx
movq %rdx, %rcx
addq %rax, (%rcx)
jae 0x288f0
addq $0x1, 0x8(%rcx)
leaq 0x8(%rcx), %rcx
jb 0x288e5
cmpq %rbx, %r12
jle 0x289ce
movq 0x18(%rsp), %rax
movq (%r15,%rax,8), %r12
movq 0x28(%rsp), %r14
movq %r14, %rdi
movq %r14, %rsi
movq %rbx, %rcx
callq 0x1bfa0
movq %rax, %r15
addq %r12, %r15
movq 0x48(%rsp), %r12
addq 0x40(%rsp), %r12
leaq (%rbx,%r13), %rcx
movq 0x10(%rsp), %rdi
movq %rdi, %rsi
movq %rbp, %rdx
callq 0x1c1c0
movq -0x8(%r14,%r13,8), %rcx
movq $0x1, -0x8(%r14,%r13,8)
cmpq %rbx, %r13
jle 0x289e9
movq %r12, %rdx
subq %r15, %rdx
jbe 0x2896b
addq %rdx, (%rbp)
jae 0x28969
addq $0x1, 0x8(%rbp)
leaq 0x8(%rbp), %rbp
jb 0x2895e
jmp 0x28982
movq %r15, %rdx
subq %r12, %rdx
subq %rdx, (%rbp)
jae 0x28982
subq $0x1, 0x8(%rbp)
leaq 0x8(%rbp), %rbp
jb 0x28977
movq 0x8(%rsp), %rdx
leaq (%rdx,%r13,8), %rdx
subq %rax, (%rdx)
jae 0x2899b
subq $0x1, 0x8(%rdx)
leaq 0x8(%rdx), %rdx
jb 0x28990
leaq (%r14,%rbx,8), %rax
addq %r15, (%rax)
jae 0x289af
addq $0x1, 0x8(%rax)
leaq 0x8(%rax), %rax
jb 0x289a4
movq -0x8(%r14,%r13,8), %rax
addq %rcx, %rax
decq %rax
movq %rax, -0x8(%r14,%r13,8)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x28(%rsp), %r14
movq %r14, %rdi
movq %r14, %rsi
movq %r13, %rcx
callq 0x1bfa0
movq %rax, %r15
jmp 0x2891b
addq %r12, (%rbp)
jae 0x289fa
addq $0x1, 0x8(%rbp)
leaq 0x8(%rbp), %rbp
jb 0x289ef
addq %r15, %rax
movq 0x8(%rsp), %rdx
leaq (%rdx,%r13,8), %rdx
subq %rax, (%rdx)
jae 0x28a16
subq $0x1, 0x8(%rdx)
leaq 0x8(%rdx), %rdx
jb 0x28a0b
jmp 0x289af