// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rcx, %r14
movq %rdx, %r8
movq %rsi, %r13
leaq 0x2(%rdx), %rax
pushq $0x3
popq %rcx
movq %rax, 0x50(%rsp)
xorl %edx, %edx
divq %rcx
movq %rax, %r12
movq %rax, 0x28(%rsp)
leaq (%rax,%rax), %rcx
movq %rcx, 0x70(%rsp)
subq %rcx, %r8
shlq $0x5, %rax
leaq (%r14,%rax), %rcx
movq %rcx, 0x20(%rsp)
leaq (%r14,%rax), %rbp
addq $0x20, %rbp
movq %r12, %rax
shlq $0x4, %rax
leaq (%r14,%rax), %rbx
addq $0x10, %rbx
movq %rdi, 0x58(%rsp)
leaq 0x8(%rdi,%r12,8), %rcx
movq %rcx, 0x68(%rsp)
movq %rax, 0x18(%rsp)
leaq (%rsi,%rax), %rcx
movq %r14, %rdi
movq %r12, %rdx
movq %rcx, 0x10(%rsp)
movq %r8, 0x60(%rsp)
callq 0x17c54
movq %rax, %r15
movq %r13, 0x38(%rsp)
leaq (%r13,%r12,8), %r13
movq %rbp, 0x30(%rsp)
movq %rbp, %rdi
movq 0x28(%rsp), %rbp
movq %r14, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0x17cf0
addq %r15, %rax
movq 0x20(%rsp), %rcx
movq %rax, 0x20(%rcx,%r12,8)
testq %r15, %r15
jne 0x2218d
movq %r14, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x1ac5c
testl %eax, %eax
js 0x223b6
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %rbp, %rcx
callq 0x17ed0
subq %rax, %r15
addq %r14, 0x18(%rsp)
movq %rbx, 0x40(%rsp)
movq %r15, (%rbx,%rbp,8)
movq 0x68(%rsp), %rbp
movq %rbp, %rdi
movq 0x10(%rsp), %rsi
movq 0x30(%rsp), %r13
movq %r13, %rdx
movq 0x60(%rsp), %rbx
movq %rbx, %rcx
callq 0x17cf0
movq %rax, %r15
movq %r12, %rdx
subq %rbx, %rdx
je 0x221fd
leaq (,%rbx,8), %rdi
addq %rbp, %rdi
leaq (,%rbx,8), %rsi
addq %r13, %rsi
movq %r15, %rcx
callq 0x29e1c
movq %rax, %r15
movq %r13, %rax
leaq (,%r12,4), %rcx
movq %rcx, 0x20(%rsp)
movq 0x28(%rsp), %r13
addq (%rax,%r13,8), %r15
movq %rbp, %rdi
movq 0x38(%rsp), %rsi
movq %rbp, %rdx
movq %r13, %rcx
callq 0x293e0
leaq (%rax,%r15,2), %rax
movq %rax, (%rbp,%r13,8)
imulq $0x28, %r12, %rax
incq %r12
movq 0x18(%rsp), %r13
addq $0x8, %r13
leaq (%r14,%rax), %r15
addq $0x28, %r15
cmpq $0x17f, 0x50(%rsp)      # imm = 0x17F
jbe 0x2227b
movq %r14, %rdi
movq 0x40(%rsp), %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x220b0
movq %r13, %rdi
movq %rbp, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x220b0
jmp 0x2229f
movq %r14, %rdi
movq 0x40(%rsp), %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x21e84
movq %r13, %rdi
movq %rbp, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x21e84
movq 0x20(%rsp), %rax
movq 0x58(%rsp), %rcx
leaq (%rcx,%rax,8), %rdi
cmpq $0x80, %rbx
movq %r14, 0x48(%rsp)
movq %r13, 0x18(%rsp)
jle 0x222d2
movq 0x10(%rsp), %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x220b0
jmp 0x222e2
movq 0x10(%rsp), %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x21e84
movq 0x20(%rsp), %rbp
movq 0x58(%rsp), %r13
movq (%r13,%rbp,8), %rax
movq %rax, 0x10(%rsp)
movq 0x8(%r13,%rbp,8), %r14
movq 0x70(%rsp), %rax
leaq (,%rax,8), %rdi
addq %r13, %rdi
movq 0x50(%rsp), %rax
cmpq $0x17f, %rax            # imm = 0x17F
jbe 0x22353
movq 0x30(%rsp), %rsi
movq %r12, %rdx
movq %r15, %rcx
movq %rax, %r12
callq 0x220b0
movq %r14, 0x8(%r13,%rbp,8)
cmpq $0x182, %r12            # imm = 0x182
jbe 0x22368
movq %r13, %rdi
movq 0x38(%rsp), %rsi
movq 0x28(%rsp), %r14
movq %r14, %rdx
movq %r15, %rcx
callq 0x220b0
jmp 0x22380
movq 0x30(%rsp), %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x21e84
movq %r14, 0x8(%r13,%rbp,8)
movq %r13, %rdi
movq 0x38(%rsp), %rsi
movq 0x28(%rsp), %r14
movq %r14, %rdx
movq %r15, %rcx
callq 0x21e84
movq 0x48(%rsp), %rdx
movq 0x18(%rsp), %rsi
addq %rbx, %rbx
movq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq %r13, %rdi
movq %r14, %rcx
movq %rbx, %r8
xorl %r9d, %r9d
callq 0x22e58
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x17ed0
xorl %r15d, %r15d
jmp 0x221a1
nop