// File: /workspace/github_cpp_makefile_star2_O1/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 0x195d5(%rip), %rcx     # 0x38130
movslq (%rcx,%rax,8), %r10
cmpq %rdx, %r10
jae 0x1ec3e
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 0x1ebc0
movl $0x1, %eax
leaq (%r8,%r8,4), %rcx
movzbl (%r15,%rax), %esi
leaq (%rsi,%rcx,2), %r8
incq %rax
cmpq $0x13, %rax
jne 0x1eba4
addq $0x13, %r15
jmp 0x1ebee
leaq 0x1(%r15), %rax
cmpl $0x0, 0x4(%rsp)
je 0x1ebeb
xorl %ecx, %ecx
movq %r8, %rsi
imulq %r13, %rsi
movzbl (%rax,%rcx), %r8d
addq %rsi, %r8
incq %rcx
cmpq %rcx, %r14
jne 0x1ebcd
addq 0x18(%rsp), %r15
jmp 0x1ebee
movq %rax, %r15
testq %rbx, %rbx
je 0x1ec1e
movq %r12, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq 0x20(%rsp), %rcx
callq 0x1c380
testq %rax, %rax
je 0x1ec12
movq %rax, (%r12,%rbx,8)
incq %rbx
movq 0x10(%rsp), %r9
movq 0x8(%rsp), %r10
jmp 0x1ec30
testq %r8, %r8
je 0x1ec2e
movq %r8, (%r12)
movl $0x1, %ebx
jmp 0x1ec30
xorl %ebx, %ebx
addq %r10, %rbp
cmpq %r9, %rbp
jb 0x1eb95
jmp 0x1ec43
xorl %ebx, %ebx
movq %r10, %rbp
movzbl (%r15), %r8d
incq %r15
cmpl $0xa, (%rsp)
jne 0x1ec84
subq %rbp, %r9
leaq 0x12(%r9), %rax
testq %rax, %rax
jle 0x1ecb8
addq $0x13, %r9
movq %r13, %rcx
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
jg 0x1ec63
jmp 0x1ecbb
addq %r9, %r10
movq %rbp, %rax
notq %rax
addq %r10, %rax
testq %rax, %rax
jle 0x1ecb8
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
jg 0x1ec9b
jmp 0x1ecbb
movq %r13, %rcx
testq %rbx, %rbx
je 0x1ecdf
movq %r12, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x1c380
testq %rax, %rax
je 0x1ecda
movq %rax, (%r12,%rbx,8)
incq %rbx
movq %rbx, %rax
jmp 0x1ecf1
testq %r8, %r8
je 0x1ecef
movq %r8, (%r12)
movl $0x1, %eax
jmp 0x1ecf1
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq