// File: /workspace/github_cpp_makefile_star2_O3/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 $0x48, %rsp
movq %r9, %r15
movq %rdx, %r9
movq %rcx, %r14
sarq %r14
movq %rcx, %rbx
subq %r14, %rbx
movabsq $0x1ffffffffffffffe, %rax # imm = 0x1FFFFFFFFFFFFFFE
andq %rcx, %rax
movq %rdi, 0x28(%rsp)
leaq (%rdi,%r14,8), %r12
movq %rsi, 0x8(%rsp)
leaq (%rsi,%rax,8), %rsi
cmpq $0x32, %rbx
movq %r8, 0x20(%rsp)
movq %rcx, 0x10(%rsp)
jle 0x2d2a2
movq %r9, %rbp
leaq (%r9,%r14,8), %rdx
movq %r12, %rdi
movq %rbx, %rcx
movq %r15, %r9
callq 0x2c91c
jmp 0x2d2bb
leaq (%rbx,%rbx), %rdx
movq %r9, %rbp
leaq (%r9,%r14,8), %rcx
movq (%r8), %r9
movq %r12, %rdi
movq %rbx, %r8
callq 0x2bb38
movq %rax, %r13
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, 0x30(%rsp)
movq %rbx, %rdx
movq %rbp, 0x18(%rsp)
movq %rbp, %rcx
movq %r14, %r8
callq 0x1c838
movq 0x8(%rsp), %rax
leaq (%rax,%r14,8), %rbx
movq %rbx, %rdi
movq %rbx, %rsi
movq %r15, 0x38(%rsp)
movq %r15, %rdx
movq 0x10(%rsp), %rbp
movq %rbp, %rcx
callq 0x1bca0
movq %rax, %r15
testq %r13, %r13
je 0x2d329
movq 0x8(%rsp), %rax
leaq (%rax,%rbp,8), %rdi
movq %rdi, %rsi
movq 0x18(%rsp), %rdx
movq %rdx, %rbp
movq %r14, %rcx
callq 0x1bca0
addq %rax, %r15
jmp 0x2d32e
movq 0x18(%rsp), %rbp
movq %r14, 0x40(%rsp)
testq %r15, %r15
movq 0x30(%rsp), %rax
je 0x2d394
cmpq $0x2, %rax
movl $0x1, %r14d
cmovgeq %rax, %r14
subq $0x1, (%r12)
jae 0x2d367
movl $0x1, %eax
cmpq %rax, %r14
je 0x2d36b
subq $0x1, (%r12,%rax,8)
leaq 0x1(%rax), %rax
jb 0x2d357
xorl %eax, %eax
jmp 0x2d372
movq $-0x1, %rax
addq %rax, %r13
movq %rbx, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq 0x10(%rsp), %rcx
callq 0x1ba80
subq %rax, %r15
movq 0x8(%rsp), %rcx
jne 0x2d34b
jmp 0x2d399
movq 0x8(%rsp), %rcx
movq 0x30(%rsp), %rax
leaq (%rcx,%rax,8), %rsi
movq 0x40(%rsp), %rbx
cmpq $0x107, %rbx            # imm = 0x107
jle 0x2d3d7
leaq (,%rax,8), %rdx
addq %rbp, %rdx
movq 0x28(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
movq 0x20(%rsp), %r8
movq 0x38(%rsp), %r9
callq 0x2d23c
jmp 0x2d403
movq 0x10(%rsp), %rdx
andq $-0x2, %rdx
leaq (,%rax,8), %rcx
addq %rbp, %rcx
movq 0x20(%rsp), %rax
movq (%rax), %r9
movq 0x28(%rsp), %r14
movq %r14, %rdi
movq %rbx, %r8
callq 0x2be5c
testq %rax, %rax
jne 0x2d41a
movq %r13, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rbx, %rbx
jle 0x2d408
shlq $0x3, %rbx
movq %r14, %rdi
movl $0xff, %esi
movq %rbx, %rdx
callq 0x6170
jmp 0x2d408