// File: /workspace/github_cpp_makefile_star2_O3/marxn[P]pupp/3rdparty/gmp/mpn/set_str.c
// Function: _gmpn_set_str_compute_powtab
void
mpn_set_str_compute_powtab (powers_t *powtab, mp_ptr powtab_mem, mp_size_t un, int base)
{
  mp_ptr powtab_mem_ptr;
  long i, pi;
  mp_size_t n;
  mp_ptr p, t;
  mp_limb_t big_base;
  int chars_per_limb;
  size_t digits_in_base;
  mp_size_t shift;

  powtab_mem_ptr = powtab_mem;

  chars_per_limb = mp_bases[base].chars_per_limb;
  big_base = mp_bases[base].big_base;

  p = powtab_mem_ptr;
  powtab_mem_ptr += 1;

  digits_in_base = chars_per_limb;

  p[0] = big_base;
  n = 1;

  count_leading_zeros (i, un - 1);
  i = GMP_LIMB_BITS - 1 - i;

  powtab[i].p = p;
  powtab[i].n = n;
  powtab[i].digits_in_base = digits_in_base;
  powtab[i].base = base;
  powtab[i].shift = 0;

  shift = 0;
  for (pi = i - 1; pi >= 0; pi--)
    {
      t = powtab_mem_ptr;
      powtab_mem_ptr += 2 * n;

      ASSERT_ALWAYS (powtab_mem_ptr < powtab_mem + mpn_dc_set_str_powtab_alloc (un));

      mpn_sqr (t, p, n);
      n = 2 * n - 1; n += t[n] != 0;
      digits_in_base *= 2;
#if 1
      if ((((un - 1) >> pi) & 2) == 0)
	{
	  mpn_divexact_1 (t, t, n, big_base);
	  n -= t[n - 1] == 0;
	  digits_in_base -= chars_per_limb;
	}
#else
      if (CLEVER_CONDITION_1 ())
	{
	  /* perform adjustment operation of previous */
	  cy = mpn_mul_1 (p, p, n, big_base);
	}
      if (CLEVER_CONDITION_2 ())
	{
	  /* perform adjustment operation of new */
	  cy = mpn_mul_1 (t, t, n, big_base);
	}
#endif
      shift *= 2;
      /* Strip low zero limbs, but be careful to keep the result divisible by
	 big_base.  */
      while (t[0] == 0 && (t[1] & ((big_base & -big_base) - 1)) == 0)
	{
	  t++;
	  n--;
	  shift++;
	}
      p = t;
      powtab[pi].p = p;
      powtab[pi].n = n;
      powtab[pi].digits_in_base = digits_in_base;
      powtab[pi].base = base;
      powtab[pi].shift = shift;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, 0x4(%rsp)
movslq %ecx, %rax
leaq (%rax,%rax,4), %rcx
leaq 0x1892a(%rip), %r8      # 0x37120
movslq (%r8,%rcx,8), %r9
movq 0x18(%r8,%rcx,8), %rcx
movq %rcx, 0x8(%rsp)
movq %rcx, (%rsi)
leaq -0x1(%rdx), %rcx
movq %rcx, 0x28(%rsp)
movq %rcx, 0x40(%rsp)
bsrq 0x40(%rsp), %rcx
xorq $0x3f, %rcx
movl $0x3f, %r8d
subq %rcx, %r8
leaq (%r8,%r8,4), %r8
movq %rsi, (%rdi,%r8,8)
movq $0x1, 0x8(%rdi,%r8,8)
movq %r9, 0x10(%rsp)
movq %r9, 0x18(%rdi,%r8,8)
movl %eax, 0x20(%rdi,%r8,8)
movq %rdi, 0x30(%rsp)
movq $0x0, 0x10(%rdi,%r8,8)
movl $0x3e, %r8d
subq %rcx, %r8
js 0x1e976
leaq 0x8(%rsi), %r15
leaq (%rsi,%rdx,8), %rax
addq $0x200, %rax            # imm = 0x200
movq %rax, 0x20(%rsp)
movq 0x8(%rsp), %rcx
leaq -0x1(%rcx), %rax
movq %rcx, %rdi
notq %rdi
andq %rax, %rdi
movl $0x1, %r13d
xorl %r14d, %r14d
movq 0x10(%rsp), %rbx
movq %rdi, 0x18(%rsp)
movq %r15, %rbp
movq %r13, %r15
shlq $0x4, %r15
addq %rbp, %r15
cmpq 0x20(%rsp), %r15
jae 0x1e985
movq %r8, 0x38(%rsp)
movq %rbx, %r12
leaq (,%r13,2), %rbx
movq %rbp, %rdi
movq %r13, %rdx
callq 0x1d514
leaq -0x1(%rbx), %r13
cmpq $0x1, -0x8(%rbp,%rbx,8)
movq %r12, %rbx
movq 0x38(%rsp), %r12
sbbq $-0x1, %r13
addq %rbx, %rbx
movq 0x28(%rsp), %rax
movl %r12d, %ecx
sarq %cl, %rax
testb $0x2, %al
jne 0x1e91a
movq %rbp, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq 0x8(%rsp), %rcx
callq 0x30220
cmpq $0x1, -0x8(%rbp,%r13,8)
sbbq $0x0, %r13
subq 0x10(%rsp), %rbx
addq %r14, %r14
cmpq $0x0, (%rbp)
movq 0x18(%rsp), %rdi
jne 0x1e941
movq 0x8(%rbp), %rax
testq %rax, %rdi
jne 0x1e941
addq $0x8, %rbp
decq %r13
incq %r14
testq %rax, %rax
je 0x1e929
leaq (%r12,%r12,4), %rax
movq 0x30(%rsp), %rdx
movq %rbp, (%rdx,%rax,8)
movq %r13, 0x8(%rdx,%rax,8)
movq %rbx, 0x18(%rdx,%rax,8)
movl 0x4(%rsp), %ecx
movl %ecx, 0x20(%rdx,%rax,8)
movq %r14, 0x10(%rdx,%rax,8)
leaq -0x1(%r12), %r8
movq %rbp, %rsi
testq %r12, %r12
jg 0x1e89d
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x667c