// File: 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
movq %rsp, %rbp
subq $0x40, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
jmp 0x49fb5
jmp 0x49fb7
jmp 0x49fb9
jmp 0x49fbb
jmp 0x49fbd
jmp 0x49fbf
jmp 0x49fc1
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
shlq $0x2, %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x14(%rbp), %eax
subl $0x2, %eax
movl %eax, %eax
imulq -0x28(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x20(%rbp), %rdx
movl -0x14(%rbp), %eax
imulq -0x28(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x30(%rbp), %rcx
callq 0x55b60
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x28(%rbp), %rax
je 0x4a066
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x20(%rbp), %rsi
movl -0x14(%rbp), %eax
subl $0x2, %eax
movl %eax, %eax
imulq -0x28(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x28(%rbp), %rdx
subq -0x30(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0x564f0
movq %rax, -0x40(%rbp)
movl -0x14(%rbp), %eax
subl $0x4, %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jl 0x4a0bd
jmp 0x4a077
movq -0x40(%rbp), %rax
shlq $0x2, %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movslq -0x34(%rbp), %rax
imulq -0x28(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x8(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x55b60
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x4a0b2
movl -0x34(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x34(%rbp)
jmp 0x4a06f
movq -0x40(%rbp), %rdx
movq -0x8(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
shlq $0x2, %rax
movq %rax, -0x40(%rbp)
movq 0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x14(%rbp), %eax
subl $0x2, %eax
movl %eax, %eax
imulq -0x28(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x20(%rbp), %rdx
movl -0x14(%rbp), %eax
imulq -0x28(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x28(%rbp), %rcx
callq 0x55b60
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movl -0x14(%rbp), %eax
subl $0x4, %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jl 0x4a181
jmp 0x4a13b
movq -0x40(%rbp), %rax
shlq $0x2, %rax
movq %rax, -0x40(%rbp)
movq 0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movslq -0x34(%rbp), %rax
imulq -0x28(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq 0x10(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x55b60
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x4a176
movl -0x34(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x34(%rbp)
jmp 0x4a133
movq -0x40(%rbp), %rdx
movq 0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x4a1b8
movq 0x10(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
addq $0x1, %rdx
movl $0x1, %ecx
callq 0x37320
jmp 0x4a1d2
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rdx
addq $0x1, %rdx
movl $0x1, %ecx
callq 0x37320
movq -0x8(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
addq $0x1, %rdx
callq 0x3b060
movl %eax, %edx
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x0, %edx
cmovll %ecx, %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
je 0x4a21a
movq -0x10(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq -0x8(%rbp), %rdx
movq -0x28(%rbp), %rcx
addq $0x1, %rcx
callq 0x36fe0
jmp 0x4a233
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq 0x10(%rbp), %rdx
movq -0x28(%rbp), %rcx
addq $0x1, %rcx
callq 0x36fe0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq 0x10(%rbp), %rdx
movq -0x28(%rbp), %rcx
addq $0x1, %rcx
callq 0x36c80
jmp 0x4a24e
jmp 0x4a250
jmp 0x4a252
movl -0x14(%rbp), %eax
andl $0x1, %eax
subl $0x1, %eax
xorl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)