// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %rbx
movq %rcx, 0x8(%rsp)
movq %rdx, %r12
movq %rcx, %rdx
sarq %rdx
movq %rcx, %rbp
subq %rdx, %rbp
movabsq $0x1ffffffffffffffe, %rax # imm = 0x1FFFFFFFFFFFFFFE
andq %rcx, %rax
movq %rdx, (%rsp)
leaq (%rdi,%rdx,8), %r13
movq %rsi, 0x28(%rsp)
leaq (%rsi,%rax,8), %rsi
cmpq $0x32, %rbp
movq %rdi, 0x20(%rsp)
movq %r8, 0x18(%rsp)
jle 0x277af
movq (%rsp), %rax
leaq (%r12,%rax,8), %rdx
movq %r13, %rdi
movq %rbp, %rcx
movq %rbx, %r9
callq 0x26ef0
jmp 0x277cd
leaq (,%rbp,2), %rdx
movq (%rsp), %rax
leaq (%r12,%rax,8), %rcx
movq (%r8), %r9
movq %r13, %rdi
movq %rbp, %r8
callq 0x26308
movq %rax, %r15
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %r14
movq %rbp, %rdx
movq %r12, %rcx
movq %r12, 0x10(%rsp)
movq (%rsp), %r12
movq %r12, %r8
callq 0x18a58
movq 0x28(%rsp), %rbp
leaq (,%r12,8), %r12
addq %rbp, %r12
movq %r12, %rdi
movq %r12, %rsi
movq %rbx, 0x30(%rsp)
movq %rbx, %rdx
movq 0x8(%rsp), %rcx
callq 0x17ed0
movq %rax, %rbx
testq %r15, %r15
je 0x27849
movq 0x8(%rsp), %rax
leaq (,%rax,8), %rdi
addq %rbp, %rdi
movq %rdi, %rsi
movq 0x10(%rsp), %rdx
movq %rdx, %rbp
movq (%rsp), %rcx
callq 0x17ed0
addq %rax, %rbx
jmp 0x2784e
movq 0x10(%rsp), %rbp
movq %r14, %rcx
testq %rbx, %rbx
je 0x27885
movq %r13, %rdi
movq %r13, %rsi
movq %rcx, %rdx
pushq $0x1
popq %rcx
callq 0x17e44
subq %rax, %r15
movq %r12, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq 0x8(%rsp), %rcx
callq 0x17cf0
movq %r14, %rcx
subq %rax, %rbx
jmp 0x27851
movq 0x28(%rsp), %rax
leaq (%rax,%rcx,8), %rsi
movq (%rsp), %r14
cmpq $0x107, %r14            # imm = 0x107
jle 0x278c2
leaq (,%rcx,8), %rdx
addq %rbp, %rdx
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rcx
movq 0x18(%rsp), %r8
movq 0x30(%rsp), %r9
callq 0x27744
jmp 0x278ee
movq 0x8(%rsp), %rdx
andq $-0x2, %rdx
leaq (,%rcx,8), %rcx
addq %rbp, %rcx
movq 0x18(%rsp), %rax
movq (%rax), %r9
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %r8
callq 0x265b0
testq %rax, %rax
jne 0x27905
movq %r15, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
testq %r14, %r14
cmovleq %rax, %r14
cmpq %rax, %r14
je 0x278f3
orq $-0x1, (%rbx,%rax,8)
incq %rax
jmp 0x2790e