// File: /workspace/github_cpp_makefile_star2_O1/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 $0x58, %rsp
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, 0x30(%rsp)
leaq 0x2(%rdx), %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
movq %rax, 0x38(%rsp)
mulq %rcx
movq %rdx, %r15
shrq %r15
andq $-0x2, %rdx
movq %r15, %rax
shlq $0x5, %rax
movq %r12, %r14
addq %rbx, %rax
addq $0x20, %rax
movq %rax, 0x20(%rsp)
leaq (%rsi,%rdx,8), %rax
movq %rdx, 0x40(%rsp)
subq %rdx, %r14
movq %r14, 0x28(%rsp)
movq %rax, 0x50(%rsp)
je 0x27253
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
movq %r14, %rcx
callq 0x1bfa0
movq %r14, %rcx
testq %rax, %rax
je 0x27255
cmpq %r15, %r14
jge 0x2727c
movq (%r13,%r14,8), %rdx
leaq 0x1(%r14), %rcx
incq %rdx
movq %rdx, (%rbx,%r14,8)
movq %rcx, %r14
je 0x27237
jmp 0x27255
xorl %ecx, %ecx
xorl %ebp, %ebp
movb $0x1, %al
movl %eax, 0x10(%rsp)
cmpq %r13, %rbx
je 0x27289
cmpq %r15, %rcx
jge 0x27289
xorl %ebp, %ebp
movq (%r13,%rcx,8), %rax
movq %rax, (%rbx,%rcx,8)
incq %rcx
cmpq %rcx, %r15
jne 0x27269
jmp 0x27289
movl $0x1, %ebp
movl $0x0, 0x10(%rsp)
movq 0x40(%rsp), %rax
leaq (%rbx,%rax,8), %rax
addq $0x10, %rax
movq %rax, 0x18(%rsp)
movq 0x30(%rsp), %rax
leaq 0x8(%rax,%r15,8), %rax
movq %rax, 0x8(%rsp)
leaq (%r13,%r15,8), %rdx
movq 0x20(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %rdx, 0x48(%rsp)
movq %r15, %rcx
callq 0x1bfa0
addq %rbp, %rax
movq %rax, (%r14,%r15,8)
cmpb $0x0, 0x10(%rsp)
je 0x27306
movq %r15, %rax
shlq $0x4, %rax
addq %r13, %rax
addq $-0x8, %rax
movq %r15, %rcx
testq %rcx, %rcx
jle 0x27306
leaq -0x1(%rcx), %rdx
movq (%rax), %rsi
addq $-0x8, %rax
cmpq %rsi, -0x8(%rbx,%rcx,8)
movq %rdx, %rcx
je 0x272e6
jbe 0x275fa
movq 0x18(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq 0x48(%rsp), %rdx
movq %r15, %rcx
callq 0x1c1c0
subq %rax, %rbp
movq %rbp, (%r14,%r15,8)
movq 0x8(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x20(%rsp), %r14
movq %r14, %rdx
movq 0x28(%rsp), %rbp
movq %rbp, %rcx
callq 0x1bfa0
movq %rax, %r11
movq %r15, %rax
subq %rbp, %rax
je 0x2745d
addq (%r14,%rbp,8), %r11
movq 0x8(%rsp), %rdi
movq %r11, (%rdi,%rbp,8)
movq 0x30(%rsp), %r10
jae 0x27408
cmpq $0x2, %rax
movl $0x1, %r11d
movl $0x1, %esi
cmovgeq %rax, %rsi
leaq (,%r12,8), %rcx
leaq (,%r15,8), %rdx
subq %rdx, %rcx
addq %r10, %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, %r12
cmpq %r8, %rsi
je 0x27462
movq (%rdx,%r8,8), %r9
leaq 0x1(%r8), %rdi
incq %r9
movq %r9, (%rcx,%r8,8)
movq %rdi, %r8
je 0x273b3
cmpq %r12, %r14
setne %sil
leaq 0x1(%rdi), %r8
cmpq %rax, %r8
setl %r8b
andb %sil, %r8b
xorl %r11d, %r11d
cmpb $0x1, %r8b
jne 0x27462
movq (%rdx,%rdi,8), %rsi
movq %rsi, (%rcx,%rdi,8)
leaq 0x1(%rdi), %rsi
addq $0x2, %rdi
cmpq %rax, %rdi
movq %rsi, %rdi
jl 0x273ee
jmp 0x27462
cmpq %rdi, %r14
sete %cl
cmpq $0x2, %rax
setl %al
orb %cl, %al
jne 0x27455
leaq (%r15,%r15,2), %rax
decq %rax
leaq (,%r15,8), %rdx
movq %r10, %rcx
subq %rdx, %rcx
addq $0x10, %rcx
movq %r15, %rdx
shlq $0x4, %rdx
addq %rbx, %rdx
addq $0x28, %rdx
xorl %r11d, %r11d
movq (%rdx,%r12,8), %rsi
movq %rsi, (%rcx,%r12,8)
incq %r12
cmpq %r12, %rax
jne 0x27443
jmp 0x27458
xorl %r11d, %r11d
movq 0x20(%rsp), %r14
movq 0x8(%rsp), %r12
movq 0x40(%rsp), %rax
leaq (%rbx,%rax,8), %rbp
addq (%r14,%r15,8), %r11
movq %r12, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
movq %r11, %r14
callq 0x2f7e0
leaq (%rax,%r14,2), %rax
movq %rax, (%r12,%r15,8)
leaq 0x1(%r15), %rdx
leaq (%r15,%r15,4), %rax
leaq (%rbx,%rax,8), %r14
addq $0x28, %r14
cmpq $0x17f, 0x38(%rsp)      # imm = 0x17F
movq %rdx, 0x10(%rsp)
movq %rbx, %rdi
jbe 0x274bd
movq 0x18(%rsp), %rsi
movq %r14, %rcx
callq 0x271b4
jmp 0x274ca
movq 0x18(%rsp), %rsi
movq %r14, %rcx
callq 0x26ee4
leaq (,%r15,4), %r12
addq $0x8, %rbp
cmpq $0x17f, 0x38(%rsp)      # imm = 0x17F
movq %rbp, 0x18(%rsp)
movq %rbp, %rdi
jbe 0x274fd
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rcx
callq 0x271b4
jmp 0x2750f
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rcx
callq 0x26ee4
movq 0x30(%rsp), %rbp
leaq (,%r12,8), %rdi
addq %rbp, %rdi
movq 0x28(%rsp), %rdx
cmpq $0x80, %rdx
movq 0x50(%rsp), %rsi
movq %r14, %rcx
jle 0x2753c
callq 0x271b4
jmp 0x27541
callq 0x26ee4
movq (%rbp,%r12,8), %rax
movq %rax, 0x8(%rsp)
movq %rbp, %rax
movq 0x8(%rbp,%r12,8), %rbp
movq 0x40(%rsp), %rcx
leaq (%rax,%rcx,8), %rdi
cmpq $0x17f, 0x38(%rsp)      # imm = 0x17F
movq 0x10(%rsp), %rdx
jbe 0x2757b
movq 0x20(%rsp), %rsi
movq %r14, %rcx
callq 0x271b4
jmp 0x27588
movq 0x20(%rsp), %rsi
movq %r14, %rcx
callq 0x26ee4
movq 0x30(%rsp), %rax
movq %rbp, 0x8(%rax,%r12,8)
movq %rax, %r12
cmpq $0x182, 0x38(%rsp)      # imm = 0x182
jbe 0x275b3
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x271b4
jmp 0x275c4
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x26ee4
movq 0x28(%rsp), %r8
addq %r8, %r8
movq 0x8(%rsp), %rax
movq %rax, (%rsp)
movq %r12, %rdi
movq 0x18(%rsp), %rsi
movq %rbx, %rdx
movq %r15, %rcx
xorl %r9d, %r9d
callq 0x283e8
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rsp), %r14
movq %r14, %rdi
movq 0x48(%rsp), %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x1c1c0
xorl %ebp, %ebp
jmp 0x27321
nopl (%rax)