// File: /workspace/github_cpp_makefile_star2_O3/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 $0x28, %rsp
movq %rdx, %r9
movq %rsi, %r15
movq %rdi, %r12
movl %ecx, (%rsp)
movslq %ecx, %r13
leaq (,%r13,4), %rax
addq %r13, %rax
leaq 0x18af8(%rip), %rcx     # 0x37120
movslq (%rcx,%rax,8), %r10
cmpq %rdx, %r10
jae 0x1e70b
movq 0x18(%rcx,%rax,8), %rax
movq %rax, 0x20(%rsp)
leal -0x1(%r10), %eax
movl %eax, 0x4(%rsp)
movslq %eax, %r14
leaq 0x1(%r14), %rax
movq %rax, 0x18(%rsp)
xorl %ebx, %ebx
movq %r10, %rbp
movq %r9, 0x10(%rsp)
movq %r10, 0x8(%rsp)
movzbl (%r15), %r8d
cmpl $0xa, (%rsp)
jne 0x1e68d
movl $0x1, %eax
leaq (%r8,%r8,4), %rcx
movzbl (%r15,%rax), %esi
leaq (%rsi,%rcx,2), %r8
incq %rax
cmpq $0x13, %rax
jne 0x1e671
addq $0x13, %r15
jmp 0x1e6bb
leaq 0x1(%r15), %rax
cmpl $0x0, 0x4(%rsp)
je 0x1e6b8
xorl %ecx, %ecx
movq %r8, %rsi
imulq %r13, %rsi
movzbl (%rax,%rcx), %r8d
addq %rsi, %r8
incq %rcx
cmpq %rcx, %r14
jne 0x1e69a
addq 0x18(%rsp), %r15
jmp 0x1e6bb
movq %rax, %r15
testq %rbx, %rbx
je 0x1e6eb
movq %r12, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq 0x20(%rsp), %rcx
callq 0x1be60
testq %rax, %rax
je 0x1e6df
movq %rax, (%r12,%rbx,8)
incq %rbx
movq 0x10(%rsp), %r9
movq 0x8(%rsp), %r10
jmp 0x1e6fd
testq %r8, %r8
je 0x1e6fb
movq %r8, (%r12)
movl $0x1, %ebx
jmp 0x1e6fd
xorl %ebx, %ebx
addq %r10, %rbp
cmpq %r9, %rbp
jb 0x1e662
jmp 0x1e710
xorl %ebx, %ebx
movq %r10, %rbp
movzbl (%r15), %r8d
incq %r15
cmpl $0xa, (%rsp)
jne 0x1e753
subq %rbp, %r9
leaq 0x12(%r9), %rax
testq %rax, %rax
jle 0x1e787
addq $0x13, %r9
movl $0xa, %ecx
leaq (%r8,%r8,4), %rax
movzbl (%r15), %esi
incq %r15
leaq (%rsi,%rax,2), %r8
addq %rcx, %rcx
leaq (%rcx,%rcx,4), %rcx
decq %r9
cmpq $0x1, %r9
ja 0x1e732
jmp 0x1e791
addq %r9, %r10
movq %rbp, %rax
notq %rax
addq %r10, %rax
testq %rax, %rax
jle 0x1e78e
subq %rbp, %r10
movq %r13, %rcx
imulq %r13, %r8
movzbl (%r15), %eax
incq %r15
addq %rax, %r8
imulq %r13, %rcx
decq %r10
cmpq $0x1, %r10
ja 0x1e76a
jmp 0x1e791
movl $0xa, %ecx
jmp 0x1e791
movq %r13, %rcx
testq %rbx, %rbx
je 0x1e7b5
movq %r12, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x1be60
testq %rax, %rax
je 0x1e7b0
movq %rax, (%r12,%rbx,8)
incq %rbx
movq %rbx, %rax
jmp 0x1e7c7
testq %r8, %r8
je 0x1e7c5
movq %r8, (%r12)
movl $0x1, %eax
jmp 0x1e7c7
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq