// File: /workspace/github_cpp_makefile_star2_O2/marxn[P]pupp/3rdparty/gmp/mpn/toom_eval_pm2.c
// Function: _gmpn_toom_eval_pm2
int
mpn_toom_eval_pm2 (mp_ptr xp2, mp_ptr xm2, unsigned k,
		   mp_srcptr xp, mp_size_t n, mp_size_t hn, mp_ptr tp)
{
  int i;
  int neg;
  mp_limb_t cy;

  ASSERT (k >= 3);
  ASSERT (k < GMP_NUMB_BITS);

  ASSERT (hn > 0);
  ASSERT (hn <= n);

  /* The degree k is also the number of full-size coefficients, so
   * that last coefficient, of size hn, starts at xp + k*n. */

  cy = 0;
  DO_addlsh2 (xp2, xp + (k-2) * n, xp + k * n, hn, cy);
  if (hn != n)
    cy = mpn_add_1 (xp2 + hn, xp + (k-2) * n + hn, n - hn, cy);
  for (i = k - 4; i >= 0; i -= 2)
    DO_addlsh2 (xp2, xp + i * n, xp2, n, cy);
  xp2[n] = cy;

  k--;

  cy = 0;
  DO_addlsh2 (tp, xp + (k-2) * n, xp + k * n, n, cy);
  for (i = k - 4; i >= 0; i -= 2)
    DO_addlsh2 (tp, xp + i * n, tp, n, cy);
  tp[n] = cy;

  if (k & 1)
    ASSERT_NOCARRY(mpn_lshift (tp , tp , n + 1, 1));
  else
    ASSERT_NOCARRY(mpn_lshift (xp2, xp2, n + 1, 1));

  neg = (mpn_cmp (xp2, tp, n + 1) < 0) ? ~0 : 0;

#if HAVE_NATIVE_mpn_add_n_sub_n
  if (neg)
    mpn_add_n_sub_n (xp2, xm2, tp, xp2, n + 1);
  else
    mpn_add_n_sub_n (xp2, xm2, xp2, tp, n + 1);
#else /* !HAVE_NATIVE_mpn_add_n_sub_n */
  if (neg)
    mpn_sub_n (xm2, tp, xp2, n + 1);
  else
    mpn_sub_n (xm2, xp2, tp, n + 1);

  mpn_add_n (xp2, xp2, tp, n + 1);
#endif /* !HAVE_NATIVE_mpn_add_n_sub_n */

  ASSERT (xp2[n] < (1<<(k+2))-1);
  ASSERT (xm2[n] < ((1<<(k+3))-1 - (1^k&1))/3);

  neg ^= ((k & 1) - 1);

  return neg;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %r12
movq %r8, %rbx
movq %rcx, %r13
movl %edx, %ebp
movq %rsi, 0x10(%rsp)
movq %rdi, %r14
leal -0x2(%rbp), %eax
imulq %r8, %rax
leaq (%rcx,%rax,8), %rsi
movl %edx, %eax
imulq %r8, %rax
leaq (%rcx,%rax,8), %rdx
movq %rsi, 0x8(%rsp)
movq %r9, %rcx
callq 0x29760
movq %rax, %r15
movq %rbx, %rdx
subq %r12, %rdx
je 0x2298a
leaq (%r14,%r12,8), %rdi
movq 0x8(%rsp), %rax
leaq (%rax,%r12,8), %rsi
movq %r15, %rcx
callq 0x29e1c
movq %rax, %r15
leal -0x4(%rbp), %r12d
testl %r12d, %r12d
js 0x229bd
movl %r12d, %eax
imulq %rbx, %rax
leaq (,%rax,8), %rsi
addq %r13, %rsi
movq %r14, %rdi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x29760
leaq (%rax,%r15,4), %r15
addl $-0x2, %r12d
jmp 0x2298e
movq %r15, (%r14,%rbx,8)
leal -0x1(%rbp), %ecx
leal -0x3(%rbp), %eax
imulq %rbx, %rax
leaq (,%rax,8), %rsi
addq %r13, %rsi
movq %rcx, 0x8(%rsp)
movq %rcx, %rax
imulq %rbx, %rax
leaq (,%rax,8), %rdx
addq %r13, %rdx
movq 0x50(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rcx
callq 0x29760
movq %rax, %r15
addl $-0x5, %ebp
testl %ebp, %ebp
js 0x22a2f
movl %ebp, %eax
imulq %rbx, %rax
leaq (,%rax,8), %rsi
addq %r13, %rsi
movq %r12, %rdi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x29760
leaq (%rax,%r15,4), %r15
addl $-0x2, %ebp
jmp 0x22a03
movq %r15, (%r12,%rbx,8)
incq %rbx
movq 0x8(%rsp), %r15
pushq $0x1
popq %rcx
andl $0x1, %r15d
jne 0x22a4c
movq %r14, %rdi
movq %r14, %rsi
jmp 0x22a52
movq %r12, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x181a0
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x1ac5c
movl %eax, %ebp
testl %eax, %eax
js 0x22a7b
movq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %r12, %rdx
jmp 0x22a86
movq 0x10(%rsp), %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x17ed0
sarl $0x1f, %ebp
movq %r14, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x17cf0
decl %r15d
xorl %ebp, %r15d
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop