// File: /workspace/github_cpp_makefile_star2_O2/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, %rbx
movq %rsi, %r15
movq %rdi, %r14
leal -0x1(%r12), %eax
testl %eax, %ecx
jne 0x1a6b6
movslq %r12d, %rax
imulq $0x28, %rax, %rax
leaq 0x16abc(%rip), %rcx     # 0x31120
movl 0x18(%rcx,%rax), %eax
addq %r15, %rbx
xorl %r12d, %r12d
xorl %esi, %esi
xorl %edx, %edx
addl $-0x40, %edx
decq %rbx
cmpq %r15, %rbx
jb 0x1a74a
leal 0x40(%rdx), %ecx
movzbl (%rbx), %edi
movq %rdi, %r8
shlq %cl, %r8
orq %r8, %rsi
movl %edx, %ecx
addl %eax, %edx
addl %eax, %ecx
addl $0x40, %ecx
decq %rbx
cmpl $0x40, %ecx
jl 0x1a678
movl %eax, %ecx
subl %edx, %ecx
shrl %cl, %edi
movq %rsi, (%r14,%r12,8)
incq %r12
incq %rbx
movq %rdi, %rsi
jmp 0x1a672
cmpq $0x6fa, %rbx            # imm = 0x6FA
jbe 0x1a76b
leaq 0x8(%rsp), %rax
andq $0x0, (%rax)
movq %rax, %rdi
movslq %r12d, %rax
imulq $0x28, %rax, %rax
leaq 0x16a43(%rip), %rcx     # 0x31120
movslq (%rcx,%rax), %rcx
movq %rbx, %rax
xorl %edx, %edx
divq %rcx
leaq 0x208(,%rax,8), %rbp
leaq 0x1(%rax), %r13
movq %rbp, %rsi
callq 0x29dc0
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r13, %rdx
movl %r12d, %ecx
callq 0x1a92e
leaq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0x29dc0
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
leaq 0x10(%rsp), %rcx
movq %rax, %r8
callq 0x1aada
movq %rax, %r12
leaq 0x8(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x1a756
callq 0x29df3
jmp 0x1a756
testq %rsi, %rsi
je 0x1a756
movq %rsi, (%r14,%r12,8)
incq %r12
movq %r12, %rax
addq $0xa18, %rsp            # imm = 0xA18
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movl %r12d, %ecx
addq $0xa18, %rsp            # imm = 0xA18
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1a78d