// File: /workspace/github_cpp_makefile_star2_O3/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 $0x48, %rsp
movq %r9, %rbx
movq %rcx, %r15
movq %rdx, %rbp
movq %rsi, %r9
movq %rdx, %rcx
sarq %rcx
movq %rdx, %r14
subq %rcx, %r14
movq %r8, 0x28(%rsp)
subq %r14, %r8
movq %r8, 0x40(%rsp)
movq %rcx, %r12
leaq (%rsi,%rcx,8), %rdx
subq %r14, %r12
movq %rdi, 0x10(%rsp)
movq %rbx, 0x30(%rsp)
movq %rcx, 0x20(%rsp)
movq %rsi, 0x38(%rsp)
jne 0x2044d
movq %rdi, %r13
movq %rcx, %rax
shlq $0x4, %rax
addq %r9, %rax
addq $-0x8, %rax
movq %rcx, %r8
testq %r8, %r8
jle 0x20433
leaq -0x1(%r8), %rsi
movq (%rax), %rdi
addq $-0x8, %rax
cmpq %rdi, -0x8(%r9,%r8,8)
movq %rsi, %r8
je 0x20413
jbe 0x20651
movq %r13, %rdi
movq %r9, %rsi
callq 0x1bca0
movq 0x20(%rsp), %rsi
movl $0x0, 0xc(%rsp)
jmp 0x20487
movq (%rdx), %rbx
leaq (%r9,%r14,8), %rdx
testq %rbx, %rbx
je 0x205c8
movq 0x10(%rsp), %r13
movq %r13, %rdi
movq %r9, %rsi
callq 0x1bca0
movq 0x20(%rsp), %rsi
subq %rax, %rbx
movq %rbx, (%r13,%rsi,8)
movl $0x0, 0xc(%rsp)
movq 0x30(%rsp), %rbx
leaq (,%r14,8), %rdi
addq %r13, %rdi
movq %r14, %r13
subq 0x40(%rsp), %r13
movq %rdi, 0x18(%rsp)
jne 0x204f8
leaq (%r15,%r14,8), %rdx
shlq $0x4, %rbp
movq %rsi, %rax
shlq $0x4, %rax
subq %rax, %rbp
leaq (%r15,%rbp), %rax
addq $-0x8, %rax
movq %r14, %rcx
movq 0x10(%rsp), %r13
movq 0x40(%rsp), %rbp
testq %rcx, %rcx
jle 0x204e8
leaq -0x1(%rcx), %rsi
movq (%rax), %r8
addq $-0x8, %rax
cmpq %r8, -0x8(%r15,%rcx,8)
movq %rsi, %rcx
je 0x204c8
jbe 0x20671
movq %r15, %rsi
movq %r14, %rcx
callq 0x1bca0
jmp 0x206bc
movq 0x28(%rsp), %rax
leaq (%rax,%rsi,2), %rax
subq %rbp, %rax
subq %rbp, %rax
shlq $0x3, %rbp
leaq (,%rsi,8), %rcx
subq %rcx, %rbp
leaq (%r15,%rbp), %rcx
addq $-0x8, %rcx
xorl %edx, %edx
movq 0x40(%rsp), %rbp
cmpq $0x0, (%rcx,%rdx,8)
jne 0x20568
decq %rdx
cmpq %rdx, %rax
jne 0x20525
leaq (%r15,%r14,8), %rsi
movq 0x28(%rsp), %rax
leaq (%r15,%rax,8), %rax
addq $-0x8, %rax
movq %rbp, %rcx
testq %rcx, %rcx
jle 0x20568
leaq -0x1(%rcx), %rdx
movq (%rax), %r8
addq $-0x8, %rax
cmpq %r8, -0x8(%r15,%rcx,8)
movq %rdx, %rcx
je 0x20548
jbe 0x20686
testq %rbp, %rbp
je 0x20625
leaq (%r15,%r14,8), %rdx
movq %r15, %rsi
movq %rbp, %rcx
callq 0x1bca0
movq 0x18(%rsp), %rdi
movq %rbp, %rcx
testq %rax, %rax
movq 0x10(%rsp), %r13
je 0x2062c
movq 0x28(%rsp), %rax
leaq (,%rax,8), %rax
addq %r13, %rax
movq %rbp, %rcx
cmpq %r14, %rcx
jge 0x206bc
movq (%r15,%rcx,8), %rdx
incq %rcx
subq $0x1, %rdx
movq %rdx, (%rax)
leaq 0x8(%rax), %rax
jb 0x205a9
jmp 0x2062c
leaq (%r9,%rbp,8), %rax
addq $-0x8, %rax
movq %rcx, %r8
testq %r8, %r8
jle 0x2045d
leaq -0x1(%r8), %rsi
movq (%rax), %rdi
addq $-0x8, %rax
cmpq %rdi, -0x8(%r9,%r8,8)
movq %rsi, %r8
je 0x205d3
ja 0x2045d
movq 0x10(%rsp), %r13
movq %r13, %rdi
movq %rdx, %rsi
movq %r9, %rdx
callq 0x1bca0
movq 0x20(%rsp), %rsi
movq $0x0, (%r13,%rsi,8)
movl $0x1, 0xc(%rsp)
jmp 0x20482
xorl %ecx, %ecx
movq 0x10(%rsp), %r13
cmpq %r15, %rdi
setne %al
cmpq %r14, %rcx
setl %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x206bc
movq (%r15,%rcx,8), %rax
movq %rax, (%rdi,%rcx,8)
incq %rcx
cmpq %rcx, %r14
jne 0x2063f
jmp 0x206bc
movq %r13, %rdi
movq %rdx, %rsi
movq %r9, %rdx
callq 0x1bca0
movq 0x20(%rsp), %rsi
movl $0x1, 0xc(%rsp)
jmp 0x20487
movq %rdx, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1bca0
xorl $0x1, 0xc(%rsp)
jmp 0x206bc
movq %r15, %rdx
movq %rbp, %rcx
callq 0x1bca0
testq %r13, %r13
je 0x206b2
movq 0x10(%rsp), %rax
movq 0x28(%rsp), %rcx
leaq (%rax,%rcx,8), %rdi
shlq $0x3, %r13
xorl %esi, %esi
movq %r13, %rdx
callq 0x6170
xorl $0x1, 0xc(%rsp)
movq 0x10(%rsp), %r13
cmpq $0x1b, %r14
jle 0x206e4
movq %r14, %r9
shlq $0x4, %r9
addq %rbx, %r9
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq 0x18(%rsp), %rcx
movq %r14, %r8
callq 0x203ac
jmp 0x206fa
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq 0x18(%rsp), %rcx
movq %r14, %r8
callq 0x1d680
movq 0x20(%rsp), %r8
cmpq %rbp, %r8
movq 0x38(%rsp), %rcx
jle 0x20749
cmpq $0x1b, %rbp
jle 0x2076f
leaq (,%r8,4), %rax
leaq (,%rbp,4), %rdx
addq %rbp, %rdx
movq %r14, %r9
shlq $0x4, %r9
leaq (%r9,%r13), %rdi
addq %rbx, %r9
leaq (%rcx,%r14,8), %rsi
leaq (%r15,%r14,8), %rcx
cmpq %rdx, %rax
jge 0x208df
movq %r8, %rdx
movq %rbp, %r8
jmp 0x20768
leaq (%rcx,%r14,8), %rsi
leaq (%r15,%r14,8), %rcx
cmpq $0x1b, %r8
jle 0x20789
movq %r14, %r9
shlq $0x4, %r9
leaq (%r9,%r13), %rdi
addq %rbx, %r9
movq %r8, %rdx
callq 0x203ac
jmp 0x2079b
movq %r14, %rdi
shlq $0x4, %rdi
addq %r13, %rdi
leaq (%rcx,%r14,8), %rsi
leaq (%r15,%r14,8), %rcx
movq %r8, %rdx
movq %rbp, %r8
jmp 0x20796
movq %r14, %rdi
shlq $0x4, %rdi
addq %r13, %rdi
movq %r8, %rdx
callq 0x1d680
cmpq $0x1b, %r14
jle 0x207c3
movq %r14, %r9
shlq $0x4, %r9
addq %rbx, %r9
movq %r13, %rdi
movq 0x38(%rsp), %rsi
movq %r14, %rdx
movq %r15, %rcx
movq %r14, %r8
callq 0x203ac
jmp 0x207d9
movq %r13, %rdi
movq 0x38(%rsp), %rsi
movq %r14, %rdx
movq %r15, %rcx
movq %r14, %r8
callq 0x1d680
movq %r14, %rbx
shlq $0x4, %rbx
addq %r13, %rbx
movq %rbx, %rdi
movq 0x18(%rsp), %r15
movq %r15, %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x1ba80
movq %r13, %rdx
movq %rax, %r13
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rcx
callq 0x1ba80
movq %rax, %r15
addq %rbp, %r12
je 0x20859
leaq (%rbx,%r14,8), %rdx
movq %rbx, %rdi
movq %rbx, %rsi
movq %r12, %rcx
callq 0x1ba80
testq %rax, %rax
je 0x20859
movq 0x20(%rsp), %rcx
addq 0x28(%rsp), %rcx
movq 0x10(%rsp), %rax
leaq (%rax,%rcx,8), %rax
xorl %ebp, %ebp
movq 0x18(%rsp), %rdi
cmpq %r14, %r12
jge 0x20862
incq %r12
incq (%rax)
leaq 0x8(%rax), %rax
je 0x20846
jmp 0x20867
xorl %ebp, %ebp
movq 0x18(%rsp), %rdi
jmp 0x20867
movl $0x1, %ebp
leaq (%r14,%r14), %rcx
addq %r13, %r15
addq %r13, %rbp
cmpl $0x0, 0xc(%rsp)
je 0x2088a
movq %rdi, %rsi
movq 0x30(%rsp), %rdx
callq 0x1ba80
addq %rbp, %rax
jmp 0x2089d
movq %rdi, %rsi
movq 0x30(%rsp), %rdx
callq 0x1bca0
subq %rax, %rbp
movq %rbp, %rax
movq 0x10(%rsp), %rdx
addq %r15, (%rbx)
jae 0x208b2
addq $0x1, 0x8(%rbx)
leaq 0x8(%rbx), %rbx
jb 0x208a7
leaq (%r14,%r14,2), %rcx
leaq (%rdx,%rcx,8), %rcx
cmpq $0x2, %rax
ja 0x208ef
addq %rax, (%rcx)
jae 0x208d0
addq $0x1, 0x8(%rcx)
leaq 0x8(%rcx), %rcx
jb 0x208c5
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r8, %rdx
movq %rbp, %r8
callq 0x66de
jmp 0x2079b
subq $0x1, (%rcx)
leaq 0x8(%rcx), %rcx
jb 0x208ef
jmp 0x208d0
nop