// File: /workspace/github_cpp_makefile_star2_O3/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, %r8d
movq %rdx, %r13
movq %rdi, %r9
movslq 0x4(%rsi), %rdi
testq %rdi, %rdi
sete %al
testq %rdx, %rdx
sete %dl
xorl %ecx, %ecx
orb %al, %dl
jne 0x4235
leaq 0x3f(%r13), %r12
cmpq $0x3f, %r12
jbe 0x4248
movq %r12, %rbx
shrq $0x6, %rbx
movslq (%r9), %rax
cmpq %rax, %rbx
jle 0x40b0
movq %rsi, -0x38(%rbp)
movl %r8d, -0x2c(%rbp)
movq %rdi, -0x40(%rbp)
cmpq $0x1, %rbx
movq %rbx, %r15
adcq $0x0, %r15
movq 0x8(%r9), %rdi
leaq (,%r15,8), %rdx
xorl %esi, %esi
movq %r9, %r14
callq *0xc02b(%rip)           # 0x100a8
movq %r14, %r9
movq %rax, %r14
movq %rax, 0x8(%r9)
movl %r15d, (%r9)
movl 0x4(%r9), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
cmpq %rcx, %r15
jae 0x40a2
movl $0x0, 0x4(%r9)
movq -0x40(%rbp), %rdi
movl -0x2c(%rbp), %r8d
movq -0x38(%rbp), %rsi
jmp 0x40b4
movq 0x8(%r9), %r14
movq %rdi, %r10
negq %r10
movq %rdi, %rax
cmovnsq %r10, %rax
movl %r12d, %ecx
andl $0xc0, %ecx
subl %r13d, %ecx
movq $-0x1, %r13
shrq %cl, %r13
cmpq %rax, %rbx
jbe 0x4158
xorl %ecx, %ecx
testl %edi, %edi
setg %cl
cmpl %r8d, %ecx
jne 0x41c9
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 0x40ff
cmpq %rdi, %r8
jb 0x4267
leaq -0x1(%rbx), %rdx
subq %rax, %rdx
jle 0x414e
leaq (%r14,%rax,8), %rdi
shlq $0x3, %rdx
movl $0xff, %esi
movq %r9, %r15
movq %r10, %r12
callq 0x10a0
movq %r12, %r10
movq %r15, %r9
movq %r13, -0x8(%r14,%rbx,8)
jmp 0x420c
cmpq %rsi, %r9
sete %cl
movq 0x8(%rsi), %rax
cmpq $0x80, %r12
setb %dl
orb %cl, %dl
jne 0x4186
leaq -0x1(%rbx), %rcx
xorl %edx, %edx
movq (%rax,%rdx,8), %rsi
movq %rsi, (%r14,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x4176
movq -0x8(%rax,%rbx,8), %rax
andq %r13, %rax
movq %rax, -0x8(%r14,%rbx,8)
xorl %eax, %eax
testl %edi, %edi
setg %al
cmpl %r8d, %eax
jne 0x4209
xorl %ecx, %ecx
cmpq $0x1, %rbx
sbbq %rbx, %rcx
movl $0x1, %eax
movq -0x8(%r14,%rax,8), %rdx
testq %rdx, %rdx
jne 0x41e9
leaq (%rcx,%rax), %rdx
incq %rdx
incq %rax
cmpq $0x1, %rdx
jne 0x41ad
jmp 0x4209
cmpq %rsi, %r9
je 0x4206
movq 0x8(%rsi), %rcx
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
movq %rsi, (%r14,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x41d4
movq %rdi, %r10
jmp 0x4214
negq %rdx
movq %rdx, -0x8(%r14,%rax,8)
cmpq %rbx, %rax
jae 0x41ff
notq (%r14,%rax,8)
incq %rax
jmp 0x41f1
andq %r13, -0x8(%r14,%rbx,8)
jmp 0x420c
movq %rax, %rbx
movq %rdi, %r10
testq %rbx, %rbx
je 0x4229
movq %rbx, %rax
cmpq $0x0, -0x8(%r14,%rax,8)
jne 0x422b
leaq -0x1(%rax), %rcx
cmpq $0x1, %rax
movq %rcx, %rax
jg 0x4214
xorl %eax, %eax
movl %eax, %ecx
negl %ecx
testq %r10, %r10
cmovnsl %eax, %ecx
movl %ecx, 0x4(%r9)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6fc1(%rip), %rdi      # 0xb210
leaq 0x5e0e(%rip), %rsi      # 0xa064
leaq 0x6fba(%rip), %rcx      # 0xb217
movl $0x93d, %edx            # imm = 0x93D
callq 0x1090
leaq 0x61c9(%rip), %rdi      # 0xa437
leaq 0x5def(%rip), %rsi      # 0xa064
leaq 0x6f9b(%rip), %rcx      # 0xb217
movl $0x954, %edx            # imm = 0x954
callq 0x1090