// File: /workspace/github_cpp_makefile_star2_O3/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 %rcx, %rbp
movq %rdx, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
movq %rdi, 0x8(%rsp)
movq 0x60(%rsp), %r14
movq %rcx, 0x20(%rsp)
subq %r9, %rbp
cmpq %r9, %rbp
jle 0x2dd01
decq %rbp
movq %rbp, %rax
cqto
idivq %rbx
movq %rax, %rcx
incq %rcx
movq %rbp, %rax
cqto
idivq %rcx
movq %rax, %rbp
jmp 0x2dd22
leaq (,%rbp,2), %rax
addq %rbp, %rax
cmpq %rbx, %rax
jle 0x2dd25
leaq -0x1(%rbp), %rax
shrq $0x3f, %rax
addq %rax, %rbp
decq %rbp
sarq %rbp
incq %rbp
leaq (%r14,%rbp,8), %r12
leaq (%r14,%rbp,8), %r13
addq $0x8, %r13
cmpq %rbx, %rbp
jne 0x2dd78
leaq 0x10(%r12), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x2f106
movq $0x1, 0x8(%r12)
leaq 0x1(%rbx), %rdx
leaq 0x8(,%rbx,8), %rcx
addq %r13, %rcx
movq %r14, %rdi
movq %r13, %rsi
callq 0x32773
leaq 0x8(%r14), %rsi
movq %r14, %rdi
movq %rbx, %rdx
jmp 0x2de71
leaq (%r15,%rbx,8), %rax
leaq 0x1(%rbp), %rdx
movq %rbp, %rcx
notq %rcx
leaq (%rax,%rcx,8), %rdi
movq (%rdi), %rax
incq %rax
movq %rax, (%r13)
jne 0x2de11
cmpq $0x2, %rdx
movl $0x1, %r9d
cmovgeq %rdx, %r9
leaq (,%rbp,8), %rax
leaq (%r14,%rbp,8), %rcx
addq $0x10, %rcx
leaq (,%rbx,8), %rsi
subq %rax, %rsi
addq %r15, %rsi
decq %r9
xorl %r10d, %r10d
cmpq %r10, %r9
je 0x2dead
movq (%rsi,%r10,8), %r11
leaq 0x1(%r10), %r8
incq %r11
movq %r11, (%rcx,%r10,8)
movq %r8, %r10
je 0x2ddc8
cmpq %r13, %rdi
setne %al
leaq 0x1(%r8), %rdi
cmpq %rbp, %rdi
setle %dil
andb %al, %dil
cmpb $0x1, %dil
jne 0x2de51
movq (%rsi,%r8,8), %rax
movq %rax, (%rcx,%r8,8)
incq %r8
cmpq %rbp, %r8
jl 0x2ddff
jmp 0x2de51
cmpq %r13, %rdi
sete %al
testq %rbp, %rbp
setle %cl
orb %al, %cl
jne 0x2de51
leaq (,%rbp,8), %rsi
leaq (%r14,%rbp,8), %rax
addq $0x10, %rax
leaq (,%rbx,8), %rcx
subq %rsi, %rcx
addq %r15, %rcx
xorl %esi, %esi
movq (%rcx,%rsi,8), %rdi
movq %rdi, (%rax,%rsi,8)
incq %rsi
cmpq %rsi, %rbp
jne 0x2de41
leaq 0x8(,%rbp,8), %rcx
addq %r13, %rcx
movq %r14, %rdi
movq %r13, %rsi
callq 0x32773
leaq 0x8(%r14), %rsi
movq %r14, %rdi
movq %rbp, %rdx
callq 0x2f106
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 0x2dec1
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rbp, %rbp
je 0x2de76
movq %r14, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x6170
jmp 0x2de76