// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, 0x10(%rsp)
movq %r8, %r13
movq %rcx, %rbp
movq %rdx, %r14
movq %rsi, %rcx
movq %rdi, %rbx
movq %rdx, %r15
sarq %r15
subq %r15, %r14
movq %r8, 0x28(%rsp)
subq %r14, %r13
movq %r15, %rax
leaq (%rsi,%r15,8), %r12
subq %r14, %rax
movq %rax, 0x30(%rsp)
movq %rsi, 0x18(%rsp)
jne 0x1c505
movq %r13, (%rsp)
movq %rcx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rcx, %r13
callq 0x1ac5c
movq %rbx, %rdi
testl %eax, %eax
js 0x1c557
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x17ed0
movl $0x0, 0xc(%rsp)
jmp 0x1c56c
movq %rbp, (%rsp)
movq (%r12), %rbp
leaq (%rcx,%r14,8), %r12
testq %rbp, %rbp
jne 0x1c531
movq %rcx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x1ac5c
movq 0x18(%rsp), %rcx
testl %eax, %eax
js 0x1c87b
movq %rbx, %rdi
movq %rcx, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x17ed0
subq %rax, %rbp
movq %rbp, (%rbx,%r15,8)
movl $0x0, 0xc(%rsp)
movq (%rsp), %rbp
jmp 0x1c570
movq %r12, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x17ed0
pushq $0x1
popq %rax
movl %eax, 0xc(%rsp)
movq (%rsp), %r13
leaq (%rbx,%r14,8), %rax
movq %rax, (%rsp)
movq %r14, %r12
subq %r13, %r12
jne 0x1c5b4
leaq (,%r14,8), %r12
addq %rbp, %r12
movq %rbp, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x1ac5c
testl %eax, %eax
js 0x1c609
movq (%rsp), %rdi
movq %rbp, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x17ed0
jmp 0x1c64d
leaq (,%r13,8), %rdi
addq %rbp, %rdi
movq %r12, %rsi
callq 0x2b954
testl %eax, %eax
je 0x1c5ea
leaq (,%r14,8), %rsi
addq %rbp, %rsi
movq %rbp, %rdi
movq %rsi, 0x20(%rsp)
movq %r13, %rdx
callq 0x1ac5c
testl %eax, %eax
js 0x1c61d
leaq (,%r14,8), %rcx
addq %rbp, %rcx
movq (%rsp), %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq %r13, %r8
callq 0x17dc8
jmp 0x1c64d
movq (%rsp), %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x17ed0
jmp 0x1c648
movq (%rsp), %rdi
movq 0x20(%rsp), %rsi
movq %rbp, %rdx
movq %r13, %rcx
callq 0x17ed0
movq 0x28(%rsp), %rax
leaq (%rbx,%rax,8), %rdi
shlq $0x3, %r12
xorl %esi, %esi
movq %r12, %rdx
callq 0x6170
xorl $0x1, 0xc(%rsp)
cmpq $0x1b, %r14
jle 0x1c679
movq %r14, %r9
shlq $0x4, %r9
movq 0x10(%rsp), %rdi
addq %rdi, %r9
movq %rbx, %rsi
movq %r14, %rdx
movq (%rsp), %r12
movq %r12, %rcx
movq %r14, %r8
callq 0x1c488
jmp 0x1c693
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq (%rsp), %r12
movq %r12, %rcx
movq %r14, %r8
callq 0x19820
cmpq %r13, %r15
movq 0x18(%rsp), %rcx
jle 0x1c6e6
cmpq $0x1b, %r13
jle 0x1c718
leaq (,%r15,4), %rax
leaq (,%r13,4), %rdx
addq %r13, %rdx
movq %r14, %r9
shlq $0x4, %r9
leaq (%rbx,%r9), %rdi
addq 0x10(%rsp), %r9
leaq (%rcx,%r14,8), %rsi
leaq (,%r14,8), %rcx
addq %rbp, %rcx
cmpq %rdx, %rax
jge 0x1c86b
movq %r15, %rdx
movq %r13, %r8
jmp 0x1c711
leaq (%rcx,%r14,8), %rsi
leaq (,%r14,8), %rcx
addq %rbp, %rcx
cmpq $0x1b, %r15
jle 0x1c739
movq %r14, %r9
shlq $0x4, %r9
leaq (%rbx,%r9), %rdi
addq 0x10(%rsp), %r9
movq %r15, %rdx
movq %r15, %r8
callq 0x1c488
jmp 0x1c74e
movq %r14, %rdi
shlq $0x4, %rdi
addq %rbx, %rdi
leaq (%rcx,%r14,8), %rsi
leaq (,%r14,8), %rcx
addq %rbp, %rcx
movq %r15, %rdx
movq %r13, %r8
jmp 0x1c749
movq %r14, %rdi
shlq $0x4, %rdi
addq %rbx, %rdi
movq %r15, %rdx
movq %r15, %r8
callq 0x19820
cmpq $0x1b, %r14
jle 0x1c778
movq %r14, %r9
shlq $0x4, %r9
addq 0x10(%rsp), %r9
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
movq %r14, %rdx
movq %rbp, %rcx
movq %r14, %r8
callq 0x1c488
jmp 0x1c78e
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
movq %r14, %rdx
movq %rbp, %rcx
movq %r14, %r8
callq 0x19820
leaq (%r14,%r14), %rax
movq %rax, (%rsp)
movq %r14, %r15
shlq $0x4, %r15
addq %rbx, %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x17cf0
movq %rax, %rbp
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, 0x18(%rsp)
movq %rbx, %rdx
movq %r14, %rcx
callq 0x17cf0
movq %rax, %rbx
addq %rbp, %rbx
leaq (%r15,%r14,8), %rcx
movq 0x30(%rsp), %r8
addq %r13, %r8
movq %r15, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x17c54
movq %rax, %r13
addq %rbp, %r13
cmpl $0x0, 0xc(%rsp)
je 0x1c810
movq %r12, %rdi
movq %r12, %rsi
movq 0x10(%rsp), %rdx
movq (%rsp), %rcx
callq 0x17cf0
addq %r13, %rax
jmp 0x1c82a
movq %r12, %rdi
movq %r12, %rsi
movq 0x10(%rsp), %rdx
movq (%rsp), %rcx
callq 0x17ed0
subq %rax, %r13
movq %r13, %rax
addq %rbx, (%r15)
jae 0x1c83a
addq $0x1, 0x8(%r15)
leaq 0x8(%r15), %r15
jb 0x1c82f
imulq $0x18, %r14, %rcx
movq 0x18(%rsp), %rdx
addq %rcx, %rdx
cmpq $0x2, %rax
ja 0x1c89d
addq %rax, (%rdx)
jae 0x1c85c
addq $0x1, 0x8(%rdx)
leaq 0x8(%rdx), %rdx
jb 0x1c851
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdx
movq %r13, %r8
callq 0x1c8ac
jmp 0x1c74e
movq %rbx, %rdi
movq %r12, %rsi
movq %rcx, %rdx
movq %r15, %rcx
callq 0x17ed0
andq $0x0, (%rbx,%r15,8)
pushq $0x1
popq %rax
movl %eax, 0xc(%rsp)
jmp 0x1c551
subq $0x1, (%rdx)
leaq 0x8(%rdx), %rdx
jb 0x1c89d
jmp 0x1c85c
nopl (%rax)