// File: marxn[P]pupp/3rdparty/gmp/mpn/mu_div_qr.c
// Function: _gmpn_mu_div_qr
mp_limb_t
mpn_mu_div_qr (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;
  mp_limb_t cy, qh;

  qn = nn - dn;
  if (qn + MU_DIV_QR_SKEW_THRESHOLD < dn)
    {
      /* |______________|_ign_first__|   dividend			  nn
		|_______|_ign_first__|   divisor			  dn

		|______|	     quotient (prel)			  qn

		 |___________________|   quotient * ignored-divisor-part  dn-1
      */

      /* Compute a preliminary quotient and a partial remainder by dividing the
	 most significant limbs of each operand.  */
      qh = mpn_mu_div_qr2 (qp, rp + nn - (2 * qn + 1),
			   np + nn - (2 * qn + 1), 2 * qn + 1,
			   dp + dn - (qn + 1), qn + 1,
			   scratch);

      /* Multiply the quotient by the divisor limbs ignored above.  */
      if (dn - (qn + 1) > qn)
	mpn_mul (scratch, dp, dn - (qn + 1), qp, qn);  /* prod is dn-1 limbs */
      else
	mpn_mul (scratch, qp, qn, dp, dn - (qn + 1));  /* prod is dn-1 limbs */

      if (qh)
	cy = mpn_add_n (scratch + qn, scratch + qn, dp, dn - (qn + 1));
      else
	cy = 0;
      scratch[dn - 1] = cy;

      cy = mpn_sub_n (rp, np, scratch, nn - (2 * qn + 1));
      cy = mpn_sub_nc (rp + nn - (2 * qn + 1),
		       rp + nn - (2 * qn + 1),
		       scratch + nn - (2 * qn + 1),
		       qn + 1, cy);
      if (cy)
	{
	  qh -= mpn_sub_1 (qp, qp, qn, 1);
	  mpn_add_n (rp, rp, dp, dn);
	}
    }
  else
    {
      qh = mpn_mu_div_qr2 (qp, rp, np, nn, dp, dn, scratch);
    }

  return qh;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x20(%rbp), %rax
subq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
addq $0x64, %rax
cmpq -0x30(%rbp), %rax
jge 0x53977
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x38(%rbp), %rcx
shlq %rcx
addq $0x1, %rcx
xorl %eax, %eax
subq %rcx, %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x38(%rbp), %rcx
shlq %rcx
addq $0x1, %rcx
xorl %eax, %eax
subq %rcx, %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x38(%rbp), %rcx
shlq %rcx
addq $0x1, %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %rax
shlq $0x3, %rax
addq %rax, %r8
movq -0x38(%rbp), %r9
addq $0x1, %r9
xorl %eax, %eax
subq %r9, %rax
shlq $0x3, %rax
addq %rax, %r8
movq -0x38(%rbp), %r9
addq $0x1, %r9
movq 0x10(%rbp), %rax
movq %rax, (%rsp)
callq 0x539b0
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
addq $0x1, %rcx
subq %rcx, %rax
cmpq -0x38(%rbp), %rax
jle 0x53804
movq 0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rax
addq $0x1, %rax
subq %rax, %rdx
movq -0x8(%rbp), %rcx
movq -0x38(%rbp), %r8
callq 0x37f00
jmp 0x53828
movq 0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
movq -0x38(%rbp), %rax
addq $0x1, %rax
subq %rax, %r8
callq 0x37f00
cmpq $0x0, -0x48(%rbp)
je 0x5386b
movq 0x10(%rbp), %rdi
movq -0x38(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq 0x10(%rbp), %rsi
movq -0x38(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rax
addq $0x1, %rax
subq %rax, %rcx
callq 0x36c80
movq %rax, -0x40(%rbp)
jmp 0x53873
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rdx
movq 0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
subq $0x1, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq 0x10(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %rax
shlq %rax
addq $0x1, %rax
subq %rax, %rcx
callq 0x36fe0
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x38(%rbp), %rcx
shlq %rcx
addq $0x1, %rcx
xorl %eax, %eax
subq %rcx, %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x38(%rbp), %rcx
shlq %rcx
addq $0x1, %rcx
xorl %eax, %eax
subq %rcx, %rax
shlq $0x3, %rax
addq %rax, %rsi
movq 0x10(%rbp), %rdx
movq -0x20(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x38(%rbp), %rcx
shlq %rcx
addq $0x1, %rcx
xorl %eax, %eax
subq %rcx, %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x38(%rbp), %rcx
addq $0x1, %rcx
movq -0x40(%rbp), %r8
callq 0x36fc0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x53975
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x38(%rbp), %rdx
movl $0x1, %ecx
callq 0x36e60
movq %rax, %rcx
movq -0x48(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x36c80
jmp 0x539a0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
movq 0x10(%rbp), %rax
movq %rax, (%rsp)
callq 0x539b0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)