// File: /workspace/github_cpp_makefile_star2_O2/marxn[P]pupp/3rdparty/gmp/mpn/toom42_mul.c
// Function: _gmpn_toom42_mul
void
mpn_toom42_mul (mp_ptr pp,
		mp_srcptr ap, mp_size_t an,
		mp_srcptr bp, mp_size_t bn,
		mp_ptr scratch)
{
  mp_size_t n, s, t;
  int vm1_neg;
  mp_limb_t cy, vinf0;
  mp_ptr a0_a2;
  mp_ptr as1, asm1, as2;
  mp_ptr bs1, bsm1, bs2;
  mp_ptr tmp;
  TMP_DECL;

#define a0  ap
#define a1  (ap + n)
#define a2  (ap + 2*n)
#define a3  (ap + 3*n)
#define b0  bp
#define b1  (bp + n)

  n = an >= 2 * bn ? (an + 3) >> 2 : (bn + 1) >> 1;

  s = an - 3 * n;
  t = bn - n;

  ASSERT (0 < s && s <= n);
  ASSERT (0 < t && t <= n);

  TMP_MARK;

  tmp = TMP_ALLOC_LIMBS (6 * n + 5);
  as1  = tmp; tmp += n + 1;
  asm1 = tmp; tmp += n + 1;
  as2  = tmp; tmp += n + 1;
  bs1  = tmp; tmp += n + 1;
  bsm1 = tmp; tmp += n;
  bs2  = tmp; tmp += n + 1;

  a0_a2 = pp;

  /* Compute as1 and asm1.  */
  vm1_neg = mpn_toom_eval_dgr3_pm1 (as1, asm1, ap, n, s, a0_a2) & 1;

  /* Compute as2.  */
#if HAVE_NATIVE_mpn_addlsh1_n
  cy  = mpn_addlsh1_n (as2, a2, a3, s);
  if (s != n)
    cy = mpn_add_1 (as2 + s, a2 + s, n - s, cy);
  cy = 2 * cy + mpn_addlsh1_n (as2, a1, as2, n);
  cy = 2 * cy + mpn_addlsh1_n (as2, a0, as2, n);
#else
  cy  = mpn_lshift (as2, a3, s, 1);
  cy += mpn_add_n (as2, a2, as2, s);
  if (s != n)
    cy = mpn_add_1 (as2 + s, a2 + s, n - s, cy);
  cy = 2 * cy + mpn_lshift (as2, as2, n, 1);
  cy += mpn_add_n (as2, a1, as2, n);
  cy = 2 * cy + mpn_lshift (as2, as2, n, 1);
  cy += mpn_add_n (as2, a0, as2, n);
#endif
  as2[n] = cy;

  /* Compute bs1 and bsm1.  */
  if (t == n)
    {
#if HAVE_NATIVE_mpn_add_n_sub_n
      if (mpn_cmp (b0, b1, n) < 0)
	{
	  cy = mpn_add_n_sub_n (bs1, bsm1, b1, b0, n);
	  vm1_neg ^= 1;
	}
      else
	{
	  cy = mpn_add_n_sub_n (bs1, bsm1, b0, b1, n);
	}
      bs1[n] = cy >> 1;
#else
      bs1[n] = mpn_add_n (bs1, b0, b1, 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);
	}
#endif
    }
  else
    {
      bs1[n] = mpn_add (bs1, b0, n, b1, t);

      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);
	}
    }

  /* Compute bs2, recycling bs1. bs2=bs1+b1  */
  mpn_add (bs2, bs1, n + 1, b1, t);

  ASSERT (as1[n] <= 3);
  ASSERT (bs1[n] <= 1);
  ASSERT (asm1[n] <= 1);
/*ASSERT (bsm1[n] == 0);*/
  ASSERT (as2[n] <= 14);
  ASSERT (bs2[n] <= 2);

