// File: marxn[P]pupp/3rdparty/gmp/mpn/toom22_mul.c
// Function: _gmpn_toom22_mul
void
mpn_toom22_mul (mp_ptr pp,
		mp_srcptr ap, mp_size_t an,
		mp_srcptr bp, mp_size_t bn,
		mp_ptr scratch)
{
  const int __gmpn_cpuvec_initialized = 1;
  mp_size_t n, s, t;
  int vm1_neg;
  mp_limb_t cy, cy2;
  mp_ptr asm1;
  mp_ptr bsm1;

#define a0  ap
#define a1  (ap + n)
#define b0  bp
#define b1  (bp + n)

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

  ASSERT (an >= bn);

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

  asm1 = pp;
  bsm1 = pp + n;

  vm1_neg = 0;

  /* Compute asm1.  */
  if (s == n)
    {
      if (mpn_cmp (a0, a1, n) < 0)
	{
	  mpn_sub_n (asm1, a1, a0, n);
	  vm1_neg = 1;
	}
      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;
	  vm1_neg = 1;
	}
      else
	{
	  asm1[s] = a0[s] - mpn_sub_n (asm1, a0, a1, s);
	}
    }

  /* Compute bsm1.  */
  if (t == n)
    {
      if (mpn_cmp (b0, b1, n) < 0)
	{
	  mpn_sub_n (bsm1, b1, b0, n);
	  vm1_neg ^= 1;
	}
      else
	{
	  mpn_sub_n (bsm1, b0, b1, n);
	}
    }
  else
    {
      if (mpn_zero_p (b0 + t, n - t) && mpn_cmp (b0, b1, t) < 0)
	{
	  mpn_sub_n (bsm1, b1, b0, t);
	  MPN_ZERO (bsm1 + t, n - t);
	  vm1_neg ^= 1;
	}
      else
	{
	  mpn_sub (bsm1, b0, n, b1, t);
	}
    }

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

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

  if (s > t)  TOOM22_MUL_REC (vinf, a1, s, b1, t, scratch_out);
  else        TOOM22_MUL_N_REC (vinf, a1, b1, s, scratch_out);

  /* v0, 2n limbs */
  TOOM22_MUL_N_REC (v0, ap, bp, 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 + t - n);

  if (vm1_neg)
    cy += mpn_add_n (pp + n, pp + n, vm1, 2 * n);
  else
    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 + t, cy2);
  if (LIKELY (cy <= 2))
    /* if s+t==n, cy is zero, but we should not acces pp[3*n] at all. */
    MPN_INCR_U (pp + 3 * n, s + t - n, cy);
  else
    MPN_DECR_U (pp + 3 * n, s + t - n, 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl $0x1, -0x34(%rbp)
movq -0x18(%rbp), %rax
sarq %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
subq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
subq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x3e84f
jmp 0x3e851
jmp 0x3e853
jmp 0x3e855
jmp 0x3e857
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x8(%rbp), %rax
movq -0x40(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movl $0x0, -0x54(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x40(%rbp), %rax
jne 0x3e8f2
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x40(%rbp), %rdx
callq 0x3b060
cmpl $0x0, %eax
jge 0x3e8cd
movq -0x70(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x10(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0x36fe0
movl $0x1, -0x54(%rbp)
jmp 0x3e8ed
movq -0x70(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x40(%rbp), %rcx
callq 0x36fe0
jmp 0x3e9a6
movq -0x10(%rbp), %rax
movq -0x48(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x3e95b
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x48(%rbp), %rdx
callq 0x3b060
cmpl $0x0, %eax
jge 0x3e95b
movq -0x70(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x10(%rbp), %rdx
movq -0x48(%rbp), %rcx
callq 0x36fe0
movq -0x70(%rbp), %rax
movq -0x48(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movl $0x1, -0x54(%rbp)
jmp 0x3e9a4
movq -0x10(%rbp), %rax
movq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xa8(%rbp)
movq -0x70(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x48(%rbp), %rcx
callq 0x36fe0
movq -0xa8(%rbp), %rdx
subq %rax, %rdx
movq -0x70(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x3e9a6
movq -0x50(%rbp), %rax
cmpq -0x40(%rbp), %rax
jne 0x3ea21
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x40(%rbp), %rdx
callq 0x3b060
cmpl $0x0, %eax
jge 0x3e9fc
movq -0x78(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x20(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0x36fe0
movl -0x54(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x3ea1c
movq -0x78(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x40(%rbp), %rcx
callq 0x36fe0
jmp 0x3eb2a
movq -0x20(%rbp), %rdi
movq -0x50(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x40(%rbp), %rsi
subq -0x50(%rbp), %rsi
callq 0x590e0
cmpl $0x0, %eax
je 0x3eb04
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x50(%rbp), %rdx
callq 0x3b060
cmpl $0x0, %eax
jge 0x3eb04
movq -0x78(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x20(%rbp), %rdx
movq -0x50(%rbp), %rcx
callq 0x36fe0
jmp 0x3ea8d
jmp 0x3ea8f
movq -0x40(%rbp), %rax
subq -0x50(%rbp), %rax
cmpq $0x0, %rax
je 0x3eaf7
jmp 0x3ea9f
movq -0x78(%rbp), %rax
movq -0x50(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x40(%rbp), %rax
subq -0x50(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x3eac3
jmp 0x3eac5
movq -0x80(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x80(%rbp)
movq $0x0, (%rax)
movq -0x88(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x88(%rbp)
cmpq $0x0, %rax
jne 0x3eac5
jmp 0x3eaf5
jmp 0x3eaf7
jmp 0x3eaf9
movl -0x54(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x3eb28
movq -0x78(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x50(%rbp), %r8
callq 0x36d60
jmp 0x3eb2a
jmp 0x3eb2c
cmpq $0x1c, -0x40(%rbp)
jge 0x3eb4e
movq -0x30(%rbp), %rdi
movq -0x70(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x78(%rbp), %rcx
movq -0x40(%rbp), %r8
callq 0x394e0
jmp 0x3eb79
movq -0x30(%rbp), %rdi
movq -0x70(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x78(%rbp), %rcx
movq -0x40(%rbp), %r8
movq -0x30(%rbp), %r9
movq -0x40(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %r9
callq 0x3e800
jmp 0x3eb7b
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jle 0x3ec8f
jmp 0x3eb8b
cmpq $0x1c, -0x50(%rbp)
jge 0x3ebd4
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x48(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x50(%rbp), %r8
callq 0x394e0
jmp 0x3ec88
movq -0x48(%rbp), %rax
shlq $0x2, %rax
imulq $0x5, -0x50(%rbp), %rcx
cmpq %rcx, %rax
jge 0x3ec37
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x48(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x50(%rbp), %r8
movq -0x30(%rbp), %r9
movq -0x40(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %r9
callq 0x3e800
jmp 0x3ec86
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x48(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x50(%rbp), %r8
movq -0x30(%rbp), %r9
movq -0x40(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %r9
callq 0x3efa0
jmp 0x3ec88
jmp 0x3ec8a
jmp 0x3ed2a
jmp 0x3ec91
cmpq $0x1c, -0x48(%rbp)
jge 0x3ecd7
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x48(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x48(%rbp), %r8
callq 0x394e0
jmp 0x3ed26
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x48(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x48(%rbp), %r8
movq -0x30(%rbp), %r9
movq -0x40(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %r9
callq 0x3e800
jmp 0x3ed28
jmp 0x3ed2a
jmp 0x3ed2c
cmpq $0x1c, -0x40(%rbp)
jge 0x3ed4e
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %r8
callq 0x394e0
jmp 0x3ed79
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x40(%rbp), %r8
movq -0x30(%rbp), %r9
movq -0x40(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %r9
callq 0x3e800
jmp 0x3ed7b
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rsi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x8(%rbp), %rdx
movq -0x40(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x40(%rbp), %rcx
callq 0x36c80
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rsi
movq -0x40(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x8(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0x36c80
movq %rax, %rcx
movq -0xb0(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rsi
movq -0x40(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x40(%rbp), %rdx
movq -0x8(%rbp), %rcx
movq -0x40(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x48(%rbp), %r8
addq -0x50(%rbp), %r8
subq -0x40(%rbp), %r8
callq 0x36b60
addq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpl $0x0, -0x54(%rbp)
je 0x3eea1
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rsi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x30(%rbp), %rdx
movq -0x40(%rbp), %rcx
shlq %rcx
callq 0x36c80
addq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x3eedd
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rsi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x30(%rbp), %rdx
movq -0x40(%rbp), %rcx
shlq %rcx
callq 0x36fe0
movq %rax, %rcx
movq -0x60(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x60(%rbp)
jmp 0x3eedf
jmp 0x3eee1
jmp 0x3eee3
jmp 0x3eee5
jmp 0x3eee7
movq -0x8(%rbp), %rax
movq -0x40(%rbp), %rcx
shlq %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq -0x68(%rbp), %rcx
addq %rcx, (%rax)
jae 0x3ef0d
addq $0x1, 0x8(%rax)
leaq 0x8(%rax), %rax
jb 0x3ef02
movq %rax, -0x90(%rbp)
jmp 0x3ef16
jmp 0x3ef18
cmpq $0x2, -0x60(%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 0x3ef6b
jmp 0x3ef3a
movq -0x8(%rbp), %rax
imulq $0x3, -0x40(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq -0x60(%rbp), %rcx
addq %rcx, (%rax)
jae 0x3ef5e
addq $0x1, 0x8(%rax)
leaq 0x8(%rax), %rax
jb 0x3ef53
movq %rax, -0x98(%rbp)
jmp 0x3ef67
jmp 0x3ef69
jmp 0x3ef90
jmp 0x3ef6d
movq -0x8(%rbp), %rax
imulq $0x3, -0x40(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
subq $0x1, (%rax)
leaq 0x8(%rax), %rax
jb 0x3ef7d
movq %rax, -0xa0(%rbp)
jmp 0x3ef90
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax)