// File: /workspace/github_cpp_makefile_star2_O1/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, %r15
movq 0x10(%r8), %r9
movl 0x4(%r8), %r12d
movl %r12d, %ebx
negl %ebx
cmovsl %r12d, %ebx
movq 0x8(%r8), %r10
testl %edx, %edx
js 0x33f4f
leaq 0x7905(%rip), %rax      # 0x3b834
cmpl $0x2, %edx
jl 0x33f68
cmpl $0x25, %edx
jl 0x33f77
cmpl $0x3e, %edx
jg 0x33f60
movq %rsi, -0x40(%rbp)
leaq 0x793b(%rip), %rax      # 0x3b884
movq %rax, -0x50(%rbp)
jmp 0x33f8b
leaq 0x7903(%rip), %rax      # 0x3b859
cmpl $-0x1, %edx
je 0x33f68
cmpl $-0x24, %edx
jge 0x33f81
xorl %r15d, %r15d
jmp 0x3440d
movq %rax, -0x50(%rbp)
movq %rsi, -0x40(%rbp)
movl $0xa, %edx
jmp 0x33f8b
movq %rax, -0x50(%rbp)
movq %rsi, -0x40(%rbp)
jmp 0x33f8b
movq %rax, -0x50(%rbp)
movq %rsi, -0x40(%rbp)
negl %edx
movl %edx, %eax
movq %rax, -0x58(%rbp)
leaq (%rax,%rax,4), %r14
leaq 0x4194(%rip), %rsi      # 0x38130
movq 0x8(%rsi,%r14,8), %r11
movslq (%r8), %rax
shlq $0x6, %rax
addq $-0x40, %rax
movq %rax, -0xc0(%rbp)
movq %r11, %rax
mulq -0xc0(%rbp)
addq $0x2, %rdx
leaq -0x1(%rcx), %rax
cmpq %rdx, %rax
cmovbq %rcx, %rdx
testq %r15, %r15
movq %rdx, -0x80(%rbp)
je 0x33fdf
movq $0x0, -0x68(%rbp)
jmp 0x34016
movq %r10, -0x30(%rbp)
leaq 0x2(%rdx), %rdi
leaq 0x142aa(%rip), %rax     # 0x48298
movq %rdi, -0x68(%rbp)
movq %r8, %r15
movq %r9, %r13
movq %r11, -0x38(%rbp)
callq *(%rax)
leaq 0x412b(%rip), %rsi      # 0x38130
movq -0x38(%rbp), %r11
movq %r13, %r9
movq -0x30(%rbp), %r10
movq %r15, %r8
movq %rax, %r15
testl %r12d, %r12d
je 0x34217
leaq (%rsi,%r14,8), %r14
movq $0x0, -0x60(%rbp)
movq -0x80(%rbp), %rcx
leaq 0x83(%rcx), %rsi
cmpq $0x7f00, %rsi           # imm = 0x7F00
movq %r15, -0xa0(%rbp)
ja 0x3441f
movq %rsp, %r12
addq $0xf, %rsi
andq $-0x10, %rsi
subq %rsi, %r12
movq %r12, %rsp
movq 0x10(%r14), %rax
movq %rcx, -0xb8(%rbp)
mulq -0xb8(%rbp)
shrq $0x3, %rdx
movabsq $0x3ffffffffffffff, %r13 # imm = 0x3FFFFFFFFFFFFFF
andq %rdx, %r13
leaq 0x2(%r13), %r14
cmpq %rbx, %r14
movq %rbx, %rax
cmovbq %r14, %rax
movq %rax, -0x78(%rbp)
xorl %r15d, %r15d
subq %r14, %rbx
cmovaeq %rbx, %r15
leaq 0x8(,%r13,2), %rbx
movq %rbx, %rsi
shlq $0x4, %rsi
cmpq $0x3f4, %r13            # imm = 0x3F4
movq %r8, -0x98(%rbp)
ja 0x3444e
movq %rsp, %rdi
addq $0xf, %rsi
andq $-0x10, %rsi
subq %rsi, %rdi
movq %rdi, %rsp
leaq (%r9,%r15,8), %rax
movq %rax, -0x48(%rbp)
leaq (%rdi,%rbx,8), %r9
addq $0x3, %r13
movq %r10, %r15
subq %r14, %r15
movq %rdi, -0x38(%rbp)
jle 0x34231
movq %r15, %rax
shlq $0x6, %rax
movq %rax, -0xa8(%rbp)
movq %r11, %rax
mulq -0xa8(%rbp)
movq %rdx, %rcx
leaq -0x88(%rbp), %rbx
movq %rbx, %rsi
movq -0x58(%rbp), %rdx
movq %rcx, -0x70(%rbp)
movq %r13, %r8
movq %r9, -0x90(%rbp)
callq 0x344a0
subq (%rbx), %r15
movq %rax, -0x30(%rbp)
addq %r14, %r15
leaq (,%r15,8), %rsi
cmpq $0x7f00, %rsi           # imm = 0x7F00
ja 0x34481
movq %rsp, %r13
addq $0xf, %rsi
andq $-0x10, %rsi
subq %rsi, %r13
movq %r13, %rsp
movq %r15, %rbx
movq -0x78(%rbp), %rdx
subq %rdx, %rbx
je 0x3417c
leaq (,%rbx,8), %rdx
movq %r13, %rdi
xorl %esi, %esi
callq 0x6170
movq -0x78(%rbp), %rdx
leaq (,%rbx,8), %rdi
addq %r13, %rdi
movq -0x48(%rbp), %rsi
callq 0x2f4c6
movq -0x30(%rbp), %rax
leaq (,%rax,8), %rsi
cmpq $0x7f00, %rsi           # imm = 0x7F00
ja 0x34492
movq %rsp, %rax
addq $0xf, %rsi
andq $-0x10, %rsi
subq %rsi, %rax
movq %rax, %rsp
movq -0x58(%rbp), %rbx
subq $0x8, %rsp
movq -0x90(%rbp), %r14
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
movq %r13, %rcx
movq %r15, %r8
movq -0x38(%rbp), %r9
movq -0x30(%rbp), %r13
pushq %r13
callq 0x1fcb0
addq $0x10, %rsp
movq %r15, %rax
subq %r13, %rax
cmpq $0x1, (%r14,%rax,8)
sbbq %r13, %r15
incq %r15
movq %r12, %rdi
movl %ebx, %esi
movq %r14, %rdx
movq %r15, %rcx
callq 0x34b18
movq -0x70(%rbp), %r9
addq %rax, %r9
jmp 0x3431c
movq -0x40(%rbp), %rax
movq $0x0, (%rax)
movb $0x0, (%r15)
xorl %ebx, %ebx
movq -0x68(%rbp), %r14
jmp 0x343eb
movq %r10, -0x30(%rbp)
subq %r10, %r14
shlq $0x6, %r14
movq %r14, -0xb0(%rbp)
movq %r11, %rax
mulq -0xb0(%rbp)
movq %rdx, %rcx
leaq -0x88(%rbp), %rsi
movq -0x58(%rbp), %rbx
movq %rbx, %rdx
movq %rcx, -0x70(%rbp)
movq %r13, %r8
movq %r9, %r15
callq 0x344a0
movq %rax, %r13
movq -0x78(%rbp), %r14
movq %r15, %rdi
cmpq %rax, %r14
jle 0x3428c
movq -0x48(%rbp), %rsi
movq %r14, %rdx
movq -0x38(%rbp), %rcx
movq %r13, %r8
jmp 0x3429a
movq -0x38(%rbp), %rsi
movq %r13, %rdx
movq -0x48(%rbp), %rcx
movq %r14, %r8
callq 0x1cd58
addq %r14, %r13
movq %r15, %rsi
cmpq $0x1, -0x8(%r15,%r13,8)
sbbq $0x0, %r13
movq -0x30(%rbp), %r15
addq -0x88(%rbp), %r15
subq %r15, %r14
movq %r14, %rcx
jns 0x34301
movq %rcx, %rbx
negq %rbx
leaq (,%rcx,8), %rax
movq %rsi, %rdi
subq %rax, %rdi
movq %r13, %rdx
movq %rsi, %r14
movq %rcx, %r15
callq 0x353c0
shlq $0x3, %rbx
movq %r14, %rdi
xorl %esi, %esi
movq %rbx, %rdx
movq -0x58(%rbp), %rbx
callq 0x6170
movq %r14, %rsi
subq %r15, %r13
xorl %ecx, %ecx
leaq (%rsi,%rcx,8), %rdx
subq %rcx, %r13
movq %r12, %rdi
movl %ebx, %esi
movq %r13, %rcx
callq 0x34b18
movq %rax, %r9
subq -0x70(%rbp), %r9
movq -0x40(%rbp), %r10
movq -0x80(%rbp), %r8
cmpq %r8, %rax
movq -0xa0(%rbp), %r15
movq -0x98(%rbp), %rsi
movq -0x50(%rbp), %rdi
jbe 0x34380
movzbl (%r12,%r8), %ecx
addl %ecx, %ecx
cmpl %ebx, %ecx
jl 0x34380
leaq -0x1(%r8), %rcx
movq %r8, %rax
movb (%r12,%rcx), %dl
incb %dl
movb %dl, (%r12,%rcx)
movzbl %dl, %edx
cmpl %edx, %ebx
jne 0x34377
testq %rcx, %rcx
je 0x3436a
decq %rax
movb $0x1, %dl
jmp 0x34379
movb $0x1, (%r12)
incq %r9
movl $0x1, %eax
xorl %edx, %edx
decq %rcx
testb %dl, %dl
jne 0x3434d
cmpq %rax, %r8
cmovbq %r8, %rax
incq %rax
cmpq $0x1, %rax
je 0x343a1
leaq -0x1(%rax), %rbx
cmpb $0x0, -0x2(%r12,%rax)
movq %rbx, %rax
je 0x3438a
jmp 0x343a3
xorl %ebx, %ebx
movl 0x4(%rsi), %eax
shrl $0x1f, %eax
addq %r15, %rax
testq %rbx, %rbx
je 0x343c6
xorl %ecx, %ecx
movzbl (%r12,%rcx), %edx
movb (%rdi,%rdx), %dl
movb %dl, (%rax,%rcx)
incq %rcx
cmpq %rbx, %rcx
jb 0x343b3
movb $0x0, (%rax,%rbx)
movq %r9, (%r10)
cmpl $0x0, 0x4(%rsi)
jns 0x343da
movb $0x2d, (%r15)
incq %rbx
movq -0x68(%rbp), %r14
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
jne 0x34477
testq %r14, %r14
je 0x3440d
incq %rbx
cmpq %rbx, %r14
je 0x3440d
leaq 0x13ea1(%rip), %rax     # 0x482a0
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq *(%rax)
movq %rax, %r15
movq %r15, %rax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r10, -0x30(%rbp)
leaq -0x60(%rbp), %rdi
movq %r8, %r15
movq %r9, %r13
movq %r11, %r12
callq 0x30170
movq %r12, %r11
movq %r13, %r9
movq -0x30(%rbp), %r10
movq -0x80(%rbp), %rcx
movq %r15, %r8
movq %rax, %r12
jmp 0x3405b
movq %r10, -0x30(%rbp)
leaq -0x60(%rbp), %rdi
movq %r9, -0x48(%rbp)
movq %r11, -0x38(%rbp)
callq 0x30170
movq -0x38(%rbp), %r11
movq -0x48(%rbp), %r9
movq -0x30(%rbp), %r10
movq %rax, %rdi
jmp 0x340ce
callq 0x301a3
jmp 0x343eb
leaq -0x60(%rbp), %rdi
callq 0x30170
movq %rax, %r13
jmp 0x3415a
leaq -0x60(%rbp), %rdi
callq 0x30170
jmp 0x341ba