// File: /workspace/github_cpp_makefile_star2_O2/marxn[P]pupp/3rdparty/gmp/mpn/toom43_mul.c
// Function: _gmpn_toom43_mul
void
mpn_toom43_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;
  enum toom6_flags flags;
  mp_limb_t cy;

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

  n = 1 + (3 * an >= 4 * bn ? (an - 1) >> 2 : (bn - 1) / (size_t) 3);

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

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

  /* This is true whenever an >= 25 or bn >= 19, I think. It
     guarantees that we can fit 5 values of size n+1 in the product
     area. */
  ASSERT (s+t >= 5);

#define v0    pp				/* 2n */
#define vm1   (scratch)				/* 2n+1 */
#define v1    (pp + 2*n)			/* 2n+1 */
#define vm2   (scratch + 2 * n + 1)		/* 2n+1 */
#define v2    (scratch + 4 * n + 2)		/* 2n+1 */
#define vinf  (pp + 5 * n)			/* s+t */
#define bs1    pp				/* n+1 */
#define bsm1  (scratch + 2 * n + 2)		/* n+1 */
#define asm1  (scratch + 3 * n + 3)		/* n+1 */
#define asm2  (scratch + 4 * n + 4)		/* n+1 */
#define bsm2  (pp + n + 1)			/* n+1 */
#define bs2   (pp + 2 * n + 2)			/* n+1 */
#define as2   (pp + 3 * n + 3)			/* n+1 */
#define as1   (pp + 4 * n + 4)			/* n+1 */

  /* Total sccratch need is 6 * n + 3 + 1; we allocate one extra
     limb, because products will overwrite 2n+2 limbs. */

#define a0a2  scratch
#define b0b2  scratch
#define a1a3  asm1
#define b1d   bsm1

  /* Compute as2 and asm2.  */
  flags = (enum toom6_flags) (toom6_vm2_neg & mpn_toom_eval_dgr3_pm2 (as2, asm2, ap, n, s, a1a3));

  /* Compute bs2 and bsm2.  */
  b1d[n] = mpn_lshift (b1d, b1, n, 1);			/*       2b1      */
  cy  = mpn_lshift (b0b2, b2, t, 2);			/*  4b2           */
  cy += mpn_add_n (b0b2, b0b2, b0, t);			/*  4b2      + b0 */
  if (t != n)
    cy = mpn_add_1 (b0b2 + t, b0 + t, n - t, cy);
  b0b2[n] = cy;

#if HAVE_NATIVE_mpn_add_n_sub_n
  if (mpn_cmp (b0b2, b1d, n+1) < 0)
    {
      mpn_add_n_sub_n (bs2, bsm2, b1d, b0b2, n+1);
      flags = (enum toom6_flags) (flags ^ toom6_vm2_neg);
    }
  else
    {
      mpn_add_n_sub_n (bs2, bsm2, b0b2, b1d, n+1);
    }
#else
  mpn_add_n (bs2, b0b2, b1d, n+1);
  if (mpn_cmp (b0b2, b1d, n+1) < 0)
    {
      mpn_sub_n (bsm2, b1d, b0b2, n+1);
      flags = (enum toom6_flags) (flags ^ toom6_vm2_neg);
    }
  else
    {
      mpn_sub_n (bsm2, b0b2, b1d, n+1);
    }
#endif

  /* Compute as1 and asm1.  */
  flags = (enum toom6_flags) (flags ^ (toom6_vm1_neg & mpn_toom_eval_dgr3_pm1 (as1, asm1, ap, n, s, a0a2)));

  /* Compute bs1 and bsm1.  */
  bsm1[n] = mpn_add (bsm1, b0, n, b2, t);
#if HAVE_NATIVE_mpn_add_n_sub_n
  if (bsm1[n] == 0 && mpn_cmp (bsm1, b1, n) < 0)
    {
      cy = mpn_add_n_sub_n (bs1, bsm1, b1, bsm1, n);
      bs1[n] = cy >> 1;
      flags = (enum toom6_flags) (flags ^ toom6_vm1_neg);
    }
  else
    {
      cy = mpn_add_n_sub_n (bs1, bsm1, bsm1, b1, n);
      bs1[n] = bsm1[n] + (cy >> 1);
      bsm1[n]-= cy & 1;
    }
#else
  bs1[n] = bsm1[n] + mpn_add_n (bs1, bsm1, b1, n);
  if (bsm1[n] == 0 && mpn_cmp (bsm1, b1, n) < 0)
    {
      mpn_sub_n (bsm1, b1, bsm1, n);
      flags = (enum toom6_flags) (flags ^ toom6_vm1_neg);
    }
  else
    {
      bsm1[n] -= mpn_sub_n (bsm1, bsm1, b1, n);
    }