#define v0    pp				/* 2n */
#define v1    (pp + 2 * n)			/* 2n+1 */
#define vinf  (pp + 4 * n)			/* s+t */
#define vm1   scratch				/* 2n+1 */
#define v2    (scratch + 2 * n + 1)		/* 2n+2 */
#define scratch_out	scratch + 4 * n + 4	/* Currently unused. */

  /* vm1, 2n+1 limbs */
  TOOM42_MUL_N_REC (vm1, asm1, bsm1, n, scratch_out);
  cy = 0;
  if (asm1[n] != 0)
    cy = mpn_add_n (vm1 + n, vm1 + n, bsm1, n);
  vm1[2 * n] = cy;

  TOOM42_MUL_N_REC (v2, as2, bs2, n + 1, scratch_out);	/* v2, 2n+1 limbs */

  /* vinf, s+t limbs */
  if (s > t)  mpn_mul (vinf, a3, s, b1, t);
  else        mpn_mul (vinf, b1, t, a3, s);

  vinf0 = vinf[0];				/* v1 overlaps with this */

  /* v1, 2n+1 limbs */
  TOOM42_MUL_N_REC (v1, as1, bs1, n, scratch_out);
  if (as1[n] == 1)
    {
      cy = bs1[n] + mpn_add_n (v1 + n, v1 + n, bs1, n);
    }
  else if (as1[n] == 2)
    {
#if HAVE_NATIVE_mpn_addlsh1_n
      cy = 2 * bs1[n] + mpn_addlsh1_n (v1 + n, v1 + n, bs1, n);
#else
      cy = 2 * bs1[n] + mpn_addmul_1 (v1 + n, bs1, n, CNST_LIMB(2));
#endif
    }
  else if (as1[n] == 3)
    {
      cy = 3 * bs1[n] + mpn_addmul_1 (v1 + n, bs1, n, CNST_LIMB(3));
    }
  else
    cy = 0;
  if (bs1[n] != 0)
    cy += mpn_add_n (v1 + n, v1 + n, as1, n);
  v1[2 * n] = cy;

  TOOM42_MUL_N_REC (v0, ap, bp, n, scratch_out);	/* v0, 2n limbs */

  mpn_toom_interpolate_5pts (pp, v2, vm1, n, s + t, vm1_neg, vinf0);

  TMP_FREE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %r9, -0x60(%rbp)
