// File: /workspace/github_cpp_makefile_star2_O1/marxn[P]pupp/3rdparty/gmp/mpn/mul_fft.c
// Function: _gmpn_mul_fft
mp_limb_t
mpn_mul_fft (mp_ptr op, mp_size_t pl,
	     mp_srcptr n, mp_size_t nl,
	     mp_srcptr m, mp_size_t ml,
	     int k)
{
  int i;
  mp_size_t K, maxLK;
  mp_size_t N, Nprime, nprime, M, Mp, l;
  mp_ptr *Ap, *Bp, A, T, B;
  int **fft_l, *tmp;
  int sqr = (n == m && nl == ml);
  mp_limb_t h;
  TMP_DECL;

  TRACE (printf ("\nmpn_mul_fft pl=%ld nl=%ld ml=%ld k=%d\n", pl, nl, ml, k));
  ASSERT_ALWAYS (mpn_fft_next_size (pl, k) == pl);

  TMP_MARK;
  N = pl * GMP_NUMB_BITS;
  fft_l = TMP_BALLOC_TYPE (k + 1, int *);
  tmp = TMP_BALLOC_TYPE ((size_t) 2 << k, int);
  for (i = 0; i <= k; i++)
    {
      fft_l[i] = tmp;
      tmp += (mp_size_t) 1 << i;
    }

  mpn_fft_initl (fft_l, k);
  K = (mp_size_t) 1 << k;
  M = N >> k;	/* N = 2^k M */
  l = 1 + (M - 1) / GMP_NUMB_BITS;
  maxLK = mpn_mul_fft_lcm (GMP_NUMB_BITS, k); /* lcm (GMP_NUMB_BITS, 2^k) */

  Nprime = (1 + (2 * M + k + 2) / maxLK) * maxLK;
  /* Nprime = ceil((2*M+k+3)/maxLK)*maxLK; */
  nprime = Nprime / GMP_NUMB_BITS;
  TRACE (printf ("N=%ld K=%ld, M=%ld, l=%ld, maxLK=%ld, Np=%ld, np=%ld\n",
		 N, K, M, l, maxLK, Nprime, nprime));
  /* we should ensure that recursively, nprime is a multiple of the next K */
  if (nprime >= (sqr ? SQR_FFT_MODF_THRESHOLD : MUL_FFT_MODF_THRESHOLD))
    {
      mp_size_t K2;
      for (;;)
	{
	  K2 = (mp_size_t) 1 << mpn_fft_best_k (nprime, sqr);
	  if ((nprime & (K2 - 1)) == 0)
	    break;
	  nprime = (nprime + K2 - 1) & -K2;
	  Nprime = nprime * GMP_LIMB_BITS;
	  /* warning: since nprime changed, K2 may change too! */
	}
      TRACE (printf ("new maxLK=%ld, Np=%ld, np=%ld\n", maxLK, Nprime, nprime));
    }
  ASSERT_ALWAYS (nprime < pl); /* otherwise we'll loop */

  T = TMP_BALLOC_LIMBS (2 * (nprime + 1));
  Mp = Nprime >> k;

  TRACE (printf ("%ldx%ld limbs -> %ld times %ldx%ld limbs (%1.2f)\n",
		pl, pl, K, nprime, nprime, 2.0 * (double) N / Nprime / K);
	 printf ("   temp space %ld\n", 2 * K * (nprime + 1)));

  A = TMP_BALLOC_LIMBS (K * (nprime + 1));
  Ap = TMP_BALLOC_MP_PTRS (K);
  mpn_mul_fft_decompose (A, Ap, K, nprime, n, nl, l, Mp, T);
  if (sqr)
    {
      mp_size_t pla;
      pla = l * (K - 1) + nprime + 1; /* number of required limbs for p */
      B = TMP_BALLOC_LIMBS (pla);
      Bp = TMP_BALLOC_MP_PTRS (K);
    }
  else
    {
      B = TMP_BALLOC_LIMBS (K * (nprime + 1));
      Bp = TMP_BALLOC_MP_PTRS (K);
      mpn_mul_fft_decompose (B, Bp, K, nprime, m, ml, l, Mp, T);
    }
  h = mpn_mul_fft_internal (op, pl, k, Ap, Bp, A, B, nprime, l, Mp, fft_l, T, sqr);

  TMP_FREE;
  return h;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, %r10
movq %rsi, %r13
movl 0xa0(%rsp), %ecx
movq %rdx, %rax
xorq %r8, %rax
movq %r10, %rsi
xorq %r9, %rsi
orq %rax, %rsi
sete %bpl
leaq -0x1(%r13), %rax
sarq %cl, %rax
incq %rax
shlq %cl, %rax
cmpq %r13, %rax
jne 0x30a5a
movq %rdx, 0x50(%rsp)
movq %r10, 0x58(%rsp)
movq %r8, 0x30(%rsp)
movq %r9, 0x38(%rsp)
movq %rdi, 0x60(%rsp)
movq $0x0, 0x8(%rsp)
leaq 0x10(%rsp), %rbx
movq $0x0, (%rbx)
movq %r13, %r14
shlq $0x6, %r14
movl 0xa0(%rsp), %eax
movslq %eax, %r15
leaq 0x8(,%r15,8), %rsi
movq %rbx, %rdi
callq 0x30170
movq %rax, %r12
movl $0x8, %esi
movl 0xa0(%rsp), %ecx
shlq %cl, %rsi
movq %rbx, %rdi
movl 0xa0(%rsp), %ebx
movq %rsi, 0x28(%rsp)
callq 0x30170
testl %ebx, %ebx
js 0x307cb
leal 0x1(%rbx), %edx
xorl %ecx, %ecx
movl $0x1, %esi
shlq %cl, %rsi
movq %rax, (%r12,%rcx,8)
leaq (%rax,%rsi,4), %rax
incq %rcx
cmpq %rcx, %rdx
jne 0x307b3
movq 0x8(%rsp), %rax
movb %bpl, %al
movq %rax, 0x8(%rsp)
movq %r12, %rdi
movl %ebx, %esi
callq 0x30a6b
movl $0x1, %r10d
movl %ebx, %ecx
shlq %cl, %r10
sarq %cl, %r14
leaq -0x1(%r14), %rax
leaq 0x3e(%r14), %r9
testq %rax, %rax
cmovnsq %rax, %r9
movl $0x40, %esi
testl %ebx, %ebx
jle 0x3081f
movl %ebx, %eax
movq %rsi, %rcx
shrq %rsi
testb $0x2, %cl
jne 0x3081f
leal -0x1(%rax), %ecx
cmpl $0x1, %eax
movl %ecx, %eax
jg 0x3080a
movl %ebx, %ecx
shlq %cl, %rsi
leaq (%r15,%r14,2), %rax
addq $0x2, %rax
cqto
idivq %rsi
movq %rax, %rbp
incq %rbp
imulq %rsi, %rbp
leaq 0x3f(%rbp), %rbx
testq %rbp, %rbp
cmovnsq %rbp, %rbx
sarq $0x6, %rbx
movq 0x8(%rsp), %rdx
testl %edx, %edx
movl $0x23a, %eax            # imm = 0x23A
movl $0x28e, %ecx            # imm = 0x28E
cmovneq %rax, %rcx
cmpq %rcx, %rbx
jge 0x3094a
cmpq %r13, %rbx
jge 0x30a5f
movq %r13, 0x48(%rsp)
sarq $0x6, %r9
incq %r9
movq %r9, 0x18(%rsp)
leaq 0x1(%rbx), %r13
movq %r13, %rsi
shlq $0x4, %rsi
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r10, %r14
callq 0x30170
movq %rax, 0x20(%rsp)
movl 0xa0(%rsp), %ecx
sarq %cl, %rbp
shlq %cl, %r13
shlq $0x3, %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x30170
movq %rax, %r15
leaq 0x10(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x30170
subq $0x8, %rsp
movq %r15, %rdi
movq %rax, 0x48(%rsp)
movq %rax, %rsi
movq %r14, %rdx
movq %rbx, %rcx
movq 0x58(%rsp), %r8
movq 0x60(%rsp), %r9
pushq 0x28(%rsp)
pushq %rbp
pushq 0x30(%rsp)
callq 0x30acc
addq $0x20, %rsp
cmpl $0x0, 0x8(%rsp)
je 0x309b4
decq %r14
imulq 0x18(%rsp), %r14
addq %rbx, %r14
leaq 0x8(,%r14,8), %rsi
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x30170
movq %rax, %r13
movq %r14, %rdi
movq 0x28(%rsp), %rsi
callq 0x30170
movq %rax, %r15
movq 0x20(%rsp), %rax
jmp 0x30a09
movl %edx, %eax
imulq $0x358, %rax, %rax      # imm = 0x358
leaq 0xa636(%rip), %rcx      # 0x3af90
addq %rcx, %rax
addq $0x4, %rax
movl -0x4(%rax), %edx
movq %rax, %rsi
movl %edx, %edi
movl %edi, %ecx
shrl $0x1b, %ecx
movl (%rsi), %edi
movl %edi, %r8d
andl $0x7ffffff, %r8d        # imm = 0x7FFFFFF
shlq %cl, %r8
addq $0x4, %rsi
cmpq %rbx, %r8
jl 0x30969
movl $0x1, %esi
shlq %cl, %rsi
leaq -0x1(%rsi), %rcx
testq %rbx, %rcx
je 0x30868
leaq (%rbx,%rsi), %rcx
decq %rcx
negq %rsi
andq %rcx, %rsi
movq %rsi, %rbp
shlq $0x6, %rbp
movq %rsi, %rbx
jmp 0x30964
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x30170
movq %rax, %r13
movq %r15, %rdi
movq 0x28(%rsp), %rsi
callq 0x30170
movq %rax, %r15
subq $0x8, %rsp
movq %r13, %rdi
movq %rax, %rsi
movq %r14, %rdx
movq %rbx, %rcx
movq 0x38(%rsp), %r8
movq 0x40(%rsp), %r9
movq 0x28(%rsp), %r14
pushq %r14
pushq %rbp
pushq 0x30(%rsp)
callq 0x30acc
addq $0x20, %rsp
movq %r14, %rax
movq 0x60(%rsp), %rdi
movq 0x48(%rsp), %rsi
movl 0xa0(%rsp), %edx
movq 0x40(%rsp), %rcx
movq %r15, %r8
movq %r13, %r9
pushq 0x8(%rsp)
pushq %rax
pushq %r12
pushq %rbp
pushq 0x38(%rsp)
pushq %rbx
callq 0x30f12
addq $0x30, %rsp
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
jne 0x30a64
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x7547
callq 0x7560
callq 0x301a3
jmp 0x30a48