// File: /workspace/github_cpp_makefile_star2_O3/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 $0x28, %rsp
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %rbp
movq %rdi, %r13
movq %rdx, %r12
sarq %r12
movq %rdx, (%rsp)
subq %r12, %r14
leaq (%rsi,%r12,8), %rdx
cmpq %r14, %r12
jne 0x26b9d
movq %r12, %rax
shlq $0x4, %rax
addq %rbp, %rax
addq $-0x8, %rax
movq %r12, %rcx
testq %rcx, %rcx
jle 0x26b95
leaq -0x1(%rcx), %rsi
movq (%rax), %rdi
addq $-0x8, %rax
cmpq %rdi, -0x8(%rbp,%rcx,8)
movq %rsi, %rcx
je 0x26b79
jbe 0x26c12
movq %r13, %rdi
movq %rbp, %rsi
jmp 0x26c1b
movq (%rdx), %rbx
leaq (,%r14,8), %rdx
addq %rbp, %rdx
testq %rbx, %rbx
je 0x26bc8
movq %r13, %rdi
movq %rbp, %rsi
movq %r12, %rcx
callq 0x1bca0
subq %rax, %rbx
movq %rbx, (%r13,%r12,8)
jmp 0x26c23
movq (%rsp), %rax
leaq -0x8(,%rax,8), %rax
addq %rbp, %rax
movq %r12, %rcx
testq %rcx, %rcx
jle 0x26bb0
leaq -0x1(%rcx), %rsi
movq (%rax), %rdi
addq $-0x8, %rax
cmpq %rdi, -0x8(%rbp,%rcx,8)
movq %rsi, %rcx
je 0x26bda
ja 0x26bb0
movq %r13, %rdi
movq %rdx, %rsi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x1bca0
movq $0x0, (%r13,%r12,8)
jmp 0x26c23
movq %r13, %rdi
movq %rdx, %rsi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x1bca0
cmpq $0x21, %r14
jle 0x26c43
movq %r14, %rcx
shlq $0x4, %rcx
addq %r15, %rcx
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x26b38
jmp 0x26c51
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1dad0
leaq (,%r14,8), %rsi
addq %rbp, %rsi
cmpq $0x21, %r12
jle 0x26c7a
movq %r14, %rcx
shlq $0x4, %rcx
leaq (%rcx,%r13), %rdi
addq %r15, %rcx
movq %r12, %rdx
callq 0x26b38
jmp 0x26c8c
movq %r14, %rdi
shlq $0x4, %rdi
addq %r13, %rdi
movq %r12, %rdx
callq 0x1dad0
cmpq $0x21, %r14
movq %r15, 0x20(%rsp)
jle 0x26cb1
movq %r14, %rcx
shlq $0x4, %rcx
addq %r15, %rcx
movq %r13, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x26b38
jmp 0x26cbf
movq %r13, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x1dad0
leaq (%r14,%r14), %rax
movq %rax, 0x18(%rsp)
movq %r14, %rbp
shlq $0x4, %rbp
addq %r13, %rbp
leaq (,%r14,8), %r15
addq %r13, %r15
movq %rbp, %rdi
movq %r15, %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x1ba80
movq %rax, %rbx
movq %r15, %rdi
movq %rbp, %rsi
movq %r13, 0x8(%rsp)
movq %r13, %rdx
movq %r14, %rcx
callq 0x1ba80
movq %rax, %r13
movq %rbx, 0x10(%rsp)
addq %rbx, %r13
movq (%rsp), %rbx
andq $-0x2, %rbx
subq %r14, %rbx
je 0x26d73
leaq (,%r14,8), %rdx
addq %rbp, %rdx
movq %rbp, %rdi
movq %rbp, %rsi
movq %rbx, %rcx
callq 0x1ba80
testq %rax, %rax
je 0x26d73
movq (%rsp), %rcx
leaq (,%rcx,8), %rax
andq $-0x10, %rax
leaq (%rax,%rcx,8), %rax
shlq $0x3, %r12
subq %r12, %rax
addq 0x8(%rsp), %rax
xorl %r12d, %r12d
cmpq %r14, %rbx
jge 0x26d78
incq %rbx
incq (%rax)
leaq 0x8(%rax), %rax
je 0x26d60
jmp 0x26d7e
xorl %r12d, %r12d
jmp 0x26d7e
movl $0x1, %r12d
addq 0x10(%rsp), %r12
movq %r15, %rdi
movq %r15, %rsi
movq 0x20(%rsp), %rdx
movq 0x18(%rsp), %rcx
callq 0x1bca0
subq %rax, %r12
addq %r13, (%rbp)
jae 0x26dac
addq $0x1, 0x8(%rbp)
leaq 0x8(%rbp), %rbp
jb 0x26da1
leaq (%r14,%r14,2), %rax
movq 0x8(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
cmpq $0x2, %r12
ja 0x26dde
addq %r12, (%rax)
jae 0x26dcf
addq $0x1, 0x8(%rax)
leaq 0x8(%rax), %rax
jb 0x26dc4
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
subq $0x1, (%rax)
leaq 0x8(%rax), %rax
jb 0x26dde
jmp 0x26dcf
nop