// File: 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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
jmp 0x3a709
jmp 0x3a70b
jmp 0x3a70d
jmp 0x3a70f
jmp 0x3a711
movslq -0x1c(%rbp), %rcx
leaq 0x26b44(%rip), %rax     # 0x61260
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
movslq -0x1c(%rbp), %rcx
leaq 0x26b2a(%rip), %rax     # 0x61260
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x4c(%rbp)
movq $0x0, -0x28(%rbp)
movslq -0x4c(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x3a878
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movzbl (%rax), %eax
movq %rax, -0x58(%rbp)
cmpl $0xa, -0x1c(%rbp)
jne 0x3a7b9
movq $0x12, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x3a7b7
imulq $0xa, -0x58(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rbp)
movzbl (%rcx), %ecx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x3a784
jmp 0x3a801
movl -0x4c(%rbp), %eax
subl $0x1, %eax
cltq
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x3a7ff
movq -0x58(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq %rcx, %rax
movq -0x10(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rbp)
movzbl (%rcx), %ecx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x3a7c5
jmp 0x3a801
cmpq $0x0, -0x28(%rbp)
jne 0x3a824
cmpq $0x0, -0x58(%rbp)
je 0x3a822
movq -0x58(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq $0x1, -0x28(%rbp)
jmp 0x3a865
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq -0x58(%rbp), %r8
callq 0x37200
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x3a863
movq -0x40(%rbp), %rdx
movq -0x8(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x28(%rbp)
movq %rdx, (%rax,%rcx,8)
jmp 0x3a865
jmp 0x3a867
movslq -0x4c(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x3a752
movslq -0x1c(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movzbl (%rax), %eax
movq %rax, -0x58(%rbp)
cmpl $0xa, -0x1c(%rbp)
jne 0x3a8f1
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
subq $0x13, %rcx
subq %rcx, %rax
subq $0x1, %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jle 0x3a8ef
imulq $0xa, -0x58(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rbp)
movzbl (%rcx), %ecx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
imulq $0xa, -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x3a8b3
jmp 0x3a954
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
movslq -0x4c(%rbp), %rdx
subq %rdx, %rcx
subq %rcx, %rax
subq $0x1, %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jle 0x3a952
movq -0x58(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq %rcx, %rax
movq -0x10(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rbp)
movzbl (%rcx), %ecx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movslq -0x1c(%rbp), %rax
imulq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x3a90b
jmp 0x3a954
cmpq $0x0, -0x28(%rbp)
jne 0x3a977
cmpq $0x0, -0x58(%rbp)
je 0x3a975
movq -0x58(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq $0x1, -0x28(%rbp)
jmp 0x3a9b8
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq -0x58(%rbp), %r8
callq 0x37200
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x3a9b6
movq -0x40(%rbp), %rdx
movq -0x8(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x28(%rbp)
movq %rdx, (%rax,%rcx,8)
jmp 0x3a9b8
movq -0x28(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)