// File: 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
movq %rsp, %rbp
pushq %rbx
subq $0x88, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
jmp 0x539da
movq -0x28(%rbp), %rax
subq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
xorl %edx, %edx
callq 0x540c0
movq %rax, -0x48(%rbp)
jmp 0x539fb
movq 0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
movq 0x10(%rbp), %rax
movq -0x48(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
addq $0x8, %rax
movq %rax, -0x68(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x48(%rbp), %rax
jne 0x53aa0
jmp 0x53a26
jmp 0x53a28
jmp 0x53a2a
jmp 0x53a2c
jmp 0x53a2e
jmp 0x53a30
jmp 0x53a32
jmp 0x53a34
movq -0x68(%rbp), %rdi
addq $0x8, %rdi
movq -0x30(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x554c6
jmp 0x53a4b
movq -0x68(%rbp), %rax
movq $0x1, (%rax)
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq $0x1, %rdx
movq -0x68(%rbp), %rcx
movq -0x48(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
addq $0x8, %rcx
callq 0x59cb0
jmp 0x53a80
jmp 0x53a82
jmp 0x53a84
jmp 0x53a86
movq -0x60(%rbp), %rdi
movq -0x60(%rbp), %rsi
addq $0x8, %rsi
movq -0x48(%rbp), %rdx
callq 0x554c6
jmp 0x53b99
movq -0x68(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x48(%rbp), %rcx
addq $0x1, %rcx
xorl %eax, %eax
subq %rcx, %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x48(%rbp), %rdx
addq $0x1, %rdx
movl $0x1, %ecx
callq 0x564f0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
setne %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x53b50
jmp 0x53aff
jmp 0x53b01
jmp 0x53b03
cmpq $0x0, -0x48(%rbp)
je 0x53b4c
jmp 0x53b0c
movq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x53b1e
jmp 0x53b20
movq -0x70(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x70(%rbp)
movq $0x0, (%rax)
movq -0x78(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, %rax
jne 0x53b20
jmp 0x53b4a
jmp 0x53b4c
jmp 0x53b4e
jmp 0x53b97
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq $0x1, %rdx
movq -0x68(%rbp), %rcx
movq -0x48(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
addq $0x8, %rcx
callq 0x59cb0
jmp 0x53b7a
jmp 0x53b7c
jmp 0x53b7e
jmp 0x53b80
movq -0x60(%rbp), %rdi
movq -0x60(%rbp), %rsi
addq $0x8, %rsi
movq -0x48(%rbp), %rdx
callq 0x554c6
jmp 0x53b97
jmp 0x53b99
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
movq -0x38(%rbp), %r9
movq -0x60(%rbp), %r11
movq -0x48(%rbp), %r10
movq 0x10(%rbp), %rax
movq -0x48(%rbp), %rbx
shlq $0x3, %rbx
addq %rbx, %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x53bf0
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
addq $0x88, %rsp
popq %rbx
popq %rbp
retq
nopl (%rax)