// File: /workspace/github_cpp_makefile_star2_O2/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 0x2d85c
leaq 0x6fe3(%rip), %r12      # 0x34824
cmpl $0x2, %r14d
jb 0x2d877
cmpl $0x25, %r14d
jb 0x2d880
cmpl $0x3e, %r14d
ja 0x2d86f
leaq 0x701a(%rip), %r12      # 0x34874
jmp 0x2d880
leaq 0x6fe6(%rip), %r12      # 0x34849
cmpl $-0x1, %r14d
je 0x2d877
cmpl $-0x24, %r14d
jae 0x2d87d
xorl %r13d, %r13d
jmp 0x2d9fd
pushq $0xa
popq %r14
jmp 0x2d880
negl %r14d
testq %r13, %r13
je 0x2d892
movq $0x0, -0x30(%rbp)
jmp 0x2d931
movl %ebx, %ecx
testq %rcx, %rcx
je 0x2d8ef
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
imulq $0x28, %rax, %rax
testl %esi, %r14d
jne 0x2d8f7
leaq 0x3844(%rip), %rsi      # 0x31120
movslq 0x18(%rsi,%rax), %rsi
leaq (%rdx,%rsi), %rax
decq %rax
xorl %edx, %edx
divq %rsi
jmp 0x2d914
movq %r8, %r15
pushq $0x1
popq %rax
jmp 0x2d914
leaq 0x3822(%rip), %rsi      # 0x31120
movq 0x8(%rsi,%rax), %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 0x15973(%rip), %rax     # 0x43298
movq %rdi, -0x30(%rbp)
callq *(%rax)
movq %rax, %r13
movq %r15, %r8
testl %ebx, %ebx
js 0x2d93a
movq %r13, %r15
jmp 0x2d946
leaq 0x1(%r13), %r15
movb $0x2d, (%r13)
negq %rbx
andq $0x0, -0x38(%rbp)
movq 0x8(%r8), %rdx
leal -0x1(%r14), %eax
testl %eax, %r14d
je 0x2d99b
movq %r13, -0x48(%rbp)
leaq (,%rbx,8), %rsi
orq $0x8, %rsi
cmpq $0x7f00, %rsi           # imm = 0x7F00
ja 0x2da16
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 0x290c6
movq %r13, %rdx
movq -0x48(%rbp), %r13
movq %r15, %rdi
movl %r14d, %esi
movq %rbx, %rcx
callq 0x2dd38
movq %rax, %rbx
xorl %eax, %eax
movq -0x30(%rbp), %r14
cmpq %rax, %rbx
je 0x2d9c9
movsbq (%r15,%rax), %rcx
movb (%r12,%rcx), %cl
movb %cl, (%r15,%rax)
incq %rax
jmp 0x2d9b2
movb $0x0, (%r15,%rbx)
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
jne 0x2da0f
testq %r14, %r14
je 0x2d9fd
subq %r13, %r15
leaq (%r15,%rbx), %rdx
incq %rdx
cmpq %rdx, %r14
je 0x2d9fd
leaq 0x158ae(%rip), %rax     # 0x432a0
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 0x29df3
jmp 0x2d9d7
leaq -0x38(%rbp), %rdi
movq %r8, -0x40(%rbp)
callq 0x29dc0
movq %rax, %r13
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdx
jmp 0x2d986
nop