// File: /workspace/github_cpp_makefile_star2_O1/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 $0x38, %rsp
movq %r9, %rbx
movq %rdx, %r9
movq %rdi, %r12
movq %rcx, %r13
sarq %r13
movq %rcx, %r15
subq %r13, %r15
movabsq $0x1ffffffffffffffe, %rax # imm = 0x1FFFFFFFFFFFFFFE
movq %rcx, 0x10(%rsp)
andq %rcx, %rax
leaq (%rdi,%r13,8), %r14
movq %rsi, 0x20(%rsp)
leaq (%rsi,%rax,8), %rsi
cmpq $0x32, %r15
movq %rdx, (%rsp)
movq %r8, 0x8(%rsp)
jle 0x2cd8d
leaq (%r9,%r13,8), %rdx
movq %r14, %rdi
movq %r15, %rcx
movq %rbx, %r9
callq 0x2cd28
jmp 0x2cda3
leaq (%r15,%r15), %rdx
leaq (%r9,%r13,8), %rcx
movq (%r8), %r9
movq %r14, %rdi
movq %r15, %r8
callq 0x2bf54
movq %rax, %rbp
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, 0x18(%rsp)
movq %r15, %rdx
movq (%rsp), %rcx
movq %r13, %r8
callq 0x1cd58
movq %r13, %r15
movq 0x20(%rsp), %rax
leaq (%rax,%r13,8), %r13
movq %r13, %rdi
movq %r13, %rsi
movq %rbx, 0x28(%rsp)
movq %rbx, %rdx
movq 0x10(%rsp), %rbx
movq %rbx, %rcx
callq 0x1c1c0
movq %r15, %rcx
movq %rax, %r15
testq %rbp, %rbp
movq %rcx, 0x30(%rsp)
je 0x2ce0f
movq 0x20(%rsp), %rax
leaq (%rax,%rbx,8), %rdi
movq %rdi, %rsi
movq (%rsp), %rdx
callq 0x1c1c0
addq %rax, %r15
testq %r15, %r15
movq 0x18(%rsp), %rax
je 0x2ce68
cmpq $0x2, %rax
movl $0x1, %ebx
cmovgeq %rax, %rbx
subq $0x1, (%r14)
jae 0x2ce41
movl $0x1, %eax
cmpq %rax, %rbx
je 0x2ce45
subq $0x1, (%r14,%rax,8)
leaq 0x1(%rax), %rax
jb 0x2ce31
xorl %eax, %eax
jmp 0x2ce4c
movq $-0x1, %rax
addq %rax, %rbp
movq %r13, %rdi
movq %r13, %rsi
movq (%rsp), %rdx
movq 0x10(%rsp), %rcx
callq 0x1bfa0
subq %rax, %r15
jne 0x2ce26
movq 0x20(%rsp), %r14
movq 0x18(%rsp), %rax
leaq (%r14,%rax,8), %rsi
movq 0x30(%rsp), %rbx
cmpq $0x32, %rbx
jle 0x2cea8
movq (%rsp), %rcx
leaq (%rcx,%rax,8), %rdx
movq %r12, %rdi
movq %rbx, %rcx
movq 0x8(%rsp), %r8
movq 0x28(%rsp), %r15
movq %r15, %r9
callq 0x2cd28
movq %rax, 0x8(%rsp)
jmp 0x2ced6
movq 0x10(%rsp), %rdx
andq $-0x2, %rdx
movq (%rsp), %rcx
leaq (%rcx,%rax,8), %rcx
movq 0x8(%rsp), %rdi
movq (%rdi), %r9
movq %r12, %rdi
movq %rbx, %r8
callq 0x2bf54
movq %rax, 0x8(%rsp)
movq 0x28(%rsp), %r15
movq %r15, %rdi
movq (%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r12, %rcx
movq %rbx, %r8
callq 0x1cd58
movq %r14, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq 0x10(%rsp), %rcx
callq 0x1c1c0
movq %rax, %r14
cmpq $0x0, 0x8(%rsp)
je 0x2cf27
movq %r13, %rdi
movq %r13, %rsi
movq (%rsp), %r13
movq %r13, %rdx
movq 0x18(%rsp), %rcx
callq 0x1c1c0
addq %rax, %r14
jmp 0x2cf2b
movq (%rsp), %r13
testq %r14, %r14
movq 0x10(%rsp), %r15
je 0x2cf7b
movq 0x30(%rsp), %rax
cmpq $0x2, %rax
movl $0x1, %ebx
cmovgeq %rax, %rbx
subq $0x1, (%r12)
jae 0x2cf63
movl $0x1, %eax
cmpq %rax, %rbx
je 0x2cf63
subq $0x1, (%r12,%rax,8)
leaq 0x1(%rax), %rax
jb 0x2cf53
movq 0x20(%rsp), %rdi
movq %rdi, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x1bfa0
subq %rax, %r14
jne 0x2cf47
movq %rbp, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq