// File: /workspace/github_cpp_makefile_star2_O2/marxn[P]pupp/3rdparty/gmp/mpn/toom2_sqr.c
// Function: _gmpn_toom2_sqr
void
mpn_toom2_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, cy2;
  mp_ptr asm1;

#define a0  ap
#define a1  (ap + n)

  s = an >> 1;
  n = an - s;

  ASSERT (0 < s && s <= n && s >= n - 1);

  asm1 = pp;

  /* Compute asm1.  */
  if (s == n)
    {
      if (mpn_cmp (a0, a1, n) < 0)
	{
	  mpn_sub_n (asm1, a1, a0, n);
	}
      else
	{
	  mpn_sub_n (asm1, a0, a1, n);
	}
    }
  else /* n - s == 1 */
    {
      if (a0[s] == 0 && mpn_cmp (a0, a1, s) < 0)
	{
	  mpn_sub_n (asm1, a1, a0, s);
	  asm1[s] = 0;
	}
      else
	{
	  asm1[s] = a0[s] - mpn_sub_n (asm1, a0, a1, s);
	}
    }

#define v0	pp				/* 2n */
#define vinf	(pp + 2 * n)			/* s+s */
#define vm1	scratch				/* 2n */
#define scratch_out	scratch + 2 * n

  /* vm1, 2n limbs */
  TOOM2_SQR_REC (vm1, asm1, n, scratch_out);

  /* vinf, s+s limbs */
  TOOM2_SQR_REC (vinf, a1, s, scratch_out);

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

  /* H(v0) + L(vinf) */
  cy = mpn_add_n (pp + 2 * n, v0 + n, vinf, n);

  /* L(v0) + H(v0) */
  cy2 = cy + mpn_add_n (pp + n, pp + 2 * n, v0, n);

  /* L(vinf) + H(vinf) */
  cy += mpn_add (pp + 2 * n, pp + 2 * n, n, vinf + n, s + s - n);

  cy -= mpn_sub_n (pp + n, pp + n, vm1, 2 * n);

  ASSERT (cy + 1  <= 3);
  ASSERT (cy2 <= 2);

  MPN_INCR_U (pp + 2 * n, s + s, cy2);
  if (LIKELY (cy <= 2))
    MPN_INCR_U (pp + 3 * n, s + s - n, cy);
  else
    MPN_DECR_U (pp + 3 * n, s + s - n, 1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, 0x8(%rsp)
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
movq %rdx, %rbp
sarq %rbp
movq %rdx, %r14
subq %rbp, %r14
leaq (%rsi,%rbp,8), %r15
cmpq %r14, %rbp
jne 0x21ed2
movq %r13, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x1ac5c
movq %rbx, %rdi
testl %eax, %eax
js 0x21f1a
movq %r13, %rsi
movq %r15, %rdx
jmp 0x21f20
movq (%r15), %r15
leaq (,%r14,8), %rdx
addq %r13, %rdx
testq %r15, %r15
jne 0x21f03
movq %r13, %rdi
movq %rdx, %rsi
movq %rdx, (%rsp)
movq %rbp, %rdx
callq 0x1ac5c
movq (%rsp), %rdx
testl %eax, %eax
js 0x22089
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rcx
callq 0x17ed0
subq %rax, %r15
movq %r15, (%rbx,%rbp,8)
jmp 0x21f28
movq %r15, %rsi
movq %r13, %rdx
movq %rbp, %rcx
callq 0x17ed0
cmpq $0x21, %r14
movq 0x8(%rsp), %r15
jle 0x21f4d
movq %r14, %rcx
shlq $0x4, %rcx
addq %r15, %rcx
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x21e84
jmp 0x21f5b
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x19c70
leaq (,%r14,8), %rsi
addq %r13, %rsi
cmpq $0x21, %rbp
jle 0x21f84
movq %r14, %rcx
shlq $0x4, %rcx
leaq (%rbx,%rcx), %rdi
addq %r15, %rcx
movq %rbp, %rdx
callq 0x21e84
jmp 0x21f96
movq %r14, %rdi
shlq $0x4, %rdi
addq %rbx, %rdi
movq %rbp, %rdx
callq 0x19c70
cmpq $0x21, %r14
jle 0x21fb6
movq %r14, %rcx
shlq $0x4, %rcx
addq %r15, %rcx
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x21e84
jmp 0x21fc4
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x19c70
leaq (%r14,%r14), %rax
movq %rax, (%rsp)
movq %r14, %r13
shlq $0x4, %r13
addq %rbx, %r13
leaq (%rbx,%r14,8), %r15
movq %r13, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x17cf0
movq %rbx, %rdx
movq %rbx, 0x10(%rsp)
movq %rax, %rbx
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rcx
callq 0x17cf0
movq %rax, %rbp
addq %rbx, %rbp
leaq (,%r14,8), %rcx
addq %r13, %rcx
andq $-0x2, %r12
subq %r14, %r12
movq %r13, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %r12, %r8
callq 0x17c54
movq %rax, %r12
addq %rbx, %r12
movq %r15, %rdi
movq %r15, %rsi
movq 0x8(%rsp), %rdx
movq (%rsp), %rcx
callq 0x17ed0
subq %rax, %r12
addq %rbp, (%r13)
jae 0x2205b
addq $0x1, 0x8(%r13)
leaq 0x8(%r13), %r13
jb 0x22050
imulq $0x18, %r14, %rax
addq 0x10(%rsp), %rax
cmpq $0x2, %r12
ja 0x220a4
addq %r12, (%rax)
jae 0x2207a
addq $0x1, 0x8(%rax)
leaq 0x8(%rax), %rax
jb 0x2206f
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movq %rdx, %rsi
movq %r13, %rdx
movq %rbp, %rcx
callq 0x17ed0
andq $0x0, (%rbx,%rbp,8)
jmp 0x21f28
subq $0x1, (%rax)
leaq 0x8(%rax), %rax
jb 0x220a4
jmp 0x2207a