// File: /workspace/github_cpp_makefile_star2_O2/marxn[P]pupp/3rdparty/gmp/mpf/get_str.c
// Function: _gmpf_get_str
char *
mpf_get_str (char *dbuf, mp_exp_t *exp, int base, size_t n_digits, mpf_srcptr u)
{
  mp_exp_t ue;
  mp_size_t n_limbs_needed;
  size_t max_digits;
  mp_ptr up, pp, tp;
  mp_size_t un, pn, tn;
  unsigned char *tstr;
  mp_exp_t exp_in_base;
  size_t n_digits_computed;
  mp_size_t i;
  const char *num_to_text;
  size_t alloc_size = 0;
  char *dp;
  TMP_DECL;

  up = PTR(u);
  un = ABSIZ(u);
  ue = EXP(u);

  if (base >= 0)
    {
      num_to_text = "0123456789abcdefghijklmnopqrstuvwxyz";
      if (base <= 1)
	base = 10;
      else if (base > 36)
	{
	  num_to_text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	  if (base > 62)
	    return NULL;
	}
    }
  else
    {
      base = -base;
      if (base <= 1)
	base = 10;
      else if (base > 36)
	return NULL;
      num_to_text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    }

  MPF_SIGNIFICANT_DIGITS (max_digits, base, PREC(u));
  if (n_digits == 0 || n_digits > max_digits)
    n_digits = max_digits;

  if (dbuf == 0)
    {
      /* We didn't get a string from the user.  Allocate one (and return
	 a pointer to it) with space for `-' and terminating null.  */
      alloc_size = n_digits + 2;
      dbuf = (char *) (*__gmp_allocate_func) (n_digits + 2);
    }

  if (un == 0)
    {
      *exp = 0;
      *dbuf = 0;
      n_digits = 0;
      goto done;
    }

  TMP_MARK;

  /* Allocate temporary digit space.  We can't put digits directly in the user
     area, since we generate more digits than requested.  (We allocate
     2 * GMP_LIMB_BITS extra bytes because of the digit block nature of the
     conversion.)  */
  tstr = (unsigned char *) TMP_ALLOC (n_digits + 2 * GMP_LIMB_BITS + 3);

  LIMBS_PER_DIGIT_IN_BASE (n_limbs_needed, n_digits, base);

  if (un > n_limbs_needed)
    {
      up += un - n_limbs_needed;
      un = n_limbs_needed;
    }

  TMP_ALLOC_LIMBS_2 (pp, 2 * n_limbs_needed + 4,
		     tp, 2 * n_limbs_needed + 4);

  if (ue <= n_limbs_needed)
    {
      /* We need to multiply number by base^n to get an n_digits integer part.  */
      mp_size_t n_more_limbs_needed, ign, off;
      unsigned long e;

      n_more_limbs_needed = n_limbs_needed - ue;
      DIGITS_IN_BASE_PER_LIMB (e, n_more_limbs_needed, base);

      pn = mpn_pow_1_highpart (pp, &ign, (mp_limb_t) base, e, n_limbs_needed + 1, tp);
      if (un > pn)
	mpn_mul (tp, up, un, pp, pn);	/* FIXME: mpn_mul_highpart */
      else
	mpn_mul (tp, pp, pn, up, un);	/* FIXME: mpn_mul_highpart */
      tn = un + pn;
      tn -= tp[tn - 1] == 0;
      off = un - ue - ign;
      if (off < 0)
	{
	  MPN_COPY_DECR (tp - off, tp, tn);
	  MPN_ZERO (tp, -off);
	  tn -= off;
	  off = 0;
	}
      n_digits_computed = mpn_get_str (tstr, base, tp + off, tn - off);

      exp_in_base = n_digits_computed - e;
    }
  else
    {
      /* We need to divide number by base^n to get an n_digits integer part.  */
      mp_size_t n_less_limbs_needed, ign, off, xn;
      unsigned long e;
      mp_ptr dummyp, xp;

      n_less_limbs_needed = ue - n_limbs_needed;
      DIGITS_IN_BASE_PER_LIMB (e, n_less_limbs_needed, base);

      pn = mpn_pow_1_highpart (pp, &ign, (mp_limb_t) base, e, n_limbs_needed + 1, tp);

      xn = n_limbs_needed + (n_less_limbs_needed-ign);
      xp = TMP_ALLOC_LIMBS (xn);
      off = xn - un;
      MPN_ZERO (xp, off);
      MPN_COPY (xp + off, up, un);

      dummyp = TMP_ALLOC_LIMBS (pn);
      mpn_tdiv_qr (tp, dummyp, (mp_size_t) 0, xp, xn, pp, pn);
      tn = xn - pn + 1;
      tn -= tp[tn - 1] == 0;
      n_digits_computed = mpn_get_str (tstr, base, tp, tn);

      exp_in_base = n_digits_computed + e;
    }

  /* We should normally have computed too many digits.  Round the result
     at the point indicated by n_digits.  */
  if (n_digits_computed > n_digits)
    {
      size_t i;
      /* Round the result.  */
      if (tstr[n_digits] * 2 >= base)
	{
	  n_digits_computed = n_digits;
	  for (i = n_digits - 1;; i--)
	    {
	      unsigned int x;
	      x = ++(tstr[i]);
	      if (x != base)
		break;
	      n_digits_computed--;
	      if (i == 0)
		{
		  /* We had something like `bbbbbbb...bd', where 2*d >= base
		     and `b' denotes digit with significance base - 1.
		     This rounds up to `1', increasing the exponent.  */
		  tstr[0] = 1;
		  n_digits_computed = 1;
		  exp_in_base++;
		  break;
		}
	    }
	}
    }

  /* We might have fewer digits than requested as a result of rounding above,
     (i.e. 0.999999 => 1.0) or because we have a number that simply doesn't
     need many digits in this base (e.g., 0.125 in base 10).  */
  if (n_digits > n_digits_computed)
    n_digits = n_digits_computed;

  /* Remove trailing 0.  There can be many zeros.  */
  while (n_digits != 0 && tstr[n_digits - 1] == 0)
    n_digits--;

  dp = dbuf + (SIZ(u) < 0);

  /* Translate to ASCII and copy to result string.  */
  for (i = 0; i < n_digits; i++)
    dp[i] = num_to_text[tstr[i]];
  dp[n_digits] = 0;

  *exp = exp_in_base;

  if (SIZ(u) < 0)
    {
      dbuf[0] = '-';
      n_digits++;
    }

  TMP_FREE;

 done:
  /* If the string was alloced then resize it down to the actual space
     required.  */
  if (alloc_size != 0)
    {
      __GMP_REALLOCATE_FUNC_MAYBE_TYPE (dbuf, alloc_size, n_digits + 1, char);
    }

  return dbuf;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %r9
movl 0x4(%r8), %r14d
movl %r14d, %r15d
negl %r15d
cmovsl %r14d, %r15d
movq 0x10(%r8), %r11
movq 0x8(%r8), %r10
pushq $0xa
popq %rax
testl %edx, %edx
js 0x2d1cf
leaq 0x7675(%rip), %rdi      # 0x34824
cmpl $0x2, %edx
jb 0x2d1e8
cmpl $0x25, %edx
jb 0x2d1f4
cmpl $0x3e, %edx
ja 0x2d1e0
movq %rsi, -0x50(%rbp)
leaq 0x76ab(%rip), %rax      # 0x34874
movq %rax, -0x30(%rbp)
jmp 0x2d208
leaq 0x7673(%rip), %rdi      # 0x34849
cmpl $-0x1, %edx
je 0x2d1e8
cmpl $-0x24, %edx
jae 0x2d1fe
xorl %r9d, %r9d
jmp 0x2d652
movq %rdi, -0x30(%rbp)
movq %rsi, -0x50(%rbp)
movl %eax, %edx
jmp 0x2d208
movq %rdi, -0x30(%rbp)
movq %rsi, -0x50(%rbp)
jmp 0x2d208
movq %rdi, -0x30(%rbp)
movq %rsi, -0x50(%rbp)
negl %edx
movl %edx, %eax
movq %rax, -0x58(%rbp)
imulq $0x28, %rax, %r12
leaq 0x3f07(%rip), %r13      # 0x31120
movq 0x8(%r13,%r12), %rax
movslq (%r8), %rdx
shlq $0x6, %rdx
addq $-0x40, %rdx
movq %rdx, -0xc0(%rbp)
movq %rax, -0x40(%rbp)
mulq -0xc0(%rbp)
addq $0x2, %rdx
leaq -0x1(%rcx), %rax
cmpq %rdx, %rax
cmovbq %rcx, %rdx
testq %r9, %r9
movq %rdx, -0x78(%rbp)
movq %r8, -0xa0(%rbp)
je 0x2d264
movq $0x0, -0x70(%rbp)
jmp 0x2d286
leaq 0x2(%rdx), %rdi
leaq 0x16029(%rip), %rax     # 0x43298
movq %rdi, -0x70(%rbp)
movq %r10, %rbx
movq %r11, -0x38(%rbp)
callq *(%rax)
movq -0x38(%rbp), %r11
movq %rbx, %r10
movq %rax, %r9
testl %r14d, %r14d
je 0x2d47c
movq %r9, -0x80(%rbp)
andq $0x0, -0x68(%rbp)
addq %r12, %r13
movq -0x78(%rbp), %rcx
leaq 0x83(%rcx), %rsi
cmpq $0x7f00, %rsi           # imm = 0x7F00
ja 0x2d664
movq %rsp, %r12
addq $0xf, %rsi
andq $-0x10, %rsi
subq %rsi, %r12
movq %r12, %rsp
movq 0x10(%r13), %rax
movq %rcx, -0xb8(%rbp)
mulq -0xb8(%rbp)
shrq $0x3, %rdx
movabsq $0x3ffffffffffffff, %r14 # imm = 0x3FFFFFFFFFFFFFF
andq %rdx, %r14
leaq 0x2(%r14), %r13
cmpq %r15, %r13
movq %r15, %rax
cmovbq %r13, %rax
movq %rax, -0x60(%rbp)
xorl %ebx, %ebx
subq %r13, %r15
cmovaeq %r15, %rbx
leaq 0x8(,%r14,2), %r15
movq %r15, %rsi
shlq $0x4, %rsi
cmpq $0x3f4, %r14            # imm = 0x3F4
ja 0x2d685
movq %rsp, %rdi
addq $0xf, %rsi
andq $-0x10, %rsi
subq %rsi, %rdi
movq %rdi, %rsp
leaq (%r11,%rbx,8), %rax
movq %rax, -0x38(%rbp)
leaq (%rdi,%r15,8), %r9
addq $0x3, %r14
movq %r10, %rbx
subq %r13, %rbx
jle 0x2d493
movq %rbx, %rax
shlq $0x6, %rax
movq %rax, -0xa8(%rbp)
movq -0x40(%rbp), %rax
mulq -0xa8(%rbp)
movq %rdx, %rcx
leaq -0x88(%rbp), %r15
movq %rdi, -0x90(%rbp)
movq %r15, %rsi
movq -0x58(%rbp), %rdx
movq %rcx, -0x98(%rbp)
movq %r14, %r8
movq %r9, -0x48(%rbp)
callq 0x2d6d3
subq (%r15), %rbx
movq %rax, -0x40(%rbp)
addq %r13, %rbx
leaq (,%rbx,8), %rsi
cmpq $0x7f00, %rsi           # imm = 0x7F00
ja 0x2d6b4
movq %rsp, %rdi
addq $0xf, %rsi
andq $-0x10, %rsi
subq %rsi, %rdi
movq %rdi, %rsp
movq -0x30(%rbp), %r13
movq %rbx, %r15
movq -0x60(%rbp), %rdx
subq %rdx, %r15
movq %rdi, %r14
je 0x2d3e8
leaq (,%r15,8), %rdx
xorl %esi, %esi
callq 0x6170
movq %r14, %rdi
movq -0x60(%rbp), %rdx
leaq (%rdi,%r15,8), %rdi
movq -0x38(%rbp), %rsi
callq 0x290c6
movq -0x40(%rbp), %rax
leaq (,%rax,8), %rsi
cmpq $0x7f00, %rsi           # imm = 0x7F00
ja 0x2d6c5
movq %rsp, %rax
addq $0xf, %rsi
andq $-0x10, %rsi
subq %rsi, %rax
movq %rax, %rsp
movq -0x58(%rbp), %r15
subq $0x8, %rsp
movq -0x48(%rbp), %rdi
movq %rax, %rsi
xorl %edx, %edx
movq %r14, %rcx
movq %rbx, %r8
movq -0x90(%rbp), %r9
movq -0x40(%rbp), %r14
pushq %r14
callq 0x1b900
popq %rax
popq %rcx
movq %rbx, %rax
subq %r14, %rax
movq -0x48(%rbp), %rdx
cmpq $0x1, (%rdx,%rax,8)
sbbq %r14, %rbx
incq %rbx
movq %r12, %rdi
movl %r15d, %esi
movq %rbx, %rcx
callq 0x2dd38
movq -0x98(%rbp), %rsi
addq %rax, %rsi
jmp 0x2d58a
movq -0x50(%rbp), %rax
andq $0x0, (%rax)
movb $0x0, (%r9)
xorl %ebx, %ebx
movq -0x70(%rbp), %r14
jmp 0x2d630
movq %r10, -0x48(%rbp)
subq %r10, %r13
shlq $0x6, %r13
movq %r13, -0xb0(%rbp)
movq -0x40(%rbp), %rax
mulq -0xb0(%rbp)
movq %rdx, %rcx
leaq -0x88(%rbp), %rsi
movq %rdi, %r13
movq -0x58(%rbp), %rdx
movq %rcx, -0x40(%rbp)
movq %r14, %r8
movq %r9, %rbx
callq 0x2d6d3
movq %rax, %r14
movq -0x60(%rbp), %r15
movq %rbx, %rdi
cmpq %rax, %r15
jle 0x2d4ee
movq -0x38(%rbp), %rsi
movq %r15, %rdx
movq %r13, %rcx
movq %r14, %r8
jmp 0x2d4fb
movq %r13, %rsi
movq %r14, %rdx
movq -0x38(%rbp), %rcx
movq %r15, %r8
callq 0x18a58
movq -0x30(%rbp), %r13
addq %r15, %r14
movq %rbx, %rsi
cmpq $0x1, -0x8(%rbx,%r14,8)
sbbq $0x0, %r14
movq -0x48(%rbp), %rbx
addq -0x88(%rbp), %rbx
subq %rbx, %r15
movq %r15, %rcx
js 0x2d52d
movq -0x58(%rbp), %r15
jmp 0x2d56e
movq %rcx, %r15
negq %r15
leaq (,%rcx,8), %rax
movq %rsi, %rdi
subq %rax, %rdi
movq %r14, %rdx
movq %rsi, %rbx
movq %rcx, -0x60(%rbp)
callq 0x2e500
shlq $0x3, %r15
movq %rbx, %rdi
xorl %esi, %esi
movq %r15, %rdx
movq -0x58(%rbp), %r15
callq 0x6170
movq %rbx, %rsi
subq -0x60(%rbp), %r14
xorl %ecx, %ecx
leaq (%rsi,%rcx,8), %rdx
subq %rcx, %r14
movq %r12, %rdi
movl %r15d, %esi
movq %r14, %rcx
callq 0x2dd38
movq %rax, %rsi
subq -0x40(%rbp), %rsi
movq -0x78(%rbp), %rdx
cmpq %rdx, %rax
movq -0x80(%rbp), %r9
movq -0xa0(%rbp), %rdi
movq -0x70(%rbp), %r14
jbe 0x2d5d5
movzbl (%r12,%rdx), %ecx
addl %ecx, %ecx
cmpl %r15d, %ecx
jb 0x2d5d5
movq %rdx, %rax
movb -0x1(%r12,%rax), %cl
incb %cl
movb %cl, -0x1(%r12,%rax)
movzbl %cl, %ecx
cmpl %ecx, %r15d
jne 0x2d5d5
decq %rax
jne 0x2d5b1
movb $0x1, (%r12)
incq %rsi
pushq $0x1
popq %rax
cmpq %rax, %rdx
cmovbq %rdx, %rax
movq %rax, %rbx
subq $0x1, %rax
jb 0x2d5ed
cmpb $0x0, -0x1(%r12,%rbx)
je 0x2d5dc
movl 0x4(%rdi), %eax
shrl $0x1f, %eax
addq %r9, %rax
xorl %ecx, %ecx
cmpq %rcx, %rbx
je 0x2d60f
movzbl (%r12,%rcx), %edx
movb (%r13,%rdx), %dl
movb %dl, (%rax,%rcx)
incq %rcx
jmp 0x2d5f8
movb $0x0, (%rbx,%rax)
movq -0x50(%rbp), %rax
movq %rsi, (%rax)
cmpl $0x0, 0x4(%rdi)
jns 0x2d627
movb $0x2d, (%r9)
incq %rbx
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
jne 0x2d6a6
testq %r14, %r14
je 0x2d652
incq %rbx
cmpq %rbx, %r14
je 0x2d652
leaq 0x15c5c(%rip), %rax     # 0x432a0
movq %r9, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq *(%rax)
movq %rax, %r9
movq %r9, %rax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x68(%rbp), %rdi
movq %r10, %r14
movq %r11, %r12
callq 0x29dc0
movq %r12, %r11
movq %r14, %r10
movq -0x78(%rbp), %rcx
movq %rax, %r12
jmp 0x2d2c4
leaq -0x68(%rbp), %rdi
movq %r10, -0x48(%rbp)
movq %r11, -0x38(%rbp)
callq 0x29dc0
movq -0x38(%rbp), %r11
movq -0x48(%rbp), %r10
movq %rax, %rdi
jmp 0x2d32f
callq 0x29df3
movq -0x80(%rbp), %r9
jmp 0x2d630
leaq -0x68(%rbp), %rdi
callq 0x29dc0
movq %rax, %rdi
jmp 0x2d3bf
leaq -0x68(%rbp), %rdi
callq 0x29dc0
jmp 0x2d41f