// File: 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
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x1, -0x24(%rbp)
movq -0x18(%rbp), %rax
sarq %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
subq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x48d3b
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x30(%rbp), %rax
jne 0x48db5
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x30(%rbp), %rdx
callq 0x3b060
cmpl $0x0, %eax
jge 0x48d90
movq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x10(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x36fe0
jmp 0x48db0
movq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x30(%rbp), %rcx
callq 0x36fe0
jmp 0x48e5c
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x48e17
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x38(%rbp), %rdx
callq 0x3b060
cmpl $0x0, %eax
jge 0x48e17
movq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x10(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x36fe0
movq -0x50(%rbp), %rax
movq -0x38(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
jmp 0x48e5a
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x70(%rbp)
movq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x38(%rbp), %rcx
callq 0x36fe0
movq -0x70(%rbp), %rdx
subq %rax, %rdx
movq -0x50(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x48e5c
jmp 0x48e5e
cmpq $0x22, -0x30(%rbp)
jge 0x48e78
movq -0x20(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x39930
jmp 0x48e9b
movq -0x20(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rcx
callq 0x48d00
jmp 0x48e9d
jmp 0x48e9f
cmpq $0x22, -0x38(%rbp)
jge 0x48ed2
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x38(%rbp), %rdx
callq 0x39930
jmp 0x48f0e
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x38(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rcx
callq 0x48d00
jmp 0x48f10
jmp 0x48f12
cmpq $0x22, -0x30(%rbp)
jge 0x48f2c
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x39930
jmp 0x48f4f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rcx
callq 0x48d00
jmp 0x48f51
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rsi
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x8(%rbp), %rdx
movq -0x30(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x30(%rbp), %rcx
callq 0x36c80
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rsi
movq -0x30(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x8(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x36c80
movq %rax, %rcx
movq -0x78(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rsi
movq -0x30(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x30(%rbp), %rdx
movq -0x8(%rbp), %rcx
movq -0x30(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x38(%rbp), %r8
addq -0x38(%rbp), %r8
subq -0x30(%rbp), %r8
callq 0x36b60
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rsi
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %rcx
shlq %rcx
callq 0x36fe0
movq %rax, %rcx
movq -0x40(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x40(%rbp)
jmp 0x49071
jmp 0x49073
jmp 0x49075
jmp 0x49077
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
shlq %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq -0x48(%rbp), %rcx
addq %rcx, (%rax)
jae 0x4909d
addq $0x1, 0x8(%rax)
leaq 0x8(%rax), %rax
jb 0x49092
movq %rax, -0x58(%rbp)
jmp 0x490a3
jmp 0x490a5
cmpq $0x2, -0x40(%rbp)
setbe %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x490f5
jmp 0x490c7
movq -0x8(%rbp), %rax
imulq $0x3, -0x30(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq -0x40(%rbp), %rcx
addq %rcx, (%rax)
jae 0x490eb
addq $0x1, 0x8(%rax)
leaq 0x8(%rax), %rax
jb 0x490e0
movq %rax, -0x60(%rbp)
jmp 0x490f1
jmp 0x490f3
jmp 0x49117
jmp 0x490f7
movq -0x8(%rbp), %rax
imulq $0x3, -0x30(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
subq $0x1, (%rax)
leaq 0x8(%rax), %rax
jb 0x49107
movq %rax, -0x68(%rbp)
jmp 0x49117
addq $0x80, %rsp
popq %rbp
retq