// File: /workspace/github_cpp_makefile_star2_O2/marxn[P]pupp/3rdparty/gmp/mpn/set_str.c
// Function: _gmpn_bc_set_str
mp_size_t
mpn_bc_set_str (mp_ptr rp, const unsigned char *str, size_t str_len, int base)
{
  mp_size_t size;
  size_t i;
  long j;
  mp_limb_t cy_limb;

  mp_limb_t big_base;
  int chars_per_limb;
  mp_limb_t res_digit;

  ASSERT (base >= 2);
  ASSERT (base < numberof (mp_bases));
  ASSERT (str_len >= 1);

  big_base = mp_bases[base].big_base;
  chars_per_limb = mp_bases[base].chars_per_limb;

  size = 0;
  for (i = chars_per_limb; i < str_len; i += chars_per_limb)
    {
      res_digit = *str++;
      if (base == 10)
	{ /* This is a common case.
	     Help the compiler to avoid multiplication.  */
	  for (j = MP_BASES_CHARS_PER_LIMB_10 - 1; j != 0; j--)
	    res_digit = res_digit * 10 + *str++;
	}
      else
	{
	  for (j = chars_per_limb - 1; j != 0; j--)
	    res_digit = res_digit * base + *str++;
	}

      if (size == 0)
	{
	  if (res_digit != 0)
	    {
	      rp[0] = res_digit;
	      size = 1;
	    }
	}
      else
	{
#if HAVE_NATIVE_mpn_mul_1c
	  cy_limb = mpn_mul_1c (rp, rp, size, big_base, res_digit);
#else
	  cy_limb = mpn_mul_1 (rp, rp, size, big_base);
	  cy_limb += mpn_add_1 (rp, rp, size, res_digit);
#endif
	  if (cy_limb != 0)
	    rp[size++] = cy_limb;
	}
    }

  big_base = base;
  res_digit = *str++;
  if (base == 10)
    { /* This is a common case.
	 Help the compiler to avoid multiplication.  */
      for (j = str_len - (i - MP_BASES_CHARS_PER_LIMB_10) - 1; j > 0; j--)
	{
	  res_digit = res_digit * 10 + *str++;
	  big_base *= 10;
	}
    }
  else
    {
      for (j = str_len - (i - chars_per_limb) - 1; j > 0; j--)
	{
	  res_digit = res_digit * base + *str++;
	  big_base *= base;
	}
    }

  if (size == 0)
    {
      if (res_digit != 0)
	{
	  rp[0] = res_digit;
	  size = 1;
	}
    }
  else
    {
#if HAVE_NATIVE_mpn_mul_1c
      cy_limb = mpn_mul_1c (rp, rp, size, big_base, res_digit);
#else
      cy_limb = mpn_mul_1 (rp, rp, size, big_base);
      cy_limb += mpn_add_1 (rp, rp, size, res_digit);
#endif
      if (cy_limb != 0)
	rp[size++] = cy_limb;
    }
  return size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r9
movq %rsi, %r12
movq %rdi, %rbp
movl %ecx, 0x4(%rsp)
movslq %ecx, %r13
imulq $0x28, %r13, %rax
leaq 0x1696a(%rip), %rcx     # 0x31120
movq 0x18(%rcx,%rax), %rdx
movq %rdx, 0x28(%rsp)
movslq (%rcx,%rax), %rcx
leal -0x1(%rcx), %eax
movslq %eax, %r14
leaq 0x1(%r14), %rax
movq %rax, 0x20(%rsp)
leaq -0x1(%r9), %r10
xorl %ebx, %ebx
movq %rcx, 0x30(%rsp)
movq %rcx, %r11
movq %r9, 0x8(%rsp)
leaq 0x1(%r12), %rax
movzbl (%r12), %r8d
cmpq %r9, %r11
jae 0x1a89f
cmpl $0xa, 0x4(%rsp)
jne 0x1a81a
pushq $-0x12
popq %rax
testq %rax, %rax
je 0x1a831
imulq $0xa, %r8, %rcx
movzbl 0x13(%r12,%rax), %r8d
addq %rcx, %r8
incq %rax
jmp 0x1a803
xorl %ecx, %ecx
cmpq %rcx, %r14
je 0x1a837
imulq %r13, %r8
movzbl (%rax,%rcx), %esi
addq %rsi, %r8
incq %rcx
jmp 0x1a81c
pushq $0x13
popq %r15
jmp 0x1a83c
movq 0x20(%rsp), %r15
testq %rbx, %rbx
je 0x1a87c
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rbp, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movq 0x28(%rsp), %rcx
callq 0x18080
testq %rax, %rax
je 0x1a86b
movq %rax, (%rbp,%rbx,8)
incq %rbx
movq 0x8(%rsp), %r9
movq 0x18(%rsp), %r10
movq 0x10(%rsp), %r11
jmp 0x1a88c
testq %r8, %r8
je 0x1a88a
movq %r8, (%rbp)
pushq $0x1
popq %rbx
jmp 0x1a88c
xorl %ebx, %ebx
addq %r15, %r12
movq 0x30(%rsp), %rax
addq %rax, %r11
subq %rax, %r10
jmp 0x1a7e6
cmpl $0xa, 0x4(%rsp)
jne 0x1a8cc
subq %r11, %r9
addq $0x12, %r9
pushq $0xa
popq %rcx
testq %r9, %r9
jle 0x1a8ea
imulq $0xa, %r8, %rsi
movzbl (%rax), %r8d
incq %rax
addq %rsi, %r8
imulq $0xa, %rcx, %rcx
decq %r9
jmp 0x1a8b0
movq %r13, %rcx
testq %r10, %r10
jle 0x1a8ea
imulq %r13, %r8
movzbl (%rax), %esi
incq %rax
addq %rsi, %r8
imulq %r13, %rcx
decq %r10
jmp 0x1a8cf
testq %rbx, %rbx
je 0x1a90f
movq %rbp, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x18080
testq %rax, %rax
je 0x1a90a
movq %rax, (%rbp,%rbx,8)
incq %rbx
movq %rbx, %rax
jmp 0x1a91f
testq %r8, %r8
je 0x1a91d
movq %r8, (%rbp)
pushq $0x1
popq %rax
jmp 0x1a91f
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq