// File: marxn[P]pupp/3rdparty/gmp/mpn/toom3_sqr.c
// Function: _gmpn_toom3_sqr
void
mpn_toom3_sqr (mp_ptr pp,
	       mp_srcptr ap, mp_size_t an,
	       mp_ptr scratch)
{
  const int __gmpn_cpuvec_initialized = 1;
  mp_size_t n, s;
  mp_limb_t cy, vinf0;
  mp_ptr gp;
  mp_ptr as1, asm1, as2;

#define a0  ap
#define a1  (ap + n)
#define a2  (ap + 2*n)

  n = (an + 2) / (size_t) 3;

  s = an - 2 * n;

  ASSERT (0 < s && s <= n);

  as1 = scratch + 4 * n + 4;
  asm1 = scratch + 2 * n + 2;
  as2 = pp + n + 1;

  gp = scratch;

  /* Compute as1 and asm1.  */
  cy = mpn_add (gp, a0, n, a2, s);
#if HAVE_NATIVE_mpn_add_n_sub_n
  if (cy == 0 && mpn_cmp (gp, a1, n) < 0)
    {
      cy = mpn_add_n_sub_n (as1, asm1, a1, gp, n);
      as1[n] = cy >> 1;
      asm1[n] = 0;
    }
  else
    {
      mp_limb_t cy2;
      cy2 = mpn_add_n_sub_n (as1, asm1, gp, a1, n);
      as1[n] = cy + (cy2 >> 1);
      asm1[n] = cy - (cy2 & 1);
    }
#else
  as1[n] = cy + mpn_add_n (as1, gp, a1, n);
  if (cy == 0 && mpn_cmp (gp, a1, n) < 0)
    {
      mpn_sub_n (asm1, a1, gp, n);
      asm1[n] = 0;
    }
  else
    {
      cy -= mpn_sub_n (asm1, gp, a1, n);
      asm1[n] = cy;
    }
#endif

  /* Compute as2.  */
#if HAVE_NATIVE_mpn_rsblsh1_n
  cy = mpn_add_n (as2, a2, as1, s);
  if (s != n)
    cy = mpn_add_1 (as2 + s, as1 + s, n - s, cy);
  cy += as1[n];
  cy = 2 * cy + mpn_rsblsh1_n (as2, a0, as2, n);
#else
#if HAVE_NATIVE_mpn_addlsh1_n
  cy  = mpn_addlsh1_n (as2, a1, a2, s);
  if (s != n)
    cy = mpn_add_1 (as2 + s, a1 + s, n - s, cy);
  cy = 2 * cy + mpn_addlsh1_n (as2, a0, as2, n);
#else
  cy = mpn_add_n (as2, a2, as1, s);
  if (s != n)
    cy = mpn_add_1 (as2 + s, as1 + s, n - s, cy);
  cy += as1[n];
  cy = 2 * cy + mpn_lshift (as2, as2, n, 1);
  cy -= mpn_sub_n (as2, as2, a0, n);
#endif
#endif
  as2[n] = cy;

  ASSERT (as1[n] <= 2);
  ASSERT (asm1[n] <= 1);

#define v0    pp				/* 2n */
#define v1    (pp + 2 * n)			/* 2n+1 */
#define vinf  (pp + 4 * n)			/* s+s */
#define vm1   scratch				/* 2n+1 */
#define v2    (scratch + 2 * n + 1)		/* 2n+2 */
#define scratch_out  (scratch + 5 * n + 5)

  /* vm1, 2n+1 limbs */
#ifdef SMALLER_RECURSION
  TOOM3_SQR_REC (vm1, asm1, n, scratch_out);
  cy = 0;
  if (asm1[n] != 0)
    cy = asm1[n] + mpn_add_n (vm1 + n, vm1 + n, asm1, n);
  if (asm1[n] != 0)
    cy += mpn_add_n (vm1 + n, vm1 + n, asm1, n);
  vm1[2 * n] = cy;
#else
  TOOM3_SQR_REC (vm1, asm1, n + 1, scratch_out);
#endif

  TOOM3_SQR_REC (v2, as2, n + 1, scratch_out);	/* v2, 2n+1 limbs */

  TOOM3_SQR_REC (vinf, a2, s, scratch_out);	/* vinf, s+s limbs */

  vinf0 = vinf[0];				/* v1 overlaps with this */

#ifdef SMALLER_RECURSION
  /* v1, 2n+1 limbs */
  TOOM3_SQR_REC (v1, as1, n, scratch_out);
  if (as1[n] == 1)
    {
      cy = as1[n] + mpn_add_n (v1 + n, v1 + n, as1, n);
    }
  else if (as1[n] != 0)
    {
#if HAVE_NATIVE_mpn_addlsh1_n
      cy = 2 * as1[n] + mpn_addlsh1_n (v1 + n, v1 + n, as1, n);
#else
      cy = 2 * as1[n] + mpn_addmul_1 (v1 + n, as1, n, CNST_LIMB(2));
#endif
    }
  else
    cy = 0;
  if (as1[n] == 1)
    {
      cy += mpn_add_n (v1 + n, v1 + n, as1, n);
    }
  else if (as1[n] != 0)
    {
#if HAVE_NATIVE_mpn_addlsh1_n
      cy += mpn_addlsh1_n (v1 + n, v1 + n, as1, n);
#else
      cy += mpn_addmul_1 (v1 + n, as1, n, CNST_LIMB(2));
#endif
    }
  v1[2 * n] = cy;
#else
  cy = vinf[1];
  TOOM3_SQR_REC (v1, as1, n + 1, scratch_out);
  vinf[1] = cy;
#endif

  TOOM3_SQR_REC (v0, ap, n, scratch_out);	/* v0, 2n limbs */

  mpn_toom_interpolate_5pts (pp, v2, vm1, n, s + s, 0, vinf0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x1, -0x24(%rbp)
movq -0x18(%rbp), %rax
addq $0x2, %rax
movl $0x3, %ecx
xorl %edx, %edx
divq %rcx
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
shlq %rcx
subq %rcx, %rax
movq %rax, -0x38(%rbp)
jmp 0x4916c
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
shlq $0x2, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
addq $0x20, %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
shlq %rcx
shlq $0x3, %rcx
addq %rcx, %rax
addq $0x10, %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
addq $0x8, %rax
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq -0x30(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x38(%rbp), %r8
callq 0x36b60
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x30(%rbp), %rcx
callq 0x36c80
movq -0x70(%rbp), %rdx
addq %rax, %rdx
movq -0x58(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
cmpq $0x0, -0x40(%rbp)
jne 0x49280
movq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x30(%rbp), %rdx
callq 0x3b060
cmpl $0x0, %eax
jge 0x49280
movq -0x60(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x50(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x36fe0
movq -0x60(%rbp), %rax
movq -0x30(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
jmp 0x492be
movq -0x60(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x30(%rbp), %rcx
callq 0x36fe0
movq %rax, %rcx
movq -0x40(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdx
movq -0x60(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x68(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x58(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x36c80
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x30(%rbp), %rax
je 0x49322
movq -0x68(%rbp), %rdi
movq -0x38(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x58(%rbp), %rsi
movq -0x38(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x30(%rbp), %rdx
subq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0x564f0
movq %rax, -0x40(%rbp)
movq -0x58(%rbp), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
shlq %rax
movq %rax, -0x78(%rbp)
movq -0x68(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x557e0
movq %rax, %rcx
movq -0x78(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdx
movq -0x68(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x49376
jmp 0x49378
jmp 0x4937a
jmp 0x4937c
movq -0x30(%rbp), %rax
addq $0x1, %rax
cmpq $0x81, %rax
jge 0x493b7
movq -0x20(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x30(%rbp), %rdx
addq $0x1, %rdx
movq -0x20(%rbp), %rcx
imulq $0x5, -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
addq $0x28, %rcx
callq 0x48d00
jmp 0x493e0
movq -0x20(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x30(%rbp), %rdx
addq $0x1, %rdx
movq -0x20(%rbp), %rcx
imulq $0x5, -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
addq $0x28, %rcx
callq 0x49120
jmp 0x493e2
jmp 0x493e4
movq -0x30(%rbp), %rax
addq $0x1, %rax
cmpq $0x81, %rax
jge 0x49431
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdi
addq $0x8, %rdi
movq -0x68(%rbp), %rsi
movq -0x30(%rbp), %rdx
addq $0x1, %rdx
movq -0x20(%rbp), %rcx
imulq $0x5, -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
addq $0x28, %rcx
callq 0x48d00
jmp 0x4946c
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdi
addq $0x8, %rdi
movq -0x68(%rbp), %rsi
movq -0x30(%rbp), %rdx
addq $0x1, %rdx
movq -0x20(%rbp), %rcx
imulq $0x5, -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
addq $0x28, %rcx
callq 0x49120
jmp 0x4946e
jmp 0x49470
cmpq $0x81, -0x38(%rbp)
jge 0x494be
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
shlq $0x2, %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x38(%rbp), %rdx
movq -0x20(%rbp), %rcx
imulq $0x5, -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
addq $0x28, %rcx
callq 0x48d00
jmp 0x49500
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
shlq $0x2, %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x38(%rbp), %rdx
movq -0x20(%rbp), %rcx
imulq $0x5, -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
addq $0x28, %rcx
callq 0x49120
jmp 0x49502
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
shlq $0x2, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
shlq $0x2, %rcx
movq 0x8(%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
addq $0x1, %rax
cmpq $0x81, %rax
jge 0x49574
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x58(%rbp), %rsi
movq -0x30(%rbp), %rdx
addq $0x1, %rdx
movq -0x20(%rbp), %rcx
imulq $0x5, -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
addq $0x28, %rcx
callq 0x48d00
jmp 0x495ab
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x58(%rbp), %rsi
movq -0x30(%rbp), %rdx
addq $0x1, %rdx
movq -0x20(%rbp), %rcx
imulq $0x5, -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
addq $0x28, %rcx
callq 0x49120
jmp 0x495ad
movq -0x40(%rbp), %rdx
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
shlq $0x2, %rcx
movq %rdx, 0x8(%rax,%rcx,8)
cmpq $0x81, -0x30(%rbp)
jge 0x495f3
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x20(%rbp), %rcx
imulq $0x5, -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
addq $0x28, %rcx
callq 0x48d00
jmp 0x49618
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x20(%rbp), %rcx
imulq $0x5, -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
addq $0x28, %rcx
callq 0x49120
jmp 0x4961a
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x30(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rsi
addq $0x8, %rsi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %r8
addq -0x38(%rbp), %r8
movq -0x48(%rbp), %rax
xorl %r9d, %r9d
movq %rax, (%rsp)
callq 0x4a7a0
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)