// File: marxn[P]pupp/3rdparty/gmp/./mini-gmp/mini-gmp.c
// Function: mpz_sizeinbase
size_t
mpz_sizeinbase (const mpz_t u, int base)
{
  mp_size_t un;
  mp_srcptr up;
  mp_ptr tp;
  mp_bitcnt_t bits;
  struct gmp_div_inverse bi;
  size_t ndigits;

  assert (base >= 2);
  assert (base <= 36);

  un = GMP_ABS (u->_mp_size);
  if (un == 0)
    return 1;

  up = u->_mp_d;

  bits = (un - 1) * GMP_LIMB_BITS + mpn_limb_size_in_base_2 (up[un-1]);
  switch (base)
    {
    case 2:
      return bits;
    case 4:
      return (bits + 1) / 2;
    case 8:
      return (bits + 2) / 3;
    case 16:
      return (bits + 3) / 4;
    case 32:
      return (bits + 4) / 5;
      /* FIXME: Do something more clever for the common case of base
	 10. */
    }

  tp = gmp_xalloc_limbs (un);
  mpn_copyi (tp, up, un);
  mpn_div_qr_1_invert (&bi, base);

  ndigits = 0;
  do
    {
      ndigits++;
      mpn_div_qr_1_preinv (tp, tp, un, &bi);
      un -= (tp[un-1] == 0);
    }
  while (un > 0);

  gmp_free (tp);
  return ndigits;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
cmpl $0x2, -0x14(%rbp)
jl 0x824a
jmp 0x8269
leaq 0x65f4(%rip), %rdi      # 0xe845
leaq 0x5e7c(%rip), %rsi      # 0xe0d4
movl $0xf95, %edx            # imm = 0xF95
leaq 0x65eb(%rip), %rcx      # 0xe84f
callq 0x1070
cmpl $0x24, -0x14(%rbp)
jg 0x8271
jmp 0x8290
leaq 0x6608(%rip), %rdi      # 0xe880
leaq 0x5e55(%rip), %rsi      # 0xe0d4
movl $0xf96, %edx            # imm = 0xF96
leaq 0x65c4(%rip), %rcx      # 0xe84f
callq 0x1070
movq -0x10(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jl 0x82a6
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x64(%rbp)
jmp 0x82b2
movq -0x10(%rbp), %rcx
xorl %eax, %eax
subl 0x4(%rcx), %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
cltq
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x82cf
movq $0x1, -0x8(%rbp)
jmp 0x8439
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rcx
movq %rcx, %rax
decq %rax
shlq $0x6, %rax
movq %rax, -0x78(%rbp)
movq -0x28(%rbp), %rax
movq -0x8(%rax,%rcx,8), %rdi
callq 0xa1e0
movq %rax, %rcx
movq -0x78(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x14(%rbp), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0x70(%rbp)
subl $0x1e, %eax
ja 0x839e
movq -0x70(%rbp), %rax
leaq 0x5d27(%rip), %rcx      # 0xe050
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x8439
movq -0x38(%rbp), %rax
addq $0x1, %rax
shrq %rax
movq %rax, -0x8(%rbp)
jmp 0x8439
movq -0x38(%rbp), %rax
addq $0x2, %rax
movl $0x3, %ecx
xorl %edx, %edx
divq %rcx
movq %rax, -0x8(%rbp)
jmp 0x8439
movq -0x38(%rbp), %rax
addq $0x3, %rax
shrq $0x2, %rax
movq %rax, -0x8(%rbp)
jmp 0x8439
movq -0x38(%rbp), %rax
addq $0x4, %rax
movl $0x5, %ecx
xorl %edx, %edx
divq %rcx
movq %rax, -0x8(%rbp)
jmp 0x8439
movq -0x20(%rbp), %rdi
callq 0x3220
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x1390
movslq -0x14(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0xa2a0
movq $0x0, -0x60(%rbp)
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq -0x58(%rbp), %rcx
callq 0xa390
movq -0x30(%rbp), %rax
movq -0x20(%rbp), %rcx
subq $0x1, %rcx
cmpq $0x0, (%rax,%rcx,8)
sete %al
andb $0x1, %al
movzbl %al, %eax
movslq %eax, %rcx
movq -0x20(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jg 0x83d1
movq 0xac71(%rip), %rax      # 0x13098
movq -0x30(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %esi
callq *%rax
movq -0x60(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)