// File: /workspace/github_cpp_makefile_star2_O3/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, %r15
movq %r8, %r13
movq %rcx, (%rsp)
movl %edx, %r12d
movq %rdi, 0x10(%rsp)
leaq (%rsi,%rsi), %r14
leaq 0x1(,%rsi,2), %rbp
testb $0x2, %r12b
movq %rsi, 0x40(%rsp)
movq %r8, %rdi
movq %r9, %rsi
movq %r8, %rdx
movq %rbp, %rcx
jne 0x28322
callq 0x1bca0
jmp 0x28327
callq 0x1ba80
movq %r13, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movl $0x2, %ecx
callq 0x300c0
movq %r15, %rdi
movq %r15, %rsi
movq 0x10(%rsp), %rbx
movq %rbx, %rdx
movq %r14, %rcx
callq 0x1bca0
subq %rax, (%r15,%r14,8)
movq %r15, %rdi
movq %r15, %rsi
movq %rbp, %rdx
movl $0x1, %ecx
callq 0x300c0
movq %r15, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbp, %rcx
callq 0x2f670
movq %r14, 0x8(%rsp)
leaq (%rbx,%r14,8), %rbx
testb $0x1, %r12b
movq %r15, 0x20(%rsp)
jne 0x283a3
movq (%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x2f670
jmp 0x283b8
movq (%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x2f530
movq %r13, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x1bca0
movabsq $0x5555555555555555, %rcx # imm = 0x5555555555555555
movq %r13, %rdi
movq %r13, %rsi
movq %rbp, %rdx
xorl %r8d, %r8d
callq 0x2f070
movq %rbx, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x1bca0
movq %rbx, %rdi
movq %rbx, %rsi
movq %rbx, %r12
movq 0x10(%rsp), %r15
movq %r15, %rdx
movq 0x8(%rsp), %rbx
movq %rbx, %rcx
callq 0x1bca0
movq %r12, 0x28(%rsp)
subq %rax, (%r12,%rbx,8)
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movq %rbp, %rcx
callq 0x1bca0
movq %rbx, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movabsq $0x5555555555555555, %rcx # imm = 0x5555555555555555
xorl %r8d, %r8d
callq 0x2f070
movq 0x40(%rsp), %r12
leaq (%r15,%r12,8), %rbx
movq %rbx, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x1ba80
leaq (%r12,%r12,2), %rcx
leaq (%r15,%rcx,8), %rdx
movq %rdx, (%rsp)
leaq (%r15,%rcx,8), %rcx
addq $0x8, %rcx
addq %rax, (%rcx)
jae 0x2848b
addq $0x1, 0x8(%rcx)
leaq 0x8(%rcx), %rcx
jb 0x28480
leaq (%r12,%r12,4), %rax
leaq (%r15,%rax,8), %rsi
movq %r14, %rdi
movq %rsi, 0x18(%rsp)
movq 0x80(%rsp), %r15
movq %r15, %rdx
movl $0x2, %ecx
callq 0x1bf80
movq %rax, %rbp
movq %r13, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x1bca0
addq %rbp, %rax
leaq (,%r15,8), %rcx
addq %r13, %rcx
subq %rax, (%rcx)
jae 0x284e2
subq $0x1, 0x8(%rcx)
leaq 0x8(%rcx), %rcx
jb 0x284d7
movq %rbx, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0x1bca0
movq 0x28(%rsp), %rdx
movq %rdx, %rcx
subq %rax, (%rcx)
jae 0x2850b
subq $0x1, 0x8(%rcx)
leaq 0x8(%rcx), %rcx
jb 0x28500
movq 0x8(%rsp), %rbx
movq (%rdx,%rbx,8), %rax
movq %rax, 0x30(%rsp)
movq (%rsp), %rdi
movq %rdi, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0x1ba80
movq %rax, 0x38(%rsp)
movq (%r13,%rbx,8), %r14
movq %r12, %rbp
shlq $0x5, %rbp
addq 0x10(%rsp), %rbp
movq 0x20(%rsp), %r15
movq %r12, %rbx
leaq (,%r12,8), %rdx
addq %r13, %rdx
movq %rbp, %rdi
movq %r15, %rsi
movq %r12, %rcx
callq 0x1ba80
addq %r14, %rax
movq 0x80(%rsp), %r12
leaq (%r15,%rbx,8), %rdx
movq %rdx, %rcx
addq %rax, (%rcx)
jae 0x28584
addq $0x1, 0x8(%rcx)
leaq 0x8(%rcx), %rcx
jb 0x28579
cmpq %rbx, %r12
jle 0x28661
movq 0x8(%rsp), %rax
movq (%r15,%rax,8), %r13
movq 0x18(%rsp), %r14
movq %r14, %rdi
movq %r14, %rsi
movq %rbx, %rcx
callq 0x1ba80
movq %rax, %r15
addq %r13, %r15
movq 0x38(%rsp), %r13
addq 0x30(%rsp), %r13
leaq (%r12,%rbx), %rcx
movq 0x28(%rsp), %rdi
movq %rdi, %rsi
movq %rbp, %rdx
callq 0x1bca0
movq -0x8(%r14,%r12,8), %rcx
movq $0x1, -0x8(%r14,%r12,8)
cmpq %rbx, %r12
jle 0x2867c
movq %r13, %rdx
subq %r15, %rdx
jbe 0x285ff
addq %rdx, (%rbp)
jae 0x285fd
addq $0x1, 0x8(%rbp)
leaq 0x8(%rbp), %rbp
jb 0x285f2
jmp 0x28616
movq %r15, %rdx
subq %r13, %rdx
subq %rdx, (%rbp)
jae 0x28616
subq $0x1, 0x8(%rbp)
leaq 0x8(%rbp), %rbp
jb 0x2860b
movq (%rsp), %rdx
leaq (%rdx,%r12,8), %rdx
subq %rax, (%rdx)
jae 0x2862e
subq $0x1, 0x8(%rdx)
leaq 0x8(%rdx), %rdx
jb 0x28623
leaq (%r14,%rbx,8), %rax
addq %r15, (%rax)
jae 0x28642
addq $0x1, 0x8(%rax)
leaq 0x8(%rax), %rax
jb 0x28637
movq -0x8(%r14,%r12,8), %rax
addq %rcx, %rax
decq %rax
movq %rax, -0x8(%r14,%r12,8)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rsp), %r14
movq %r14, %rdi
movq %r14, %rsi
movq %r12, %rcx
callq 0x1ba80
movq %rax, %r15
jmp 0x285af
addq %r13, (%rbp)
jae 0x2868d
addq $0x1, 0x8(%rbp)
leaq 0x8(%rbp), %rbp
jb 0x28682
addq %r15, %rax
movq (%rsp), %rdx
leaq (%rdx,%r12,8), %rdx
subq %rax, (%rdx)
jae 0x286a8
subq $0x1, 0x8(%rdx)
leaq 0x8(%rdx), %rdx
jb 0x2869d
jmp 0x28642
nop