// File: /workspace/github_cpp_makefile_star2_O3/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
movq 0x10(%r8), %rax
movq %rax, -0x60(%rbp)
movl 0x4(%r8), %r15d
movl %r15d, %r14d
negl %r14d
cmovsl %r15d, %r14d
movq 0x8(%r8), %r11
testl %edx, %edx
js 0x33ab0
leaq 0x6d94(%rip), %rax      # 0x3a824
cmpl $0x2, %edx
jb 0x33ac9
cmpl $0x25, %edx
jb 0x33ad8
cmpl $0x3e, %edx
ja 0x33ac1
movq %rsi, -0x50(%rbp)
leaq 0x6dca(%rip), %rax      # 0x3a874
movq %rax, -0x38(%rbp)
jmp 0x33aec
leaq 0x6d92(%rip), %rax      # 0x3a849
cmpl $-0x1, %edx
je 0x33ac9
cmpl $-0x24, %edx
jae 0x33ae2
xorl %r9d, %r9d
jmp 0x33f88
movq %rax, -0x38(%rbp)
movq %rsi, -0x50(%rbp)
movl $0xa, %edx
jmp 0x33aec
movq %rax, -0x38(%rbp)
movq %rsi, -0x50(%rbp)
jmp 0x33aec
movq %rax, -0x38(%rbp)
movq %rsi, -0x50(%rbp)
negl %edx
movl %edx, %r10d
leaq (%r10,%r10,4), %r12
leaq 0x3626(%rip), %rsi      # 0x37120
movq 0x8(%rsi,%r12,8), %r13
movslq (%r8), %rax
shlq $0x6, %rax
addq $-0x40, %rax
movq %rax, -0xc0(%rbp)
movq %r13, %rax
mulq -0xc0(%rbp)
addq $0x2, %rdx
leaq -0x1(%rcx), %rax
cmpq %rdx, %rax
cmovbq %rcx, %rdx
testq %r9, %r9
movq %rdx, -0x78(%rbp)
movq %r10, -0x40(%rbp)
je 0x33b41
movq $0x0, -0x70(%rbp)
jmp 0x33b6e
movq %r11, -0x30(%rbp)
leaq 0x2(%rdx), %rdi
leaq 0x13740(%rip), %rax     # 0x47290
movq %rdi, -0x70(%rbp)
movq %r8, %rbx
callq *(%rax)
leaq 0x35c0(%rip), %rsi      # 0x37120
movq -0x30(%rbp), %r11
movq -0x40(%rbp), %r10
movq %rbx, %r8
movq %rax, %r9
testl %r15d, %r15d
je 0x33d74
leaq (%rsi,%r12,8), %rbx
movq $0x0, -0x68(%rbp)
movq -0x78(%rbp), %rcx
leaq 0x83(%rcx), %rsi
cmpq $0x7f00, %rsi           # imm = 0x7F00
movq %r9, -0x80(%rbp)
movq %r13, -0x48(%rbp)
ja 0x33f9a
movq %rsp, %r12
addq $0xf, %rsi
andq $-0x10, %rsi
subq %rsi, %r12
movq %r12, %rsp
movq 0x10(%rbx), %rax
movq %rcx, -0xb8(%rbp)
mulq -0xb8(%rbp)
shrq $0x3, %rdx
movabsq $0x3ffffffffffffff, %r15 # imm = 0x3FFFFFFFFFFFFFF
andq %rdx, %r15
leaq 0x2(%r15), %r13
cmpq %r14, %r13
movq %r14, %rax
cmovbq %r13, %rax
movq %rax, -0x58(%rbp)
xorl %ebx, %ebx
subq %r13, %r14
cmovaeq %r14, %rbx
leaq 0x8(,%r15,2), %r14
movq %r14, %rsi
shlq $0x4, %rsi
cmpq $0x3f4, %r15            # imm = 0x3F4
movq %r8, -0xa0(%rbp)
ja 0x33fbf
movq %rsp, %rdi
addq $0xf, %rsi
andq $-0x10, %rsi
subq %rsi, %rdi
movq %rdi, %rsp
movq -0x60(%rbp), %rax
leaq (%rax,%rbx,8), %rax
movq %rax, -0x60(%rbp)
leaq (%rdi,%r14,8), %r9
addq $0x3, %r15
movq %r11, %rbx
subq %r13, %rbx
jle 0x33d8e
movq %rbx, %rax
shlq $0x6, %rax
movq %rax, -0xa8(%rbp)
movq -0x48(%rbp), %rax
mulq -0xa8(%rbp)
movq %rdx, %rcx
leaq -0x88(%rbp), %r14
movq %rdi, -0x90(%rbp)
movq %r14, %rsi
movq %r10, %rdx
movq %rcx, -0x48(%rbp)
movq %r15, %r8
movq %r9, -0x98(%rbp)
callq 0x34009
subq (%r14), %rbx
movq %rax, -0x30(%rbp)
addq %r13, %rbx
leaq (,%rbx,8), %rsi
cmpq $0x7f00, %rsi           # imm = 0x7F00
ja 0x33fea
movq %rsp, %r15
addq $0xf, %rsi
andq $-0x10, %rsi
subq %rsi, %r15
movq %r15, %rsp
movq -0x38(%rbp), %r13
movq %rbx, %r14
movq -0x58(%rbp), %rdx
subq %rdx, %r14
je 0x33cdf
leaq (,%r14,8), %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x6170
movq -0x58(%rbp), %rdx
leaq (%r15,%r14,8), %rdi
movq -0x60(%rbp), %rsi
callq 0x2f106
movq -0x30(%rbp), %rax
leaq (,%rax,8), %rsi
cmpq $0x7f00, %rsi           # imm = 0x7F00
ja 0x33ffb
movq %rsp, %rax
addq $0xf, %rsi
andq $-0x10, %rsi
subq %rsi, %rax
movq %rax, %rsp
subq $0x8, %rsp
movq -0x98(%rbp), %r14
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
movq %r15, %rcx
movq %rbx, %r8
movq -0x90(%rbp), %r9
movq -0x30(%rbp), %r15
pushq %r15
callq 0x1f79c
addq $0x10, %rsp
movq %rbx, %rax
subq %r15, %rax
cmpq $0x1, (%r14,%rax,8)
sbbq %r15, %rbx
incq %rbx
movq %r12, %rdi
movq -0x40(%rbp), %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x34698
movq -0x48(%rbp), %r10
addq %rax, %r10
jmp 0x33e83
movq -0x50(%rbp), %rax
movq $0x0, (%rax)
movb $0x0, (%r9)
xorl %ebx, %ebx
movq -0x70(%rbp), %r14
jmp 0x33f66
movq %r11, -0x30(%rbp)
subq %r11, %r13
shlq $0x6, %r13
movq %r13, -0xb0(%rbp)
movq -0x48(%rbp), %rax
mulq -0xb0(%rbp)
movq %rdx, %rcx
leaq -0x88(%rbp), %rsi
movq %r10, %rdx
movq %rdi, %r13
movq %rcx, -0x48(%rbp)
movq %r15, %r8
movq %r9, %r14
callq 0x34009
movq %rax, %r15
movq -0x58(%rbp), %rbx
movq %r14, %rdi
cmpq %rax, %rbx
jle 0x33de8
movq -0x60(%rbp), %rsi
movq %rbx, %rdx
movq %r13, %rcx
movq %r15, %r8
jmp 0x33df5
movq %r13, %rsi
movq %r15, %rdx
movq -0x60(%rbp), %rcx
movq %rbx, %r8
callq 0x1c838
movq -0x38(%rbp), %r13
addq %rbx, %r15
movq %r14, %rcx
cmpq $0x1, -0x8(%r14,%r15,8)
sbbq $0x0, %r15
movq -0x30(%rbp), %r14
addq -0x88(%rbp), %r14
subq %r14, %rbx
movq -0x40(%rbp), %rsi
movq %rbx, %r8
jns 0x33e6a
movq %r8, %r14
negq %r14
leaq (,%r8,8), %rax
movq %rcx, %rdi
subq %rax, %rdi
movq %rcx, %rsi
movq %r15, %rdx
movq %rcx, %rbx
movq %r8, -0x58(%rbp)
callq 0x34f40
shlq $0x3, %r14
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x6170
movq %rbx, %rcx
movq -0x40(%rbp), %rsi
subq -0x58(%rbp), %r15
xorl %r8d, %r8d
leaq (%rcx,%r8,8), %rdx
subq %r8, %r15
movq %r12, %rdi
movq %r15, %rcx
callq 0x34698
movq %rax, %r10
subq -0x48(%rbp), %r10
movq -0x78(%rbp), %rsi
cmpq %rsi, %rax
movq -0x80(%rbp), %r9
movq -0xa0(%rbp), %rdi
movq -0x70(%rbp), %r14
jbe 0x33ef7
movzbl (%r12,%rsi), %ecx
addl %ecx, %ecx
movq -0x40(%rbp), %r8
cmpl %r8d, %ecx
jb 0x33ef7
movb -0x1(%rsi,%r12), %al
incb %al
movb %al, -0x1(%rsi,%r12)
movzbl %al, %eax
cmpl %eax, %r8d
jne 0x33ee5
movq %rsi, %rcx
cmpq $0x1, %rcx
je 0x33eea
leaq -0x1(%rcx), %rax
movb -0x2(%r12,%rcx), %dl
incb %dl
movb %dl, -0x2(%r12,%rcx)
movzbl %dl, %edx
movq %rax, %rcx
cmpl %edx, %r8d
je 0x33ec2
jmp 0x33ef7
movq %rsi, %rax
jmp 0x33ef7
movb $0x1, (%r12)
incq %r10
movl $0x1, %eax
cmpq %rax, %rsi
cmovbq %rsi, %rax
incq %rax
cmpq $0x1, %rax
je 0x33f3a
leaq -0x1(%rax), %rbx
cmpb $0x0, -0x2(%r12,%rax)
movq %rbx, %rax
je 0x33f01
movl 0x4(%rdi), %eax
shrl $0x1f, %eax
leaq (%r9,%rax), %rcx
xorl %edx, %edx
movzbl (%r12,%rdx), %esi
movb (%r13,%rsi), %sil
movb %sil, (%rcx,%rdx)
incq %rdx
cmpq %rbx, %rdx
jb 0x33f22
jmp 0x33f42
movl 0x4(%rdi), %eax
shrl $0x1f, %eax
xorl %ebx, %ebx
addq %r9, %rax
movb $0x0, (%rbx,%rax)
movq -0x50(%rbp), %rax
movq %r10, (%rax)
cmpl $0x0, 0x4(%rdi)
jns 0x33f5d
movb $0x2d, (%r9)
incq %rbx
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
jne 0x33fdc
testq %r14, %r14
je 0x33f88
incq %rbx
cmpq %rbx, %r14
je 0x33f88
leaq 0x1331e(%rip), %rax     # 0x47298
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
movq %r11, %r12
leaq -0x68(%rbp), %rdi
movq %r8, %r15
callq 0x2fdb0
movq %r12, %r11
movq -0x40(%rbp), %r10
movq -0x78(%rbp), %rcx
movq %r15, %r8
movq %rax, %r12
jmp 0x33bb4
movq %r11, -0x30(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x2fdb0
movq -0x30(%rbp), %r11
movq -0x40(%rbp), %r10
movq %rax, %rdi
jmp 0x33c26
callq 0x2fde3
movq -0x80(%rbp), %r9
jmp 0x33f66
leaq -0x68(%rbp), %rdi
callq 0x2fdb0
movq %rax, %r15
jmp 0x33cb9
leaq -0x68(%rbp), %rdi
callq 0x2fdb0
jmp 0x33d16