#endif

  ASSERT (as1[n] <= 3);
  ASSERT (bs1[n] <= 2);
  ASSERT (asm1[n] <= 1);
  ASSERT (bsm1[n] <= 1);
  ASSERT (as2[n] <=14);
  ASSERT (bs2[n] <= 6);
  ASSERT (asm2[n] <= 9);
  ASSERT (bsm2[n] <= 4);

  /* vm1, 2n+1 limbs */
  mpn_mul_n (vm1, asm1, bsm1, n+1);  /* W4 */

  /* vm2, 2n+1 limbs */
  mpn_mul_n (vm2, asm2, bsm2, n+1);  /* W2 */

  /* v2, 2n+1 limbs */
  mpn_mul_n (v2, as2, bs2, n+1);  /* W1 */

  /* v1, 2n+1 limbs */
  mpn_mul_n (v1, as1, bs1, n+1);  /* W3 */

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

  /* v0, 2n limbs */
  mpn_mul_n (v0, ap, bp, n);  /* W5 */

  mpn_toom_interpolate_6pts (pp, n, flags, vm1, vm2, v2, t + s);

#undef v0
#undef vm1
#undef v1
#undef vm2
#undef v2
#undef vinf
#undef bs1
#undef bs2
#undef bsm1
#undef bsm2
#undef asm1
#undef asm2
/* #undef as1 */
/* #undef as2 */
#undef a0a2
#undef b0b2
#undef a1a3
#undef b1d
#undef a0
#undef a1
#undef a2
#undef a3
#undef b0
#undef b1
#undef b2
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %r9, %rbx
movq %rcx, 0x58(%rsp)
movq %rdx, %r11
movq %rsi, %r10
movq %rdi, 0x18(%rsp)
leaq (%rdx,%rdx,2), %rax
leaq (,%r8,4), %rcx
cmpq %rcx, %rax
jge 0x1d822
leaq -0x1(%r8), %rax
pushq $0x3
popq %rcx
xorl %edx, %edx
divq %rcx
movq %rax, %r14
jmp 0x1d82a
leaq -0x1(%r11), %r14
sarq $0x2, %r14
leaq 0x1(%r14), %r12
leaq (%r12,%r12,2), %rcx
subq %rcx, %r11
leaq 0x2(,%r14,2), %rdx
movq %rdx, 0x10(%rsp)
subq %rdx, %r8
movq %r8, 0x20(%rsp)
movq 0x18(%rsp), %rax
leaq (%rax,%rcx,8), %rdi
addq $0x18, %rdi
movq %r12, %rax
shlq $0x5, %rax
movq %rax, 0x68(%rsp)
leaq (%rbx,%rax), %rsi
addq $0x20, %rsi
movq %rcx, 0xb0(%rsp)
leaq 0x18(%rbx,%rcx,8), %r9
movq %rdi, 0xa8(%rsp)
movq %rsi, 0xa0(%rsp)
movq %r10, 0x70(%rsp)
movq %r10, %rdx
movq %r12, %rcx
movq %r11, 0x78(%rsp)
movq %r11, %r8
movq %r9, 0x60(%rsp)
callq 0x226f4
movl %eax, 0x30(%rsp)
movq %r12, %r13
shlq $0x4, %r13
leaq (%rbx,%r13), %rbp
leaq (%rbx,%r13), %rdi
addq $0x10, %rdi
movq 0x58(%rsp), %r15
leaq 0x8(%r15,%r14,8), %rsi
pushq $0x1
popq %rcx
movq %rdi, 0x38(%rsp)
movq %rsi, 0x90(%rsp)
movq %r12, %rdx
callq 0x181a0
movq %rbp, 0x48(%rsp)
movq %r14, 0x98(%rsp)
movq %rax, 0x18(%rbp,%r14,8)
addq %r15, %r13
pushq $0x2
popq %rcx
movq %rbx, %rdi
movq %r13, 0x40(%rsp)
movq %r13, %rsi
movq 0x20(%rsp), %rdx
callq 0x181a0
movq %rax, %rbp
movq %rbx, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq 0x20(%rsp), %rcx
callq 0x17cf0
movq 0x20(%rsp), %rcx
addq %rbp, %rax
movq %r12, 0x50(%rsp)
subq %rcx, %r12
je 0x1d946
leaq (%rbx,%rcx,8), %rdi
leaq (%r15,%rcx,8), %rsi
movq %r12, %rdx
movq %rax, %rcx
callq 0x29e1c
movq 0x98(%rsp), %r12
leaq 0x4(,%r12,4), %rcx
movq %rcx, 0x28(%rsp)
movl 0x30(%rsp), %r13d
andl $0x2, %r13d
movq %rax, 0x8(%rbx,%r12,8)
movq 0x18(%rsp), %r15
movq 0x10(%rsp), %rax
leaq (%r15,%rax,8), %rdi
addq $0x10, %rdi
leaq 0x2(%r12), %r14
movq %rdi, 0x88(%rsp)
movq %rbx, %rsi
movq 0x38(%rsp), %rbp
movq %rbp, %rdx
movq %r14, %rcx
callq 0x17cf0
movq %rbx, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x1ac5c
movq 0x50(%rsp), %rcx
leaq (%r15,%rcx,8), %rdi
addq $0x8, %rdi
testl %eax, %eax
movq %r14, 0x30(%rsp)
js 0x1d9cf
movq %rbx, %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x17ed0
jmp 0x1d9e1
movq %rbp, %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x17ed0
xorl $0x2, %r13d
movl %r13d, %r14d
addq %rbx, 0x68(%rsp)
movq 0x18(%rsp), %r15
movq 0x10(%rsp), %rax
leaq (%r15,%rax,8), %rax
movq %rax, 0x80(%rsp)
movq 0x28(%rsp), %rax
leaq 0x20(%r15,%rax,8), %rdi
movq %rdi, 0x28(%rsp)
movq 0x60(%rsp), %rsi
movq 0x70(%rsp), %rdx
movq 0x50(%rsp), %r13
movq %r13, %rcx
movq 0x78(%rsp), %r8
movq %rbx, 0x38(%rsp)
movq %rbx, %r9
callq 0x22648
andl $0x1, %eax
xorl %r14d, %eax
movl %eax, 0x10(%rsp)
movq %rbp, %rdi
movq 0x58(%rsp), %rsi
movq %r13, %rdx
movq 0x40(%rsp), %rcx
movq 0x20(%rsp), %r8
callq 0x17c54
movq %rax, %r14
movq %rax, 0x8(%rbp,%r12,8)
movq %r15, %rdi
movq %rbp, %rsi
movq 0x90(%rsp), %rbx
movq %rbx, %rdx
movq %r13, %rcx
callq 0x17cf0
addq %r14, %rax
leaq (%r15,%r13,8), %r14
movq %rax, 0x8(%r15,%r12,8)
movq %r13, %r15
cmpq $0x0, 0x8(%rbp,%r12,8)
jne 0x1daa4
movq %rbp, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1ac5c
testl %eax, %eax
js 0x1dbdb
movq %rbp, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x17ed0
subq %rax, 0x8(%rbp,%r12,8)
movq 0x38(%rsp), %rbx
movq %rbx, %rdi
movq 0x60(%rsp), %rsi
movq %rbp, %rdx
movq 0x30(%rsp), %r12
movq %r12, %rcx
callq 0x19500
movq 0x48(%rsp), %rdi
addq $0x8, %rdi
addq $0x8, %r14
movq %rdi, 0x48(%rsp)
movq 0xa0(%rsp), %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0x19500
movq 0x68(%rsp), %rdi
addq $0x10, %rdi
movq %rdi, %rbp
movq 0xa8(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq %r12, %rcx
callq 0x19500
movq 0x80(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x18(%rsp), %r14
movq %r14, %rdx
movq %r12, %rcx
callq 0x19500
imulq $0x28, %r15, %rdi
addq %r14, %rdi
movq 0xb0(%rsp), %rax
movq 0x70(%rsp), %r13
leaq (,%rax,8), %rcx
addq %r13, %rcx
movq 0x20(%rsp), %r14
movq 0x78(%rsp), %r12
cmpq %r14, %r12
jle 0x1db7b
movq %rcx, %rsi
movq %r12, %rdx
movq 0x40(%rsp), %rcx
movq %r14, %r8
jmp 0x1db86
movq 0x40(%rsp), %rsi
movq %r14, %rdx
movq %r12, %r8
callq 0x18a58
movq 0x18(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
movq 0x58(%rsp), %rdx
movq 0x50(%rsp), %r13
movq %r13, %rcx
callq 0x19500
addq %r12, %r14
movq %r14, (%rsp)
movq %r15, %rdi
movq %r13, %rsi
movl 0x10(%rsp), %edx
movq %rbx, %rcx
movq 0x48(%rsp), %r8
movq %rbp, %r9
callq 0x2309c
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbp, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq %r15, %rcx
callq 0x17ed0
xorl $0x1, 0x10(%rsp)
jmp 0x1daba
nop