// File: /workspace/github_cpp_makefile_star2_O3/marxn[P]pupp/3rdparty/gmp/mpn/set_str.c
// Function: _gmpn_set_str
mp_size_t
mpn_set_str (mp_ptr rp, const unsigned char *str, size_t str_len, int base)
{
  if (POW2_P (base))
    {
      /* The base is a power of 2.  Read the input string from least to most
	 significant character/digit.  */

      const unsigned char *s;
      int next_bitpos;
      mp_limb_t res_digit;
      mp_size_t size;
      int bits_per_indigit = mp_bases[base].big_base;

      size = 0;
      res_digit = 0;
      next_bitpos = 0;

      for (s = str + str_len - 1; s >= str; s--)
	{
	  int inp_digit = *s;

	  res_digit |= ((mp_limb_t) inp_digit << next_bitpos) & GMP_NUMB_MASK;
	  next_bitpos += bits_per_indigit;
	  if (next_bitpos >= GMP_NUMB_BITS)
	    {
	      rp[size++] = res_digit;
	      next_bitpos -= GMP_NUMB_BITS;
	      res_digit = inp_digit >> (bits_per_indigit - next_bitpos);
	    }
	}

      if (res_digit != 0)
	rp[size++] = res_digit;
      return size;
    }

  if (BELOW_THRESHOLD (str_len, SET_STR_PRECOMPUTE_THRESHOLD))
    return mpn_bc_set_str (rp, str, str_len, base);
  else
    {
      mp_ptr powtab_mem, tp;
      powers_t powtab[GMP_LIMB_BITS];
      int chars_per_limb;
      mp_size_t size;
      mp_size_t un;
      TMP_DECL;

      TMP_MARK;

      chars_per_limb = mp_bases[base].chars_per_limb;

      un = str_len / chars_per_limb + 1;

      /* Allocate one large block for the powers of big_base.  */
      powtab_mem = TMP_BALLOC_LIMBS (mpn_dc_set_str_powtab_alloc (un));

      mpn_set_str_compute_powtab (powtab, powtab_mem, un, base);

      tp = TMP_BALLOC_LIMBS (mpn_dc_set_str_itch (un));
      size = mpn_dc_set_str (rp, str, str_len, powtab, tp);

      TMP_FREE;
      return size;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa18, %rsp            # imm = 0xA18
movl %ecx, %r12d
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
leal -0x1(%r12), %eax
testl %eax, %ecx
jne 0x1e4d4
leaq (%r14,%r15), %rdx
decq %rdx
xorl %eax, %eax
cmpq %r14, %rdx
jae 0x1e56a
xorl %r15d, %r15d
jmp 0x1e5c2
cmpq $0x6fa, %r15            # imm = 0x6FA
jbe 0x1e5d7
leaq 0x8(%rsp), %rax
movq $0x0, (%rax)
movq %rax, %rdi
movslq %r12d, %rax
leaq (%rax,%rax,4), %rax
leaq 0x18c22(%rip), %rcx     # 0x37120
movslq (%rcx,%rax,8), %rcx
movq %r15, %rax
xorl %edx, %edx
divq %rcx
leaq 0x208(,%rax,8), %rbp
leaq 0x1(%rax), %r13
movq %rbp, %rsi
callq 0x2fdb0
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r13, %rdx
movl %r12d, %ecx
callq 0x1e7d6
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
callq 0x2fdb0
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
leaq 0x10(%rsp), %rcx
movq %rax, %r8
callq 0x1e98a
movq %rax, %r15
movq (%r12), %rdi
testq %rdi, %rdi
je 0x1e5c2
callq 0x2fde3
jmp 0x1e5c2
movslq %r12d, %rcx
leaq (%rcx,%rcx,4), %rcx
leaq 0x18ba8(%rip), %rsi     # 0x37120
movl 0x18(%rsi,%rcx,8), %esi
xorl %edi, %edi
xorl %r15d, %r15d
movq %rdi, %r9
movzbl (%rdx), %r8d
movq %r8, %rdi
movl %eax, %ecx
shlq %cl, %rdi
orq %r9, %rdi
addl %esi, %eax
cmpl $0x40, %eax
jl 0x1e5ae
movq %rdi, (%rbx,%r15,8)
incq %r15
addl $-0x40, %eax
movl %esi, %ecx
subl %eax, %ecx
shrl %cl, %r8d
movq %r8, %rdi
decq %rdx
cmpq %r14, %rdx
jae 0x1e581
testq %rdi, %rdi
je 0x1e5c2
movq %rdi, (%rbx,%r15,8)
incq %r15
movq %r15, %rax
addq $0xa18, %rsp            # imm = 0xA18
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movl %r12d, %ecx
addq $0xa18, %rsp            # imm = 0xA18
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1e5f9