// File: marxn[P]pupp/3rdparty/gmp/mpn/toom_eval_pm1.c
// Function: _gmpn_toom_eval_pm1
int
mpn_toom_eval_pm1 (mp_ptr xp1, mp_ptr xm1, unsigned k,
		   mp_srcptr xp, mp_size_t n, mp_size_t hn, mp_ptr tp)
{
  unsigned i;
  int neg;

  ASSERT (k >= 4);

  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. */

  xp1[n] = mpn_add_n (xp1, xp, xp + 2*n, n);
  for (i = 4; i < k; i += 2)
    ASSERT_NOCARRY (mpn_add (xp1, xp1, n+1, xp+i*n, n));

  tp[n] = mpn_add_n (tp, xp + n, xp + 3*n, n);
  for (i = 5; i < k; i += 2)
    ASSERT_NOCARRY (mpn_add (tp, tp, n+1, xp+i*n, n));

  if (k & 1)
    ASSERT_NOCARRY (mpn_add (tp, tp, n+1, xp+k*n, hn));
  else
    ASSERT_NOCARRY (mpn_add (xp1, xp1, n+1, xp+k*n, hn));

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

#if HAVE_NATIVE_mpn_add_n_sub_n
  if (neg)
    mpn_add_n_sub_n (xp1, xm1, tp, xp1, n + 1);
  else
    mpn_add_n_sub_n (xp1, xm1, xp1, tp, n + 1);
#else
  if (neg)
    mpn_sub_n (xm1, tp, xp1, n + 1);
  else
    mpn_sub_n (xm1, xp1, tp, n + 1);

  mpn_add_n (xp1, xp1, tp, n + 1);
#endif

  ASSERT (xp1[n] <= k);
  ASSERT (xm1[n] <= k/2 + 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 0x49d95
jmp 0x49d97
jmp 0x49d99
jmp 0x49d9b
jmp 0x49d9d
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x28(%rbp), %rcx
callq 0x36c80
movq %rax, %rdx
movq -0x8(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x4, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x49e15
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rdx
addq $0x1, %rdx
movq -0x20(%rbp), %rcx
movl -0x34(%rbp), %eax
imulq -0x28(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x28(%rbp), %r8
callq 0x36b60
movl -0x34(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x34(%rbp)
jmp 0x49dd6
movq 0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x20(%rbp), %rdx
imulq $0x3, -0x28(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x28(%rbp), %rcx
callq 0x36c80
movq %rax, %rdx
movq 0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x5, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x49e96
movq 0x10(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
addq $0x1, %rdx
movq -0x20(%rbp), %rcx
movl -0x34(%rbp), %eax
imulq -0x28(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x28(%rbp), %r8
callq 0x36b60
movl -0x34(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x34(%rbp)
jmp 0x49e57
movl -0x14(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x49ecf
movq 0x10(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
addq $0x1, %rdx
movq -0x20(%rbp), %rcx
movl -0x14(%rbp), %eax
imulq -0x28(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x30(%rbp), %r8
callq 0x36b60
jmp 0x49efb
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rdx
addq $0x1, %rdx
movq -0x20(%rbp), %rcx
movl -0x14(%rbp), %eax
imulq -0x28(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x30(%rbp), %r8
callq 0x36b60
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 0x49f43
movq -0x10(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq -0x8(%rbp), %rdx
movq -0x28(%rbp), %rcx
addq $0x1, %rcx
callq 0x36fe0
jmp 0x49f5c
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 0x49f77
jmp 0x49f79
jmp 0x49f7b
movl -0x38(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop