// File: /workspace/github_cpp_makefile_star2_O1/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 %rsi, %rbp
movq %rdi, %r13
movq %rdx, %r12
sarq %r12
movq %rdx, %r14
subq %r12, %r14
cmpq %r14, %r12
movq %rdx, (%rsp)
jne 0x26f64
movq %rdx, %rbx
leaq (,%r14,8), %rdx
addq %rbp, %rdx
movq %rbx, %rax
shlq $0x4, %rax
movq %r12, %rcx
shlq $0x4, %rcx
subq %rcx, %rax
addq %rbp, %rax
addq $-0x8, %rax
movq %r14, %rcx
testq %rcx, %rcx
jle 0x26f59
leaq -0x1(%rcx), %rsi
movq (%rax), %rdi
addq $-0x8, %rax
cmpq %rdi, -0x8(%rbp,%rcx,8)
movq %rsi, %rcx
je 0x26f39
jbe 0x26fdb
movq %r13, %rdi
movq %rbp, %rsi
jmp 0x26fe4
movq (%rbp,%r12,8), %rbx
leaq (,%r14,8), %rdx
addq %rbp, %rdx
testq %rbx, %rbx
je 0x26f91
movq %r13, %rdi
movq %rbp, %rsi
movq %r12, %rcx
callq 0x1c1c0
subq %rax, %rbx
movq %rbx, (%r13,%r12,8)
jmp 0x26fec
movq (%rsp), %rax
leaq -0x8(,%rax,8), %rax
addq %rbp, %rax
movq %r12, %rcx
testq %rcx, %rcx
jle 0x26f79
leaq -0x1(%rcx), %rsi
movq (%rax), %rdi
addq $-0x8, %rax
cmpq %rdi, -0x8(%rbp,%rcx,8)
movq %rsi, %rcx
je 0x26fa3
ja 0x26f79
movq %r13, %rdi
movq %rdx, %rsi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x1c1c0
movq $0x0, (%r13,%r12,8)
jmp 0x26fec
movq %r13, %rdi
movq %rdx, %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x1c1c0
cmpq $0x21, %r14
jle 0x2700c
movq %r14, %rcx
shlq $0x4, %rcx
addq %r15, %rcx
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x26ee4
jmp 0x2701a
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1e000
leaq (,%r14,8), %rsi
addq %rbp, %rsi
cmpq $0x21, %r12
jle 0x27043
movq %r14, %rcx
shlq $0x4, %rcx
leaq (%rcx,%r13), %rdi
addq %r15, %rcx
movq %r12, %rdx
callq 0x26ee4
jmp 0x27055
movq %r14, %rdi
shlq $0x4, %rdi
addq %r13, %rdi
movq %r12, %rdx
callq 0x1e000
cmpq $0x21, %r14
movq %r15, 0x20(%rsp)
jle 0x2707a
movq %r14, %rcx
shlq $0x4, %rcx
addq %r15, %rcx
movq %r13, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x26ee4
jmp 0x27088
movq %r13, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x1e000
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 0x1bfa0
movq %rax, %rbx
movq %r15, %rdi
movq %rbp, %rsi
movq %r13, 0x8(%rsp)
movq %r13, %rdx
movq %r14, %rcx
callq 0x1bfa0
movq %rax, %r13
movq %rbx, 0x10(%rsp)
addq %rbx, %r13
movq (%rsp), %rbx
andq $-0x2, %rbx
subq %r14, %rbx
je 0x2713c
leaq (,%r14,8), %rdx
addq %rbp, %rdx
movq %rbp, %rdi
movq %rbp, %rsi
movq %rbx, %rcx
callq 0x1bfa0
testq %rax, %rax
je 0x2713c
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 0x27141
incq %rbx
incq (%rax)
leaq 0x8(%rax), %rax
je 0x27129
jmp 0x27147
xorl %r12d, %r12d
jmp 0x27147
movl $0x1, %r12d
addq 0x10(%rsp), %r12
movq %r15, %rdi
movq %r15, %rsi
movq 0x20(%rsp), %rdx
movq 0x18(%rsp), %rcx
callq 0x1c1c0
subq %rax, %r12
addq %r13, (%rbp)
jae 0x27175
addq $0x1, 0x8(%rbp)
leaq 0x8(%rbp), %rbp
jb 0x2716a
leaq (%r14,%r14,2), %rax
movq 0x8(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
cmpq $0x2, %r12
ja 0x271a7
addq %r12, (%rax)
jae 0x27198
addq $0x1, 0x8(%rax)
leaq 0x8(%rax), %rax
jb 0x2718d
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
subq $0x1, (%rax)
leaq 0x8(%rax), %rax
jb 0x271a7
jmp 0x27198
nop