// File: /workspace/github_cpp_makefile_star2_O2/marxn[P]pupp/3rdparty/gmp/mpn/mu_div_qr.c
// Function: mpn_mu_div_qr2
static mp_limb_t
mpn_mu_div_qr2 (mp_ptr qp,
		mp_ptr rp,
		mp_srcptr np,
		mp_size_t nn,
		mp_srcptr dp,
		mp_size_t dn,
		mp_ptr scratch)
{
  mp_size_t qn, in;
  mp_limb_t cy, qh;
  mp_ptr ip, tp;

  ASSERT (dn > 1);

  qn = nn - dn;

  /* Compute the inverse size.  */
  in = mpn_mu_div_qr_choose_in (qn, dn, 0);
  ASSERT (in <= dn);

#if 1
  /* This alternative inverse computation method gets slightly more accurate
     results.  FIXMEs: (1) Temp allocation needs not analysed (2) itch function
     not adapted (3) mpn_invertappr scratch needs not met.  */
  ip = scratch;
  tp = scratch + in + 1;

  /* compute an approximate inverse on (in+1) limbs */
  if (dn == in)
    {
      MPN_COPY (tp + 1, dp, in);
      tp[0] = 1;
      mpn_invertappr (ip, tp, in + 1, tp + in + 1);
      MPN_COPY_INCR (ip, ip + 1, in);
    }
  else
    {
      cy = mpn_add_1 (tp, dp + dn - (in + 1), in + 1, 1);
      if (UNLIKELY (cy != 0))
	MPN_ZERO (ip, in);
      else
	{
	  mpn_invertappr (ip, tp, in + 1, tp + in + 1);
	  MPN_COPY_INCR (ip, ip + 1, in);
	}
    }
#else
  /* This older inverse computation method gets slightly worse results than the
     one above.  */
  ip = scratch;
  tp = scratch + in;

  /* Compute inverse of D to in+1 limbs, then round to 'in' limbs.  Ideally the
     inversion function should do this automatically.  */
  if (dn == in)
    {
      tp[in + 1] = 0;
      MPN_COPY (tp + in + 2, dp, in);
      mpn_invertappr (tp, tp + in + 1, in + 1, NULL);
    }
  else
    {
      mpn_invertappr (tp, dp + dn - (in + 1), in + 1, NULL);
    }
  cy = mpn_sub_1 (tp, tp, in + 1, GMP_NUMB_HIGHBIT);
  if (UNLIKELY (cy != 0))
    MPN_ZERO (tp + 1, in);
  MPN_COPY (ip, tp + 1, in);
#endif

  qh = mpn_preinv_mu_div_qr (qp, rp, np, nn, dp, dn, ip, in, scratch + in);

  return qh;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %rbx
movq %r8, %r15
movq %rdx, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
movq %rdi, 0x8(%rsp)
movq 0x60(%rsp), %r14
movq %rcx, 0x20(%rsp)
movq %rcx, %rdi
subq %r9, %rdi
movq %r9, %rsi
xorl %edx, %edx
callq 0x28568
movq %rax, %rbp
leaq (%r14,%rax,8), %r12
leaq (%r14,%rax,8), %r13
addq $0x8, %r13
cmpq %rbx, %rax
jne 0x2814c
leaq 0x10(%r12), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x290c6
movq $0x1, 0x8(%r12)
leaq 0x1(%rbx), %rdx
leaq 0x8(,%rbx,8), %rcx
addq %r13, %rcx
movq %r14, %rdi
movq %r13, %rsi
callq 0x2bf2e
leaq 0x8(%r14), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x290c6
jmp 0x281a1
movq %r15, (%rsp)
leaq (%r15,%rbx,8), %rax
leaq 0x1(%rbp), %r15
movq %rbp, %rcx
notq %rcx
leaq (%rax,%rcx,8), %rsi
pushq $0x1
popq %rcx
movq %r13, %rdi
movq %r15, %rdx
callq 0x29e1c
testq %rax, %rax
jne 0x281d8
leaq 0x8(,%rbp,8), %rcx
addq %r13, %rcx
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x2bf2e
leaq 0x8(%r14), %rsi
movq %r14, %rdi
movq %rbp, %rdx
callq 0x290c6
movq (%rsp), %r15
subq $0x8, %rsp
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq 0x28(%rsp), %rcx
movq %r15, %r8
movq %rbx, %r9
pushq %r12
pushq %rbp
pushq %r14
callq 0x281f4
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rbp, %rbp
movq (%rsp), %r15
je 0x281a1
movq %rbp, %rdx
shlq $0x3, %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x6170
jmp 0x281a1