// File: /workspace/github_cpp_makefile_star2_O1/marxn[P]pupp/3rdparty/gmp/./mini-gmp/mini-gmp.c
// Function: mpz_div_r_2exp
static void
mpz_div_r_2exp (mpz_t r, const mpz_t u, mp_bitcnt_t bit_index,
		enum mpz_div_round_mode mode)
{
  mp_size_t us, un, rn;
  mp_ptr rp;
  mp_limb_t mask;

  us = u->_mp_size;
  if (us == 0 || bit_index == 0)
    {
      r->_mp_size = 0;
      return;
    }
  rn = (bit_index + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS;
  assert (rn > 0);

  rp = MPZ_REALLOC (r, rn);
  un = GMP_ABS (us);

  mask = GMP_LIMB_MAX >> (rn * GMP_LIMB_BITS - bit_index);

  if (rn > un)
    {
      /* Quotient (with truncation) is zero, and remainder is
	 non-zero */
      if (mode == ((us > 0) ? GMP_DIV_CEIL : GMP_DIV_FLOOR)) /* us != 0 here. */
	{
	  /* Have to negate and sign extend. */
	  mp_size_t i;
	  mp_limb_t cy;

	  for (cy = 1, i = 0; i < un; i++)
	    {
	      mp_limb_t s = ~u->_mp_d[i] + cy;
	      cy = s < cy;
	      rp[i] = s;
	    }
	  assert (cy == 0);
	  for (; i < rn - 1; i++)
	    rp[i] = GMP_LIMB_MAX;

	  rp[rn-1] = mask;
	  us = -us;
	}
      else
	{
	  /* Just copy */
	  if (r != u)
	    mpn_copyi (rp, u->_mp_d, un);

	  rn = un;
	}
    }
  else
    {
      if (r != u)
	mpn_copyi (rp, u->_mp_d, rn - 1);

      rp[rn-1] = u->_mp_d[rn-1] & mask;

      if (mode == ((us > 0) ? GMP_DIV_CEIL : GMP_DIV_FLOOR)) /* us != 0 here. */
	{
	  /* If r != 0, compute 2^{bit_count} - r. */
	  mp_size_t i;

	  for (i = 0; i < rn && rp[i] == 0; i++)
	    ;
	  if (i < rn)
	    {
	      /* r > 0, need to flip sign. */
	      rp[i] = ~rp[i] + 1;
	      while (++i < rn)
		rp[i] = ~rp[i];

	      rp[rn-1] &= mask;

	      /* us is not used for anything else, so we can modify it
		 here to indicate flipped sign. */
	      us = -us;
	    }
	}
    }
  rn = mpn_normalized_size (rp, rn);
  r->_mp_size = us < 0 ? -rn : rn;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %r11d
movq %rdx, %r13
movq %rdi, %r9
movslq 0x4(%rsi), %rdi
testq %rdi, %rdi
sete %cl
testq %rdx, %rdx
sete %dl
xorl %eax, %eax
orb %cl, %dl
jne 0x42a7
leaq 0x3f(%r13), %r15
cmpq $0x3f, %r15
jbe 0x42ba
movq %r15, %r12
shrq $0x6, %r12
movslq (%r9), %rax
cmpq %rax, %r12
jle 0x4109
movl %r11d, -0x2c(%rbp)
movq %rsi, -0x38(%rbp)
movq %rdi, -0x40(%rbp)
cmpq $0x2, %r12
movl $0x1, %ebx
cmovgeq %r12, %rbx
movq 0x8(%r9), %rdi
leaq (,%rbx,8), %rdx
xorl %esi, %esi
movq %r9, %r14
callq *0xbfd2(%rip)           # 0x100a8
movq %r14, %r9
movq %rax, %r14
movq %rax, 0x8(%r9)
movl %ebx, (%r9)
movl 0x4(%r9), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
cmpq %rcx, %rbx
jae 0x40fb
movl $0x0, 0x4(%r9)
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x2c(%rbp), %r11d
jmp 0x410d
movq 0x8(%r9), %r14
movq %rdi, %r10
negq %r10
movq %rdi, %rax
cmovnsq %r10, %rax
movl %r15d, %ecx
andl $0xc0, %ecx
subl %r13d, %ecx
movq $-0x1, %r13
shrq %cl, %r13
cmpq %rax, %r12
jbe 0x418a
xorl %ecx, %ecx
testl %edi, %edi
setg %cl
cmpl %r11d, %ecx
jne 0x41fa
testl %edi, %edi
je 0x423e
movq 0x8(%rsi), %rcx
cmpq $0x1, %rax
adcq $0x0, %rax
movl $0x1, %esi
xorl %edx, %edx
movq %rsi, %rdi
movq (%rcx,%rdx,8), %r8
notq %r8
xorl %esi, %esi
addq %rdi, %r8
setb %sil
movq %r8, (%r14,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x4160
cmpq %rdi, %r8
setae %al
jmp 0x4242
cmpq %rsi, %r9
je 0x41b3
cmpq $0x80, %r15
jb 0x41b3
movq 0x8(%rsi), %rax
leaq -0x1(%r12), %rcx
xorl %edx, %edx
movq (%rax,%rdx,8), %r8
movq %r8, (%r14,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x41a3
movq 0x8(%rsi), %rax
movq -0x8(%rax,%r12,8), %rax
andq %r13, %rax
movq %rax, -0x8(%r14,%r12,8)
xorl %eax, %eax
testl %edi, %edi
setg %al
cmpl %r11d, %eax
jne 0x421c
xorl %ecx, %ecx
cmpq $0x1, %r12
sbbq %r12, %rcx
movl $0x1, %eax
movq -0x8(%r14,%rax,8), %rdx
testq %rdx, %rdx
jne 0x4221
leaq (%rcx,%rax), %rdx
incq %rdx
incq %rax
cmpq $0x1, %rdx
jne 0x41de
jmp 0x421c
cmpq %rsi, %r9
je 0x4219
testl %edi, %edi
je 0x4219
movq 0x8(%rsi), %rcx
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
movq %rsi, (%r14,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x4209
movq %rax, %r12
movq %rdi, %r10
jmp 0x427d
negq %rdx
movq %rdx, -0x8(%r14,%rax,8)
cmpq %r12, %rax
jae 0x4237
notq (%r14,%rax,8)
incq %rax
jmp 0x4229
andq %r13, -0x8(%r14,%r12,8)
jmp 0x427d
xorl %edx, %edx
xorl %eax, %eax
testb %al, %al
je 0x42d9
leaq -0x1(%r12), %rax
cmpq %rax, %rdx
jge 0x4278
leaq (%r14,%rdx,8), %rdi
notq %rdx
addq %r12, %rdx
shlq $0x3, %rdx
movl $0xff, %esi
movq %r9, %rbx
movq %r10, %r15
callq 0x10a0
movq %r15, %r10
movq %rbx, %r9
movq %r13, -0x8(%r14,%r12,8)
testq %r12, %r12
je 0x429b
cmpq $0x0, -0x8(%r14,%r12,8)
jne 0x429b
leaq -0x1(%r12), %rax
cmpq $0x1, %r12
movq %rax, %r12
jg 0x4282
xorl %r12d, %r12d
movl %r12d, %eax
negl %eax
testq %r10, %r10
cmovnsl %r12d, %eax
movl %eax, 0x4(%r9)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6f4f(%rip), %rdi      # 0xb210
leaq 0x5d9c(%rip), %rsi      # 0xa064
leaq 0x6f48(%rip), %rcx      # 0xb217
movl $0x93d, %edx            # imm = 0x93D
callq 0x1090
leaq 0x6157(%rip), %rdi      # 0xa437
leaq 0x5d7d(%rip), %rsi      # 0xa064
leaq 0x6f29(%rip), %rcx      # 0xb217
movl $0x954, %edx            # imm = 0x954
callq 0x1090