movq %r8, %rbx
movq %rcx, -0x98(%rbp)
movq %rsi, -0x70(%rbp)
movq %rdi, -0x68(%rbp)
leaq (%r8,%r8), %rax
leaq 0x3(%rdx), %rcx
sarq $0x2, %rcx
leaq 0x1(%r8), %r12
sarq %r12
cmpq %rdx, %rax
cmovleq %rcx, %r12
leaq (%r12,%r12,2), %rcx
andq $0x0, -0xa0(%rbp)
movq %rcx, -0x30(%rbp)
subq %rcx, %rdx
movq %rdx, -0x90(%rbp)
imulq $0x30, %r12, %rsi
addq $0x28, %rsi
cmpq $0x7f00, %rsi           # imm = 0x7F00
ja 0x1d2bf
movq %rsp, %rdi
addq $0xf, %rsi
andq $-0x10, %rsi
subq %rsi, %rdi
movq %rdi, %rsp
movq %rbx, -0xb0(%rbp)
subq %r12, %rbx
movq %rbx, -0x58(%rbp)
leaq (%rdi,%r12,8), %rsi
addq $0x8, %rsi
leaq 0x8(%rsi,%r12,8), %r15
leaq 0x8(%r15,%r12,8), %rax
movq %rax, -0x38(%rbp)
leaq 0x8(%rax,%r12,8), %rax
movq %rax, -0x50(%rbp)
movq %rdi, -0x80(%rbp)
movq %rsi, -0xb8(%rbp)
movq -0x70(%rbp), %r14
movq %r14, %rdx
movq %r12, %rcx
movq -0x90(%rbp), %rbx
movq %rbx, %r8
movq -0x68(%rbp), %r9
callq 0x22648
movl %eax, -0x3c(%rbp)
movq %r12, %rax
shlq $0x4, %rax
movq %rax, -0xa8(%rbp)
leaq (%r14,%rax), %r13
movq -0x30(%rbp), %rax
leaq (%r14,%rax,8), %rdx
movq %rbx, %r14
movq %r15, %rdi
movq %r13, %rsi
movq %rdx, -0x78(%rbp)
movq %rbx, %rcx
callq 0x291c0
movq %rax, %rbx
movq %r12, %rdx
subq %r14, %rdx
je 0x1cf34
leaq (%r15,%r14,8), %rdi
leaq (,%r14,8), %rsi
addq %r13, %rsi
movq %rbx, %rcx
callq 0x29e1c
movq %rax, %rbx
leaq 0x1(%r12), %rax
movq %rax, -0x48(%rbp)
movq -0x50(%rbp), %rax
leaq (%rax,%r12,8), %rax
movq %rax, -0x88(%rbp)
andl $0x1, -0x3c(%rbp)
movq -0x70(%rbp), %r14
leaq (%r14,%r12,8), %rsi
movq %r15, %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0x291c0
shlq $0x2, %rbx
leaq (%rbx,%rax,2), %rbx
movq %r15, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x291c0
addq %rbx, %rax
movq %r15, -0xc0(%rbp)
movq %rax, (%r15,%r12,8)
movq %r12, %rbx
movq -0x98(%rbp), %r13
leaq (,%r12,8), %rax
addq %r13, %rax
movq -0x58(%rbp), %r14
subq %r14, %rbx
movq %rax, -0x30(%rbp)
jne 0x1d003
movq -0x38(%rbp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
movq %rax, %r14
movq %r12, %rcx
callq 0x17cf0
movq %rax, (%rbx,%r12,8)
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x1ac5c
testl %eax, %eax
movq -0x60(%rbp), %rbx
js 0x1d067
movq -0x50(%rbp), %r15
movq %r15, %rdi
movq %r13, %rsi
movq -0x30(%rbp), %r13
movq %r13, %rdx
movq %r12, %rcx
callq 0x17ed0
jmp 0x1d084
movq -0x38(%rbp), %r15
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %rax, %rcx
movq %r14, %r8
callq 0x17c54
movq %rax, (%r15,%r12,8)
leaq (,%r14,8), %rdi
addq %r13, %rdi
movq %rbx, %rsi
callq 0x2b954
testl %eax, %eax
je 0x1d049
movq %r13, %rdi
movq -0x30(%rbp), %rsi
movq %r14, %rdx
callq 0x1ac5c
testl %eax, %eax
js 0x1d08a
movq -0x50(%rbp), %r15
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq -0x30(%rbp), %r13
movq %r13, %rcx
movq %r14, %r8
callq 0x17dc8
jmp 0x1d0c7
movq -0x50(%rbp), %r15
movq %r15, %rdi
movq -0x30(%rbp), %rsi
movq %r13, %rdx
movq %rsi, %r13
movq %r12, %rcx
callq 0x17ed0
xorl $0x1, -0x3c(%rbp)
movq -0x58(%rbp), %r8
jmp 0x1d0ce
movq -0x50(%rbp), %r15
movq %r15, %rdi
movq -0x30(%rbp), %rsi
movq %r13, %rdx
movq %rsi, %r13
movq %r14, %rcx
callq 0x17ed0
leaq (%r15,%r14,8), %rdi
movq -0xb0(%rbp), %rax
shlq $0x3, %rax
movq -0xa8(%rbp), %rdx
subq %rax, %rdx
xorl %esi, %esi
callq 0x6170
xorl $0x1, -0x3c(%rbp)
movq -0x60(%rbp), %rbx
movq %r14, %r8
leaq (%r12,%r12), %r14
movq -0x88(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq %r13, %rcx
callq 0x17c54
movq %rbx, %rdi
movq -0xb8(%rbp), %r13
movq %r13, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x19500
cmpq $0x0, (%r13,%r12,8)
je 0x1d11d
leaq (%rbx,%r12,8), %rdi
movq %rdi, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x17cf0
jmp 0x1d11f
xorl %eax, %eax
movq %r14, %r13
leaq (%rbx,%r14,8), %rdi
addq $0x8, %rdi
movq %rax, -0x8(%rdi)
movq %rdi, -0x50(%rbp)
movq -0xc0(%rbp), %rsi
movq -0x88(%rbp), %rdx
movq -0x48(%rbp), %rcx
callq 0x19500
movq %r12, %rbx
shlq $0x5, %rbx
movq -0x68(%rbp), %rax
leaq (%rax,%rbx), %rdi
movq -0x58(%rbp), %r8
movq -0x90(%rbp), %r14
cmpq %r8, %r14
jle 0x1d175
movq -0x78(%rbp), %rsi
movq %r14, %rdx
movq -0x30(%rbp), %rcx
jmp 0x1d183
movq -0x30(%rbp), %rsi
movq %r8, %rdx
movq -0x78(%rbp), %rcx
movq %r14, %r8
callq 0x18a58
movq -0x68(%rbp), %rax
movq (%rax,%rbx), %rcx
movq %rcx, -0x30(%rbp)
leaq (%rax,%r13,8), %rbx
movq %rbx, %rdi
movq -0x80(%rbp), %r15
movq %r15, %rsi
movq -0x38(%rbp), %rdx
movq %r12, %rcx
callq 0x19500
movq (%r15,%r12,8), %rax
cmpq $0x3, %rax
je 0x1d214
cmpq $0x2, %rax
je 0x1d1e9
cmpq $0x1, %rax
movq -0x38(%rbp), %rcx
jne 0x1d23f
movq (%rcx,%r12,8), %rax
movq %rax, -0x48(%rbp)
leaq (%rbx,%r12,8), %rdi
movq %rdi, %rsi
movq -0x38(%rbp), %rdx
movq %r12, %rcx
callq 0x17cf0
movq -0x38(%rbp), %rcx
jmp 0x1d236
movq -0x38(%rbp), %r15
movq (%r15,%r12,8), %rax
movq %rax, -0x48(%rbp)
leaq (%rbx,%r12,8), %rdi
movq %rdi, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x291c0
movq %r15, %rcx
movq -0x48(%rbp), %rdx
leaq (%rax,%rdx,2), %r15
jmp 0x1d242
movq -0x38(%rbp), %r15
imulq $0x3, (%r15,%r12,8), %rax
movq %rax, -0x48(%rbp)
leaq (%rbx,%r12,8), %rdi
pushq $0x3
popq %rcx
movq %r15, %rsi
movq %r12, %rdx
callq 0x29e80
movq %r15, %rcx
movq %rax, %r15
addq -0x48(%rbp), %r15
jmp 0x1d242
xorl %r15d, %r15d
cmpq $0x0, (%rcx,%r12,8)
je 0x1d25f
leaq (%rbx,%r12,8), %rdi
movq %rdi, %rsi
movq -0x80(%rbp), %rdx
movq %r12, %rcx
callq 0x17cf0
addq %rax, %r15
movq %r15, (%rbx,%r13,8)
movq -0x68(%rbp), %rbx
movq %rbx, %rdi
movq -0x70(%rbp), %rsi
movq -0x98(%rbp), %rdx
movq %r12, %rcx
callq 0x19500
addq -0x58(%rbp), %r14
subq $0x8, %rsp
movq %rbx, %rdi
movq -0x50(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq %r12, %rcx
movq %r14, %r8
movl -0x3c(%rbp), %r9d
pushq -0x30(%rbp)
callq 0x22e58
popq %rax
popq %rcx
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
jne 0x1d2d3
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0xa0(%rbp), %rdi
callq 0x29dc0
movq %rax, %rdi
jmp 0x1ce88
callq 0x29df3
jmp 0x1d2b0
nop