// File: /workspace/github_cpp_makefile_star2_O2/marxn[P]pupp/3rdparty/gmp/mpn/dcpi1_div_qr.c
// Function: _gmpn_dcpi1_div_qr_n
mp_limb_t
mpn_dcpi1_div_qr_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_DIV_QR_THRESHOLD))
    ql = mpn_sbpi1_div_qr (qp, np + hi, 2 * lo, dp + hi, lo, dinv->inv32);
  else
    ql = mpn_dcpi1_div_qr_n (qp, np + hi, dp + hi, lo, dinv, tp);

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

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

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

  return qh;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, %r14
movq %rcx, 0x18(%rsp)
movq %rdx, %r9
movq %rsi, 0x20(%rsp)
movq %rdi, 0x28(%rsp)
movq %rcx, %rbx
sarq %rbx
movq %rcx, %r13
subq %rbx, %r13
movabsq $0x1ffffffffffffffe, %rax # imm = 0x1FFFFFFFFFFFFFFE
andq %rcx, %rax
leaq (%rdi,%rbx,8), %r12
leaq (%rsi,%rax,8), %rsi
cmpq $0x32, %r13
movq %r8, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
jle 0x26f58
leaq (%r9,%rbx,8), %rdx
movq %r12, %rdi
movq %r13, %rcx
movq %r14, %r9
callq 0x26ef0
jmp 0x26f72
leaq (,%r13,2), %rdx
leaq (%r9,%rbx,8), %rcx
movq (%r8), %r9
movq %r12, %rdi
movq %r13, %r8
callq 0x26308
movq %rax, %rbp
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %r15
movq %r13, %rdx
movq 0x8(%rsp), %rcx
movq %rbx, %r8
callq 0x18a58
movq 0x20(%rsp), %rax
leaq (%rax,%rbx,8), %r13
movq %r13, %rdi
movq %r13, %rsi
movq %r14, 0x30(%rsp)
movq %r14, %rdx
movq %rbx, %r14
movq 0x18(%rsp), %rbx
movq %rbx, %rcx
callq 0x17ed0
movq %r14, %rcx
movq %rax, %r14
testq %rbp, %rbp
movq %rcx, 0x40(%rsp)
je 0x26fe3
movq 0x20(%rsp), %rax
leaq (%rax,%rbx,8), %rdi
movq %rdi, %rsi
movq 0x8(%rsp), %rdx
movq %rdx, %rbx
callq 0x17ed0
addq %rax, %r14
jmp 0x26fe8
movq 0x8(%rsp), %rbx
movq %r15, %r8
testq %r14, %r14
je 0x2701f
movq %r12, %rdi
movq %r12, %rsi
movq %r8, %rdx
pushq $0x1
popq %rcx
callq 0x17e44
subq %rax, %rbp
movq %r13, %rdi
movq %r13, %rsi
movq %rbx, %rdx
movq 0x18(%rsp), %rcx
callq 0x17cf0
movq %r15, %r8
subq %rax, %r14
jmp 0x26feb
movq 0x20(%rsp), %r15
leaq (%r15,%r8,8), %rsi
movq 0x40(%rsp), %r14
cmpq $0x32, %r14
movq %r8, 0x38(%rsp)
jle 0x27060
leaq (%rbx,%r8,8), %rdx
movq 0x28(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rcx
movq 0x10(%rsp), %r8
movq 0x30(%rsp), %r12
movq %r12, %r9
callq 0x26ef0
movq %rax, 0x10(%rsp)
jmp 0x2708f
movq 0x18(%rsp), %rdx
andq $-0x2, %rdx
leaq (%rbx,%r8,8), %rcx
movq 0x10(%rsp), %rax
movq (%rax), %r9
movq 0x28(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %r8
callq 0x26308
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %r12
movq %r12, %rdi
movq 0x8(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %rbx, %rcx
movq %r14, %r8
callq 0x18a58
movq %r15, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq 0x18(%rsp), %rcx
callq 0x17ed0
movq %rax, %r14
cmpq $0x0, 0x10(%rsp)
je 0x270e2
movq %r13, %rdi
movq %r13, %rsi
movq 0x8(%rsp), %rbx
movq %rbx, %rdx
movq 0x38(%rsp), %rcx
callq 0x17ed0
addq %rax, %r14
jmp 0x270e7
movq 0x8(%rsp), %rbx
pushq $0x1
popq %r12
movq 0x18(%rsp), %r13
testq %r14, %r14
je 0x27120
movq 0x28(%rsp), %rdi
movq %rdi, %rsi
movq 0x40(%rsp), %rdx
movq %r12, %rcx
callq 0x17e44
movq %r15, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x17cf0
subq %rax, %r14
jmp 0x270f0
movq %rbp, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq