// File: /workspace/github_cpp_makefile_star2_O1/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 $0x28, %rsp
movl %esi, %r14d
movslq 0x4(%rdx), %rbx
testl %esi, %esi
js 0x34632
leaq 0x721d(%rip), %r12      # 0x3b834
cmpl $0x2, %r14d
jl 0x3464c
cmpl $0x25, %r14d
jl 0x34657
cmpl $0x3e, %r14d
jg 0x34645
leaq 0x7254(%rip), %r12      # 0x3b884
jmp 0x34657
leaq 0x7220(%rip), %r12      # 0x3b859
cmpl $-0x1, %r14d
je 0x3464c
cmpl $-0x24, %r14d
jge 0x34654
xorl %edi, %edi
jmp 0x347de
movl $0xa, %r14d
jmp 0x34657
negl %r14d
testq %rdi, %rdi
je 0x34664
xorl %r13d, %r13d
jmp 0x34704
movl %ebx, %ecx
testq %rcx, %rcx
je 0x346c1
movq %rbx, %rdi
negq %rdi
cmovsq %rbx, %rdi
movq 0x8(%rdx), %rax
movq -0x8(%rax,%rdi,8), %rax
movq %rax, -0x50(%rbp)
bsrq -0x50(%rbp), %rax
shlq $0x6, %rdi
cltq
xorq $0x3f, %rax
subq %rax, %rdi
leal -0x1(%r14), %esi
movl %r14d, %eax
movq %rdx, %r15
leaq (%rax,%rax,4), %rax
testl %esi, %r14d
jne 0x346cb
leaq 0x3a82(%rip), %rsi      # 0x38130
movslq 0x18(%rsi,%rax,8), %rsi
leaq (%rdi,%rsi), %rax
decq %rax
xorl %edx, %edx
divq %rsi
jmp 0x346e8
movq %rdx, %r15
movl $0x1, %eax
jmp 0x346e8
leaq 0x3a5e(%rip), %rsi      # 0x38130
movq 0x8(%rsi,%rax,8), %rax
incq %rax
movq %rdi, -0x48(%rbp)
mulq -0x48(%rbp)
movq %rdx, %rax
incq %rax
shrl $0x1f, %ecx
leaq (%rcx,%rax), %r13
incq %r13
leaq 0x13b9f(%rip), %rax     # 0x48298
movq %r13, %rdi
callq *(%rax)
movq %rax, %rdi
movq %r15, %rdx
testl %ebx, %ebx
js 0x3470d
movq %rdi, %r15
jmp 0x34717
leaq 0x1(%rdi), %r15
movb $0x2d, (%rdi)
negq %rbx
movq $0x0, -0x38(%rbp)
leal -0x1(%r14), %eax
testl %eax, %r14d
movq %rdi, -0x30(%rbp)
movq %r13, -0x40(%rbp)
jne 0x34736
movq 0x8(%rdx), %r13
jmp 0x3476f
leaq (,%rbx,8), %rsi
orq $0x8, %rsi
cmpq $0x7f00, %rsi           # imm = 0x7F00
ja 0x347f7
movq %rsp, %r13
addq $0xf, %rsi
andq $-0x10, %rsi
subq %rsi, %r13
movq %r13, %rsp
movq 0x8(%rdx), %rsi
movq %r13, %rdi
movq %rbx, %rdx
callq 0x2f4c6
movq %r15, %rdi
movl %r14d, %esi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x34b18
movq %rax, %rbx
testq %rax, %rax
je 0x3479f
xorl %eax, %eax
movsbq (%r15,%rax), %rcx
movb (%r12,%rcx), %cl
movb %cl, (%r15,%rax)
incq %rax
cmpq %rax, %rbx
jne 0x3478a
movb $0x0, (%r15,%rbx)
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
movq -0x40(%rbp), %r14
jne 0x347f0
testq %r14, %r14
je 0x347da
movq -0x30(%rbp), %rdi
subq %rdi, %r15
leaq (%r15,%rbx), %rdx
incq %rdx
cmpq %rdx, %r14
je 0x347de
leaq 0x13ad0(%rip), %rax     # 0x482a0
movq %r14, %rsi
callq *(%rax)
movq %rax, %rdi
jmp 0x347de
movq -0x30(%rbp), %rdi
movq %rdi, %rax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x301a3
jmp 0x347b1
leaq -0x38(%rbp), %rdi
movq %rdx, %r13
callq 0x30170
movq %r13, %rdx
movq %rax, %r13
jmp 0x34760
nop