// File: /workspace/github_cpp_makefile_star2_O3/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 $0x68, %rsp
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r13
leaq 0x2(%rdx), %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
movq %rax, 0x48(%rsp)
mulq %rcx
movq %rdx, %r15
shrq %r15
andq $-0x2, %rdx
movq %r15, %rax
shlq $0x5, %rax
movq %r12, %r14
leaq (%rbx,%rax), %rbp
addq $0x20, %rbp
leaq 0x10(%rbx,%rdx,8), %rax
movq %rax, 0x38(%rsp)
movq %rdi, 0x40(%rsp)
leaq 0x8(%rdi,%r15,8), %rax
movq %rax, 0x20(%rsp)
leaq (%rsi,%rdx,8), %rax
movq %rdx, 0x60(%rsp)
subq %rdx, %r14
movq %r14, 0x50(%rsp)
movq %rbp, 0x30(%rsp)
movq %rax, 0x28(%rsp)
je 0x26ea4
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
movq %r14, %rcx
callq 0x1ba80
movq %r14, %rcx
testq %rax, %rax
je 0x26ea6
cmpq %r15, %r14
jge 0x26f2d
movq (%r13,%r14,8), %rdx
leaq 0x1(%r14), %rcx
incq %rdx
movq %rdx, (%rbx,%r14,8)
movq %rcx, %r14
je 0x26e84
jmp 0x26ea6
xorl %ecx, %ecx
cmpq %r13, %rbx
je 0x26ec1
cmpq %r15, %rcx
jge 0x26ec1
movq (%r13,%rcx,8), %rax
movq %rax, (%rbx,%rcx,8)
incq %rcx
cmpq %rcx, %r15
jne 0x26eb0
leaq (,%r15,8), %rdx
addq %r13, %rdx
movq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %rdx, 0x10(%rsp)
movq %r15, %rcx
callq 0x1ba80
leaq (%r14,%r15,8), %rdi
movq %rax, (%rdi)
movq %r15, %rax
shlq $0x4, %rax
addq %r13, %rax
addq $-0x8, %rax
xorl %r14d, %r14d
movq %r15, %rcx
movq 0x38(%rsp), %rbp
movq %rdi, 0x18(%rsp)
testq %rcx, %rcx
jle 0x26f6c
movq -0x8(%rbx,%rcx,8), %rdx
decq %rcx
movq (%rax), %rsi
addq $-0x8, %rax
cmpq %rsi, %rdx
je 0x26f09
jbe 0x272a8
xorl %r14d, %r14d
jmp 0x26f6c
leaq (,%r15,8), %rdx
addq %r13, %rdx
movq %rbp, %rdi
movq %rbx, %rsi
movq %rdx, 0x10(%rsp)
movq %r15, %rcx
callq 0x1ba80
incq %rax
leaq (,%r15,8), %rcx
addq %rbp, %rcx
movq %rcx, 0x18(%rsp)
movq %rax, (%rcx)
movl $0x1, %r14d
movq 0x38(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rsi
movq 0x10(%rsp), %rdx
movq %r15, %rcx
callq 0x1bca0
subq %rax, %r14
movq 0x60(%rsp), %rax
leaq (%rbx,%rax,8), %rax
movq %rax, 0x10(%rsp)
movq %r14, (%rbp,%r15,8)
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %r14
movq %r14, %rdx
movq 0x50(%rsp), %rbp
movq %rbp, %rcx
callq 0x1ba80
movq %rax, %r11
movq %r15, %rax
subq %rbp, %rax
jne 0x27059
movq 0x20(%rsp), %r14
movq 0x10(%rsp), %rbp
movq 0x18(%rsp), %rdi
leaq (,%r15,4), %rax
movq %rax, 0x18(%rsp)
addq (%rdi), %r11
movq %r14, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %r15, %rcx
movq %r11, %r12
callq 0x2f420
leaq (%rax,%r12,2), %rax
movq %rax, (%r14,%r15,8)
leaq 0x1(%r15), %r14
addq $0x8, %rbp
leaq (%r15,%r15,4), %rax
movq %rbp, %r12
leaq (%rbx,%rax,8), %rbp
addq $0x28, %rbp
cmpq $0x17f, 0x48(%rsp)      # imm = 0x17F
movq %r12, 0x10(%rsp)
movq %r14, 0x58(%rsp)
movq %rbx, %rdi
jbe 0x2711c
movq 0x38(%rsp), %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x26dec
movq %r12, %rdi
movq 0x20(%rsp), %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x26dec
jmp 0x2713f
addq (%r14,%rbp,8), %r11
movq 0x20(%rsp), %rdi
movq %r11, (%rdi,%rbp,8)
jae 0x27249
cmpq $0x2, %rax
movl $0x1, %r11d
movl $0x1, %esi
cmovgeq %rax, %rsi
leaq (,%r12,8), %rcx
leaq (,%r15,8), %rdx
subq %rdx, %rcx
movq 0x40(%rsp), %rdx
addq %rdx, %rcx
addq $0x10, %rcx
movq %r15, %rdx
shlq $0x4, %rdx
leaq (%rdx,%r12,8), %rdx
addq %rbx, %rdx
addq $0x28, %rdx
decq %rsi
xorl %r8d, %r8d
movq %rdi, %r14
movq 0x10(%rsp), %rbp
cmpq %r8, %rsi
je 0x26fcd
movq (%rdx,%r8,8), %r9
leaq 0x1(%r8), %rdi
incq %r9
movq %r9, (%rcx,%r8,8)
movq %rdi, %r8
je 0x270be
cmpq %r14, 0x30(%rsp)
setne %sil
leaq 0x1(%rdi), %r8
cmpq %rax, %r8
setl %r8b
andb %sil, %r8b
xorl %r11d, %r11d
cmpb $0x1, %r8b
jne 0x26fcd
movq (%rdx,%rdi,8), %rsi
movq %rsi, (%rcx,%rdi,8)
leaq 0x1(%rdi), %rsi
addq $0x2, %rdi
cmpq %rax, %rdi
movq %rsi, %rdi
jl 0x270ff
jmp 0x26fcd
movq 0x38(%rsp), %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x26b38
movq %r12, %rdi
movq 0x20(%rsp), %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x26b38
movq 0x18(%rsp), %r14
movq 0x40(%rsp), %r12
leaq (%r12,%r14,8), %rdi
movq 0x50(%rsp), %rdx
cmpq $0x80, %rdx
movq 0x28(%rsp), %rsi
movq %rbp, %rcx
jle 0x2716a
callq 0x26dec
jmp 0x2716f
callq 0x26b38
leaq (,%r15,8), %rax
movq (%r12,%r14,8), %rcx
movq %rcx, 0x20(%rsp)
movq 0x8(%r12,%r14,8), %rcx
movq %rcx, 0x28(%rsp)
movq 0x60(%rsp), %rcx
leaq (%r12,%rcx,8), %rdi
leaq (%rax,%rax,4), %rax
leaq (%rbx,%rax), %rbp
addq $0x28, %rbp
movq 0x48(%rsp), %rax
cmpq $0x17f, %rax            # imm = 0x17F
jbe 0x271e6
movq 0x30(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq %rbp, %rcx
callq 0x26dec
movq 0x28(%rsp), %rax
movq %rax, 0x8(%r12,%r14,8)
cmpq $0x182, 0x48(%rsp)      # imm = 0x182
jbe 0x27202
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %rbp, %rcx
callq 0x26dec
jmp 0x27213
movq 0x30(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq %rbp, %rcx
callq 0x26b38
movq 0x28(%rsp), %rax
movq %rax, 0x8(%r12,%r14,8)
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %rbp, %rcx
callq 0x26b38
movq 0x50(%rsp), %r8
addq %r8, %r8
movq 0x20(%rsp), %rax
movq %rax, (%rsp)
movq %r12, %rdi
movq 0x10(%rsp), %rsi
movq %rbx, %rdx
movq %r15, %rcx
xorl %r9d, %r9d
callq 0x28080
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq %rdi, %r14
sete %cl
cmpq $0x2, %rax
setl %al
orb %cl, %al
movq %rdi, %r14
movq 0x18(%rsp), %rdi
jne 0x272c3
leaq (%r15,%r15,2), %rax
decq %rax
leaq (,%r15,8), %rdx
movq 0x40(%rsp), %rcx
subq %rdx, %rcx
addq $0x10, %rcx
movq %r15, %rdx
shlq $0x4, %rdx
addq %rbx, %rdx
addq $0x28, %rdx
xorl %r11d, %r11d
movq 0x10(%rsp), %rbp
movq (%rdx,%r12,8), %rsi
movq %rsi, (%rcx,%r12,8)
incq %r12
cmpq %r12, %rax
jne 0x27293
jmp 0x26fd2
movq %rbp, %rdi
movq 0x10(%rsp), %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x1bca0
xorl %r14d, %r14d
jmp 0x26f82
xorl %r11d, %r11d
movq 0x10(%rsp), %rbp
jmp 0x26fd2