// File: /workspace/github_cpp_makefile_star2_O3/marxn[P]pupp/3rdparty/gmp/mpz/get_str.c
// Function: _gmpz_get_str
char *
mpz_get_str (char *res_str, int base, mpz_srcptr x)
{
  mp_ptr xp;
  mp_size_t x_size = SIZ (x);
  char *return_str;
  size_t str_size;
  size_t alloc_size = 0;
  const char *num_to_text;
  int i;
  TMP_DECL;

  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";
    }

  /* allocate string for the user if necessary */
  if (res_str == NULL)
    {
      /* digits, null terminator, possible minus sign */
      MPN_SIZEINBASE (alloc_size, PTR(x), ABS(x_size), base);
      alloc_size += 1 + (x_size<0);
      res_str = (char *) (*__gmp_allocate_func) (alloc_size);
    }
  return_str = res_str;

  if (x_size < 0)
    {
      *res_str++ = '-';
      x_size = -x_size;
    }

  /* mpn_get_str clobbers its input on non power-of-2 bases */
  TMP_MARK;
  xp = PTR (x);
  if (! POW2_P (base))
    {
      xp = TMP_ALLOC_LIMBS (x_size | 1);  /* |1 in case x_size==0 */
      MPN_COPY (xp, PTR (x), x_size);
    }

  str_size = mpn_get_str ((unsigned char *) res_str, base, xp, x_size);
  ASSERT (alloc_size == 0 || str_size <= alloc_size - (SIZ(x) < 0));

  /* Convert result to printable chars.  */
  for (i = 0; i < str_size; i++)
    res_str[i] = num_to_text[(int) res_str[i]];
  res_str[str_size] = 0;

  TMP_FREE;

  /* if allocated then resize down to the actual space required */
  if (alloc_size != 0)
    {
      size_t  actual_size = str_size + 1 + (res_str - return_str);
      ASSERT (actual_size == strlen (return_str) + 1);
      __GMP_REALLOCATE_FUNC_MAYBE_TYPE (return_str, alloc_size, actual_size,
					char);
    }
  return return_str;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r8
movl %esi, %r14d
movq %rdi, %r13
movslq 0x4(%rdx), %rbx
testl %esi, %esi
js 0x341a4
leaq 0x669b(%rip), %r12      # 0x3a824
cmpl $0x2, %r14d
jb 0x341bf
cmpl $0x25, %r14d
jb 0x341ca
cmpl $0x3e, %r14d
ja 0x341b7
leaq 0x66d2(%rip), %r12      # 0x3a874
jmp 0x341ca
leaq 0x669e(%rip), %r12      # 0x3a849
cmpl $-0x1, %r14d
je 0x341bf
cmpl $-0x24, %r14d
jae 0x341c7
xorl %r13d, %r13d
jmp 0x3434f
movl $0xa, %r14d
jmp 0x341ca
negl %r14d
testq %r13, %r13
je 0x341dc
movq $0x0, -0x30(%rbp)
jmp 0x3427d
movl %ebx, %ecx
testq %rcx, %rcx
je 0x34239
movq %rbx, %rdx
negq %rdx
cmovsq %rbx, %rdx
movq 0x8(%r8), %rax
movq -0x8(%rax,%rdx,8), %rax
movq %rax, -0x58(%rbp)
bsrq -0x58(%rbp), %rax
shlq $0x6, %rdx
cltq
xorq $0x3f, %rax
subq %rax, %rdx
leal -0x1(%r14), %esi
movl %r14d, %eax
movq %r8, %r15
leaq (%rax,%rax,4), %rax
testl %esi, %r14d
jne 0x34243
leaq 0x2efa(%rip), %rsi      # 0x37120
movslq 0x18(%rsi,%rax,8), %rsi
leaq (%rdx,%rsi), %rax
decq %rax
xorl %edx, %edx
divq %rsi
jmp 0x34260
movq %r8, %r15
movl $0x1, %eax
jmp 0x34260
leaq 0x2ed6(%rip), %rsi      # 0x37120
movq 0x8(%rsi,%rax,8), %rax
incq %rax
movq %rdx, -0x50(%rbp)
mulq -0x50(%rbp)
movq %rdx, %rax
incq %rax
shrl $0x1f, %ecx
leaq (%rcx,%rax), %rdi
incq %rdi
leaq 0x1301f(%rip), %rax     # 0x47290
movq %rdi, -0x30(%rbp)
callq *(%rax)
movq %rax, %r13
movq %r15, %r8
testl %ebx, %ebx
js 0x34286
movq %r13, %r15
jmp 0x34292
leaq 0x1(%r13), %r15
movb $0x2d, (%r13)
negq %rbx
movq $0x0, -0x38(%rbp)
movq 0x8(%r8), %rdx
leal -0x1(%r14), %eax
testl %eax, %r14d
je 0x342ea
movq %r13, -0x48(%rbp)
leaq (,%rbx,8), %rsi
orq $0x8, %rsi
cmpq $0x7f00, %rsi           # imm = 0x7F00
ja 0x34368
movq %rsp, %r13
addq $0xf, %rsi
andq $-0x10, %rsi
subq %rsi, %r13
movq %r13, %rsp
movq %r13, %rdi
movq %rdx, %rsi
movq %rbx, %rdx
callq 0x2f106
movq %r13, %rdx
movq -0x48(%rbp), %r13
movq %r15, %rdi
movl %r14d, %esi
movq %rbx, %rcx
callq 0x34698
movq %rax, %rbx
testq %rax, %rax
je 0x34317
xorl %eax, %eax
movsbq (%r15,%rax), %rcx
movb (%r12,%rcx), %cl
movb %cl, (%r15,%rax)
incq %rax
cmpq %rax, %rbx
jne 0x34302
movb $0x0, (%r15,%rbx)
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
movq -0x30(%rbp), %r14
jne 0x34361
testq %r14, %r14
je 0x3434f
subq %r13, %r15
leaq (%r15,%rbx), %rdx
incq %rdx
cmpq %rdx, %r14
je 0x3434f
leaq 0x12f54(%rip), %rax     # 0x47298
movq %r13, %rdi
movq %r14, %rsi
callq *(%rax)
movq %rax, %r13
movq %r13, %rax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2fde3
jmp 0x34329
leaq -0x38(%rbp), %rdi
movq %r8, -0x40(%rbp)
callq 0x2fdb0
movq %rax, %r13
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdx
jmp 0x342d5
nopl (%rax)