// File: marxn[P]pupp/3rdparty/gmp/mpn/dcpi1_divappr_q.c
// Function: _gmpn_dcpi1_divappr_q_n
mp_limb_t
mpn_dcpi1_divappr_q_n (mp_ptr qp, mp_ptr np, mp_srcptr dp, mp_size_t n,
		       gmp_pi1_t *dinv, mp_ptr tp)
{
  mp_size_t lo, hi;
  mp_limb_t cy, qh, ql;

  lo = n >> 1;			/* floor(n/2) */
  hi = n - lo;			/* ceil(n/2) */

  if (BELOW_THRESHOLD (hi, DC_DIV_QR_THRESHOLD))
    qh = mpn_sbpi1_div_qr (qp + lo, np + 2 * lo, 2 * hi, dp + lo, hi, dinv->inv32);
  else
    qh = mpn_dcpi1_div_qr_n (qp + lo, np + 2 * lo, dp + lo, hi, dinv, tp);

  mpn_mul (tp, qp + lo, hi, dp, lo);

  cy = mpn_sub_n (np + lo, np + lo, tp, n);
  if (qh != 0)
    cy += mpn_sub_n (np + n, np + n, dp, lo);

  while (cy != 0)
    {
      qh -= mpn_sub_1 (qp + lo, qp + lo, hi, 1);
      cy -= mpn_add_n (np + lo, np + lo, dp, n);
    }

  if (BELOW_THRESHOLD (lo, DC_DIVAPPR_Q_THRESHOLD))
    ql = mpn_sbpi1_divappr_q (qp, np + hi, 2 * lo, dp + hi, lo, dinv->inv32);
  else
    ql = mpn_dcpi1_divappr_q_n (qp, np + hi, dp + hi, lo, dinv, tp);

  if (UNLIKELY (ql != 0))
    {
      mp_size_t i;
      for (i = 0; i < lo; i++)
	qp[i] = GMP_NUMB_MASK;
    }

  return qh;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
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
sarq %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
subq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x33, -0x40(%rbp)
jge 0x529cb
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x40(%rbp), %rdx
shlq %rdx
movq -0x18(%rbp), %rcx
movq -0x38(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x40(%rbp), %r8
movq -0x28(%rbp), %rax
movq (%rax), %r9
callq 0x505f0
movq %rax, -0x50(%rbp)
jmp 0x52a10
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x18(%rbp), %rdx
movq -0x38(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
callq 0x51ab0
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x38(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x40(%rbp), %rdx
movq -0x18(%rbp), %rcx
movq -0x38(%rbp), %r8
callq 0x37f00
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 -0x30(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x36fe0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x52a9d
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x18(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x36fe0
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x52a9f
cmpq $0x0, -0x48(%rbp)
je 0x52b1b
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rsi
movq -0x38(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x40(%rbp), %rdx
movl $0x1, %ecx
callq 0x36e60
movq %rax, %rcx
movq -0x50(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x50(%rbp)
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 -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x36c80
movq %rax, %rcx
movq -0x48(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x48(%rbp)
jmp 0x52a9f
cmpq $0x108, -0x38(%rbp)     # imm = 0x108
jge 0x52b64
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x38(%rbp), %rdx
shlq %rdx
movq -0x18(%rbp), %rcx
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
movq -0x38(%rbp), %r8
movq -0x28(%rbp), %rax
movq (%rax), %r9
callq 0x50ac0
movq %rax, -0x58(%rbp)
jmp 0x52b9b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movq -0x18(%rbp), %rdx
movq -0x40(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdx
movq -0x38(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
callq 0x52940
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%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 0x52bed
movq $0x0, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x38(%rbp), %rax
jge 0x52beb
movq -0x8(%rbp), %rax
movq -0x60(%rbp), %rcx
movq $-0x1, (%rax,%rcx,8)
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x52bc3
jmp 0x52bed
movq -0x50(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)