// File: /workspace/github_cpp_makefile_star2_O2/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 $0x28, %rsp
movl %ecx, %r9d
movq %rdx, %rbx
movq %rsi, %r12
movslq 0x4(%rsi), %rsi
testq %rsi, %rsi
sete %al
testq %rdx, %rdx
sete %dl
xorl %ecx, %ecx
orb %al, %dl
jne 0x3aa1
leaq 0x3f(%rbx), %r13
cmpq $0x3f, %r13
jbe 0x3ab3
movq %r13, %r8
shrq $0x6, %r8
movslq (%rdi), %rax
cmpq %rax, %r8
movq %r8, -0x38(%rbp)
jle 0x393b
movq %rdi, %r14
movq %rsi, -0x30(%rbp)
movq %r8, %rsi
movl %r9d, %r15d
callq 0x228f
movl %r15d, %r9d
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %r8
movq %r14, %rdi
movq %rax, %r15
jmp 0x393f
movq 0x8(%rdi), %r15
movq %rsi, %rax
negq %rax
movq %rsi, %r14
movq %rax, -0x40(%rbp)
cmovnsq %rax, %r14
andl $0xc0, %r13d
subl %ebx, %r13d
pushq $-0x1
popq %rbx
movl %r13d, %ecx
shrq %cl, %rbx
cmpq %r14, %r8
movq %rdi, -0x48(%rbp)
jbe 0x39a3
xorl %eax, %eax
testl %esi, %esi
setg %al
cmpl %r9d, %eax
jne 0x39cc
pushq $0x1
popq %rcx
xorl %eax, %eax
cmpq %rax, %r14
je 0x39f0
movq 0x8(%r12), %rdx
movq (%rdx,%rax,8), %rdx
notq %rdx
xorl %esi, %esi
addq %rdx, %rcx
setb %sil
movq %rcx, (%r15,%rax,8)
incq %rax
movq %rsi, %rcx
jmp 0x397d
cmpq %r12, %rdi
je 0x3a13
movq %rsi, -0x30(%rbp)
movq 0x8(%r12), %rsi
leaq -0x1(%r8), %r14
movq %r15, %rdi
movq %r14, %rdx
movl %r9d, %r13d
callq 0x12ed
movl %r13d, %r9d
movq -0x30(%rbp), %rsi
jmp 0x3a17
cmpq %r12, %rdi
je 0x3a82
movq %rsi, %rbx
movq 0x8(%r12), %rsi
movq %r15, %rdi
movq %r14, %rdx
callq 0x12ed
movq %r14, %r8
jmp 0x3a88
testq %rcx, %rcx
jne 0x3ad2
leaq -0x1(%r8), %rax
cmpq %rax, %r14
jge 0x3a0c
orq $-0x1, (%r15,%r14,8)
incq %r14
jmp 0x39fd
movq %rbx, -0x8(%r15,%r8,8)
jmp 0x3a7c
leaq -0x1(%r8), %r14
movq 0x8(%r12), %rax
movq (%rax,%r14,8), %rax
andq %rbx, %rax
movq %rax, (%r15,%r14,8)
xorl %eax, %eax
testl %esi, %esi
setg %al
cmpl %r9d, %eax
jne 0x3a59
movq -0x38(%rbp), %r8
movq %r8, %rcx
negq %rcx
pushq $0x1
popq %rax
leaq (%rcx,%rax), %rdx
cmpq $0x1, %rdx
je 0x3a85
movq -0x8(%r15,%rax,8), %rdx
testq %rdx, %rdx
jne 0x3a62
incq %rax
jmp 0x3a40
movq %rsi, %rbx
movq -0x38(%rbp), %r8
jmp 0x3a88
negq %rdx
movq %rdx, -0x8(%r15,%rax,8)
cmpq %r8, %rax
jae 0x3a78
notq (%r15,%rax,8)
incq %rax
jmp 0x3a6a
andq %rbx, (%r15,%r14,8)
movq -0x40(%rbp), %rbx
jmp 0x3a88
movq %r14, %r8
movq %rsi, %rbx
movq %r15, %rdi
movq %r8, %rsi
callq 0x1369
movl %eax, %ecx
negl %ecx
testq %rbx, %rbx
cmovnsl %eax, %ecx
movq -0x48(%rbp), %rdi
movl %ecx, 0x4(%rdi)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6756(%rip), %rdi      # 0xa210
leaq 0x55a3(%rip), %rsi      # 0x9064
leaq 0x674f(%rip), %rcx      # 0xa217
movl $0x93d, %edx            # imm = 0x93D
callq 0x1090
leaq 0x595e(%rip), %rdi      # 0x9437
leaq 0x5584(%rip), %rsi      # 0x9064
leaq 0x6730(%rip), %rcx      # 0xa217
movl $0x954, %edx            # imm = 0x954
callq 0x1090