// File: /workspace/github_cpp_makefile_star2_O2/marxn[P]pupp/3rdparty/gmp/gen-psqr.c
// Function: generate_mod
void
generate_mod (int limb_bits, int nail_bits)
{
  int    numb_bits = limb_bits - nail_bits;
  int    i, divisor;

  mpz_init_set_ui (pp, 0L);
  mpz_init_set_ui (pp_norm, 0L);
  mpz_init_set_ui (pp_inverted, 0L);

  /* no more than limb_bits many factors in a one limb modulus (and of
     course in reality nothing like that many) */
  factor_alloc = limb_bits;
  factor = (struct factor_t *) xmalloc (factor_alloc * sizeof (*factor));
  rawfactor = (struct rawfactor_t *) xmalloc (factor_alloc * sizeof (*rawfactor));

  if (numb_bits % 4 != 0)
    {
      strcpy (mod34_excuse, "GMP_NUMB_BITS % 4 != 0");
      goto use_pp;
    }

  max_divisor = 2*limb_bits;
  max_divisor_bits = log2_ceil (max_divisor);

  if (numb_bits / 4 < max_divisor_bits)
    {
      /* Wind back to one limb worth of max_divisor, if that will let us use
         mpn_mod_34lsub1.  */
      max_divisor = limb_bits;
      max_divisor_bits = log2_ceil (max_divisor);

      if (numb_bits / 4 < max_divisor_bits)
        {
          strcpy (mod34_excuse, "GMP_NUMB_BITS / 4 too small");
          goto use_pp;
        }
    }

  {
    /* Can use mpn_mod_34lsub1, find small factors of 2^mod34_bits-1. */
    mpz_t  m, q, r;
    int    multiplicity;

    mod34_bits = (numb_bits / 4) * 3;

    /* mpn_mod_34lsub1 returns a full limb value, PERFSQR_MOD_34 folds it at
       the mod34_bits mark, adding the two halves for a remainder of at most
       mod34_bits+1 many bits */
    mod_bits = mod34_bits + 1;

    mpz_init_set_ui (m, 1L);
    mpz_mul_2exp (m, m, mod34_bits);
    mpz_sub_ui (m, m, 1L);

    mpz_init (q);
    mpz_init (r);

    for (i = 3; i <= max_divisor; i+=2)
      {
        if (! isprime (i))
          continue;

        mpz_tdiv_qr_ui (q, r, m, (unsigned long) i);
        if (mpz_sgn (r) != 0)
          continue;

        /* if a repeated prime is found it's used as an i^n in one factor */
        divisor = 1;
        multiplicity = 0;
        do
          {
            if (divisor > max_divisor / i)
              break;
            multiplicity++;
            mpz_set (m, q);
            mpz_tdiv_qr_ui (q, r, m, (unsigned long) i);
          }
        while (mpz_sgn (r) == 0);

        assert (nrawfactor < factor_alloc);
        rawfactor[nrawfactor].divisor = i;
        rawfactor[nrawfactor].multiplicity = multiplicity;
        nrawfactor++;
      }

    mpz_clear (m);
    mpz_clear (q);
    mpz_clear (r);
  }

  if (nrawfactor <= 2)
    {
      mpz_t  new_pp;

      sprintf (mod34_excuse, "only %d small factor%s",
               nrawfactor, nrawfactor == 1 ? "" : "s");

    use_pp:
      /* reset to two limbs of max_divisor, in case the mpn_mod_34lsub1 code
         tried with just one */
      max_divisor = 2*limb_bits;
      max_divisor_bits = log2_ceil (max_divisor);

      mpz_init (new_pp);
      nrawfactor = 0;
      mod_bits = MIN (numb_bits, limb_bits - max_divisor_bits);

      /* one copy of each small prime */
      mpz_set_ui (pp, 1L);
      for (i = 3; i <= max_divisor; i+=2)
        {
          if (! isprime (i))
            continue;

          mpz_mul_ui (new_pp, pp, (unsigned long) i);
          if (mpz_sizeinbase (new_pp, 2) > mod_bits)
            break;
          mpz_set (pp, new_pp);

          assert (nrawfactor < factor_alloc);
          rawfactor[nrawfactor].divisor = i;
          rawfactor[nrawfactor].multiplicity = 1;
          nrawfactor++;
        }

      /* Plus an extra copy of one or more of the primes selected, if that
         still fits in max_divisor and the total in mod_bits.  Usually only
         3 or 5 will be candidates */
      for (i = nrawfactor-1; i >= 0; i--)
        {
          if (rawfactor[i].divisor > max_divisor / rawfactor[i].divisor)
            continue;
          mpz_mul_ui (new_pp, pp, (unsigned long) rawfactor[i].divisor);
          if (mpz_sizeinbase (new_pp, 2) > mod_bits)
            continue;
          mpz_set (pp, new_pp);

          rawfactor[i].multiplicity++;
        }

      mod_bits = mpz_sizeinbase (pp, 2);

      mpz_set (pp_norm, pp);
      while (mpz_sizeinbase (pp_norm, 2) < numb_bits)
        mpz_add (pp_norm, pp_norm, pp_norm);

      mpz_preinv_invert (pp_inverted, pp_norm, numb_bits);

      mpz_clear (new_pp);
    }

  /* start the factor array */
  for (i = 0; i < nrawfactor; i++)
    {
      int  j;
      assert (nfactor < factor_alloc);
      factor[nfactor].divisor = 1;
      for (j = 0; j < rawfactor[i].multiplicity; j++)
        factor[nfactor].divisor *= rawfactor[i].divisor;
      nfactor++;
    }

 combine:
  /* Combine entries in the factor array.  Combine the smallest entry with
     the biggest one that will fit with it (ie. under max_divisor), then
     repeat that with the new smallest entry. */
  qsort (factor, nfactor, sizeof (factor[0]), f_cmp_divisor);
  for (i = nfactor-1; i >= 1; i--)
    {
      if (factor[i].divisor <= max_divisor / factor[0].divisor)
        {
          factor[0].divisor *= factor[i].divisor;
          COLLAPSE_ELEMENT (factor, i, nfactor);
          goto combine;
        }
    }

  total_fraction = 1.0;
  for (i = 0; i < nfactor; i++)
    {
      mpz_init (factor[i].inverse);
      mpz_invert_ui_2exp (factor[i].inverse,
                          (unsigned long) factor[i].divisor,
                          (unsigned long) mod_bits);

      mpz_init (factor[i].mask);
      square_mask (factor[i].mask, factor[i].divisor);

      /* fraction of possible squares */
      factor[i].fraction = (double) mpz_popcount (factor[i].mask)
        / factor[i].divisor;

      /* total fraction of possible squares */
      total_fraction *= factor[i].fraction;
    }

  /* best tests first (ie. smallest fraction) */
  qsort (factor, nfactor, sizeof (factor[0]), f_cmp_fraction);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %edi, %r13d
movl %edi, %r12d
subl %esi, %r12d
pushq $0x1
popq %rbx
movq %rbx, 0x6618(%rip)      # 0xe100
pushq $0x8
popq %r14
movq %r14, %rdi
callq *0x65bb(%rip)           # 0xe0b0
movq %rax, 0x660c(%rip)      # 0xe108
andl $0x0, 0x6601(%rip)      # 0xe104
movq %rbx, 0x6606(%rip)      # 0xe110
movq %r14, %rdi
callq *0x659d(%rip)           # 0xe0b0
movq %rax, 0x65fe(%rip)      # 0xe118
andl $0x0, 0x65f3(%rip)      # 0xe114
movq %rbx, 0x65f8(%rip)      # 0xe120
movq %r14, %rdi
callq *0x657f(%rip)           # 0xe0b0
movq %rax, 0x65f0(%rip)      # 0xe128
andl $0x0, 0x65e5(%rip)      # 0xe124
movl %r13d, 0x65ea(%rip)     # 0xe130
movslq %r13d, %rax
imulq $0x30, %rax, %rdi
callq 0x12b4
movq %rax, 0x65df(%rip)      # 0xe138
movslq 0x65d0(%rip), %rdi      # 0xe130
shlq $0x3, %rdi
callq 0x12b4
movq %rax, 0x65d0(%rip)      # 0xe140
testb $0x3, %r12b
movl %r12d, -0x30(%rbp)
je 0x7cae
movupd 0x1fae(%rip), %xmm0     # 0x9b34
movapd %xmm0, 0x65c2(%rip)     # 0xe150
movabsq $0x30203d21203420, %rax # imm = 0x30203D21203420
movq %rax, 0x65c0(%rip)      # 0xe15f
leal (,%r13,2), %r15d
pushq $0x3
popq %r14
movl %r15d, 0x661e(%rip)     # 0xe1d0
movl %r15d, %edi
callq 0x75d1
movl %eax, 0x6614(%rip)      # 0xe1d4
leaq -0x70(%rbp), %r15
pushq $0x1
popq %rbx
movq %rbx, (%r15)
pushq $0x8
popq %rdi
callq *0x64dd(%rip)           # 0xe0b0
andl $0x0, 0x6602(%rip)      # 0xe1dc
subl 0x65f3(%rip), %r13d     # 0xe1d4
movq %rax, 0x8(%r15)
cmpl %r13d, %r12d
cmovll %r12d, %r13d
movl %r13d, 0x64ed(%rip)     # 0xe0e0
movq 0x650e(%rip), %rax      # 0xe108
movq %rbx, (%rax)
movl $0x1, 0x64fd(%rip)      # 0xe104
xorl %ebx, %ebx
movl 0x65c0(%rip), %r13d     # 0xe1d0
leaq 0x64e9(%rip), %r12      # 0xe100
movslq %r13d, %rax
cmpq %rax, %r14
jg 0x7d1f
movq %r14, %rdi
callq 0x750d
testl %eax, %eax
je 0x7ca5
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2ef3
movq %r15, %rdi
pushq $0x2
popq %rsi
callq 0x5874
movslq 0x6491(%rip), %rcx      # 0xe0e0
cmpq %rcx, %rax
ja 0x7d19
movq %r12, %rdi
movq %r15, %rsi
callq 0x2266
movslq 0x6572(%rip), %rax      # 0xe1dc
cmpl 0x64c0(%rip), %eax      # 0xe130
jge 0x821f
movq 0x64c3(%rip), %rcx      # 0xe140
movl %r14d, (%rcx,%rax,8)
movslq 0x6554(%rip), %rax      # 0xe1dc
movl $0x1, 0x4(%rcx,%rax,8)
movl 0x6546(%rip), %ebx      # 0xe1dc
incl %ebx
movl %ebx, 0x653e(%rip)      # 0xe1dc
movl 0x652b(%rip), %r13d     # 0xe1d0
addq $0x2, %r14
jmp 0x7c17
leal (,%r13,2), %r15d
movl %r15d, 0x6513(%rip)     # 0xe1d0
movl %r15d, %edi
callq 0x75d1
movl %eax, 0x6509(%rip)      # 0xe1d4
movl %r12d, %ebx
sarl $0x2, %ebx
cmpl %eax, %ebx
jge 0x803f
movl %r13d, 0x64f0(%rip)     # 0xe1d0
movl %r13d, %edi
callq 0x75d1
movl %eax, 0x64e6(%rip)      # 0xe1d4
cmpl %eax, %ebx
jge 0x803f
movups 0x1e5a(%rip), %xmm0     # 0x9b57
movups %xmm0, 0x6458(%rip)     # 0xe15c
movupd 0x1e3f(%rip), %xmm0     # 0x9b4b
movapd %xmm0, 0x643c(%rip)     # 0xe150
jmp 0x7ba7
movl 0x64bd(%rip), %ebx      # 0xe1dc
movl %ebx, %r13d
leaq 0x63d7(%rip), %r14      # 0xe100
leaq -0x70(%rbp), %r15
pushq $0x2
popq %r12
testl %r13d, %r13d
jle 0x7d90
movq 0x6403(%rip), %rax      # 0xe140
movslq -0x8(%rax,%r13,8), %rcx
movl 0x6488(%rip), %eax      # 0xe1d0
cltd
idivl %ecx
cmpl %eax, %ecx
jg 0x7d8b
movq %r15, %rdi
movq %r14, %rsi
movq %rcx, %rdx
callq 0x2ef3
movq %r15, %rdi
movl %r12d, %esi
callq 0x5874
movslq 0x6371(%rip), %rcx      # 0xe0e0
cmpq %rcx, %rax
ja 0x7d8b
movq %r14, %rdi
movq %r15, %rsi
callq 0x2266
movq 0x63ba(%rip), %rax      # 0xe140
incl -0x4(%rax,%r13,8)
decq %r13
jmp 0x7d31
leaq 0x6369(%rip), %r12      # 0xe100
pushq $0x2
popq %r14
movq %r12, %rdi
movl %r14d, %esi
callq 0x5874
movl %eax, 0x6334(%rip)      # 0xe0e0
leaq 0x635d(%rip), %r15      # 0xe110
movq %r15, %rdi
movq %r12, %rsi
callq 0x2266
movl -0x30(%rbp), %r12d
movslq %r12d, %rbx
movq %r15, %rdi
movl %r14d, %esi
callq 0x5874
cmpq %rbx, %rax
jae 0x7de5
movq %r15, %rdi
movq %r15, %rsi
movq %r15, %rdx
callq 0x2c6d
jmp 0x7dc5
leaq 0x6334(%rip), %rdi      # 0xe120
leaq 0x631d(%rip), %rsi      # 0xe110
movl %r12d, %edx
callq 0x7609
movq -0x68(%rbp), %rdi
xorl %esi, %esi
callq *0x62b9(%rip)           # 0xe0c0
movq 0x632a(%rip), %rax      # 0xe138
movq 0x632b(%rip), %rcx      # 0xe140
xorl %edx, %edx
xorl %esi, %esi
movslq 0x63bc(%rip), %rdi      # 0xe1dc
movl 0x63b9(%rip), %r8d      # 0xe1e0
cmpq %rdi, %rsi
jge 0x7e7a
cmpl 0x62fd(%rip), %r8d      # 0xe130
jge 0x8200
movslq %r8d, %rdi
imulq $0x30, %rdi, %rdi
movl $0x1, (%rax,%rdi)
movl 0x4(%rcx,%rsi,8), %edi
testl %edi, %edi
cmovlel %edx, %edi
subl $0x1, %edi
jb 0x7e6f
movslq 0x6384(%rip), %r8       # 0xe1e0
imulq $0x30, %r8, %r8
movl (%rax,%r8), %r9d
imull (%rcx,%rsi,8), %r9d
movl %r9d, (%rax,%r8)
jmp 0x7e50
incl 0x636b(%rip)            # 0xe1e0
incq %rsi
jmp 0x7e19
leaq -0x5d3(%rip), %r14      # 0x78ae
pushq $0x30
popq %r15
movq 0x62ac(%rip), %rdi      # 0xe138
movslq %r8d, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1070
movslq 0x633f(%rip), %rsi      # 0xe1e0
movq 0x6290(%rip), %r8       # 0xe138
movl 0x6322(%rip), %ecx      # 0xe1d0
movl %esi, %r10d
movq %rsi, %r9
incq %r9
imulq $0x30, %r10, %rdi
addq %r8, %rdi
cmpl $0x2, %r10d
jl 0x7f20
decq %r10
movl -0x30(%rdi), %r11d
addq $-0x30, %rdi
movl (%r8), %ebx
movl %ecx, %eax
cltd
idivl %ebx
decq %r9
cmpl %eax, %r11d
jg 0x7ebe
imull %r11d, %ebx
movl %ebx, (%r8)
incl %r10d
andl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
imulq $0x30, %r10, %rsi
addq %r8, %rsi
movslq 0x62e2(%rip), %rax      # 0xe1e0
subq %r9, %rax
imulq $0x30, %rax, %rdx
callq 0x10e0
movl 0x62cf(%rip), %r8d      # 0xe1e0
decl %r8d
movl %r8d, 0x62c5(%rip)      # 0xe1e0
jmp 0x7e85
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x62b7(%rip)      # 0xe1e8
pushq $0x18
popq %r12
xorl %eax, %eax
pushq $0x1
popq %r14
pushq $0x8
popq %r13
movslq %esi, %rsi
movq 0x61ef(%rip), %r15      # 0xe138
cmpq %rsi, %rax
jge 0x801e
movq %rax, -0x30(%rbp)
movq %r14, -0x10(%r15,%r12)
movq %r13, %rdi
callq *0x614c(%rip)           # 0xe0b0
movq %rax, -0x8(%r15,%r12)
movq 0x61c8(%rip), %rax      # 0xe138
leaq (%rax,%r12), %rdi
addq $-0x10, %rdi
movslq -0x8(%rdi), %rsi
movslq 0x615d(%rip), %rdx      # 0xe0e0
callq 0x7844
movq 0x61a9(%rip), %rbx      # 0xe138
movq %r14, (%rbx,%r12)
movq %r13, %rdi
callq *0x6114(%rip)           # 0xe0b0
movq %rax, 0x8(%rbx,%r12)
movq 0x6190(%rip), %rdi      # 0xe138
movl -0x18(%rdi,%r12), %esi
addq %r12, %rdi
callq 0x793e
movq 0x617c(%rip), %rbx      # 0xe138
leaq (%rbx,%r12), %rdi
callq 0x68b6
movq %rax, %xmm0
movq -0x30(%rbp), %rax
punpckldq 0x108a(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1092(%rip), %xmm0     # 0x9070
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
cvtsi2sdl -0x18(%rbx,%r12), %xmm0
divsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rbx,%r12)
mulsd 0x61e4(%rip), %xmm1     # 0xe1e8
movsd %xmm1, 0x61dc(%rip)     # 0xe1e8
incq %rax
movl 0x61cb(%rip), %esi      # 0xe1e0
addq $0x30, %r12
jmp 0x7f3f
leaq -0x75a(%rip), %rcx      # 0x78cb
pushq $0x30
popq %rdx
movq %r15, %rdi
callq 0x1070
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r15d, -0x34(%rbp)
movq %r13, -0x58(%rbp)
leal (%rbx,%rbx,2), %eax
movl %eax, 0x6188(%rip)      # 0xe1d8
leal (%rbx,%rbx,2), %eax
incl %eax
movl %eax, 0x6085(%rip)      # 0xe0e0
pushq $0x1
popq %rbx
leaq -0x90(%rbp), %r13
movl %ebx, (%r13)
movq %r14, %rdi
callq *0x603e(%rip)           # 0xe0b0
movq %rax, 0x8(%r13)
pushq $0x1
popq %r15
movq %r15, (%rax)
movl %ebx, 0x4(%r13)
movslq 0x6150(%rip), %rdx      # 0xe1d8
movq %r13, %rdi
movq %r13, %rsi
callq 0x307c
movq %r13, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x2c07
leaq -0x80(%rbp), %r12
movq %r15, (%r12)
movq %r14, %rdi
movq %r14, %rbx
callq *0x5ffb(%rip)           # 0xe0b0
movq %rax, 0x8(%r12)
leaq -0x50(%rbp), %r14
movq %r15, (%r14)
movq %rbx, %rdi
callq *0x5fe6(%rip)           # 0xe0b0
movq %rax, 0x8(%r14)
pushq $0x3
popq %r15
movslq 0x60f7(%rip), %rax      # 0xe1d0
cmpq %rax, %r15
jg 0x818f
movq %r15, %rdi
callq 0x750d
testl %eax, %eax
je 0x8186
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x3def
movl -0x4c(%rbp), %eax
movl %eax, %ecx
sarl $0x1f, %ecx
xorl %edx, %edx
testl %eax, %eax
setne %dl
orl %ecx, %edx
jne 0x8186
xorl %ebx, %ebx
movl 0x60b2(%rip), %eax      # 0xe1d0
cltd
idivl %r15d
testl %eax, %eax
jle 0x8157
incl %ebx
movq %r13, %rdi
movq %r12, %rsi
callq 0x2266
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x3def
movl -0x4c(%rbp), %eax
movl %eax, %ecx
sarl $0x1f, %ecx
xorl %edx, %edx
testl %eax, %eax
setne %dl
orl %ecx, %edx
je 0x8118
movslq 0x607e(%rip), %rax      # 0xe1dc
cmpl 0x5fcc(%rip), %eax      # 0xe130
jge 0x823e
movq 0x5fcf(%rip), %rcx      # 0xe140
movl %r15d, (%rcx,%rax,8)
movslq 0x6060(%rip), %rax      # 0xe1dc
movl %ebx, 0x4(%rcx,%rax,8)
incl 0x6056(%rip)            # 0xe1dc
addq $0x2, %r15
jmp 0x80d2
movq -0x88(%rbp), %rdi
xorl %esi, %esi
callq *0x5f22(%rip)           # 0xe0c0
movq -0x78(%rbp), %rdi
xorl %esi, %esi
callq *0x5f16(%rip)           # 0xe0c0
movq -0x48(%rbp), %rdi
xorl %esi, %esi
callq *0x5f0a(%rip)           # 0xe0c0
movl 0x6020(%rip), %edx      # 0xe1dc
cmpl $0x2, %edx
jg 0x7e07
cmpl $0x1, %edx
leaq 0x1aa3(%rip), %rax      # 0x9c72
leaq 0x19dc(%rip), %rcx      # 0x9bb2
cmoveq %rax, %rcx
leaq 0x5f6f(%rip), %rdi      # 0xe150
leaq 0x19b5(%rip), %rsi      # 0x9b9d
xorl %eax, %eax
callq 0x1100
movl -0x30(%rbp), %r12d
movq -0x58(%rbp), %r13
movl -0x34(%rbp), %r15d
jmp 0x7ba7
leaq 0x19ad(%rip), %rdi      # 0x9bb4
leaq 0x1905(%rip), %rsi      # 0x9b13
leaq 0x196c(%rip), %rcx      # 0x9b81
movl $0x185, %edx            # imm = 0x185
callq 0x10a0
leaq 0x1941(%rip), %rdi      # 0x9b67
leaq 0x18e6(%rip), %rsi      # 0x9b13
leaq 0x194d(%rip), %rcx      # 0x9b81
movl $0x161, %edx            # imm = 0x161
callq 0x10a0
leaq 0x1922(%rip), %rdi      # 0x9b67
leaq 0x18c7(%rip), %rsi      # 0x9b13
leaq 0x192e(%rip), %rcx      # 0x9b81
movl $0x139, %edx            # imm = 0x139
callq 0x10a0