// File: /workspace/github_cpp_makefile_star2_O2/marxn[P]pupp/3rdparty/gmp/mpn/sbpi1_div_qr.c
// Function: _gmpn_sbpi1_div_qr
mp_limb_t
mpn_sbpi1_div_qr (mp_ptr qp,
		  mp_ptr np, mp_size_t nn,
		  mp_srcptr dp, mp_size_t dn,
		  mp_limb_t dinv)
{
  mp_limb_t qh;
  mp_size_t i;
  mp_limb_t n1, n0;
  mp_limb_t d1, d0;
  mp_limb_t cy, cy1;
  mp_limb_t q;

  ASSERT (dn > 2);
  ASSERT (nn >= dn);
  ASSERT ((dp[dn-1] & GMP_NUMB_HIGHBIT) != 0);

  np += nn;

  qh = mpn_cmp (np - dn, dp, dn) >= 0;
  if (qh != 0)
    mpn_sub_n (np - dn, np - dn, dp, dn);

  qp += nn - dn;

  dn -= 2;			/* offset dn by 2 for main division loops,
				   saving two iterations in mpn_submul_1.  */
  d1 = dp[dn + 1];
  d0 = dp[dn + 0];

  np -= 2;

  n1 = np[1];

  for (i = nn - (dn + 2); i > 0; i--)
    {
      np--;
      if (UNLIKELY (n1 == d1) && np[1] == d0)
	{
	  q = GMP_NUMB_MASK;
	  mpn_submul_1 (np - dn, dp, dn + 2, q);
	  n1 = np[1];		/* update n1, last loop's value will now be invalid */
	}
      else
	{
	  udiv_qr_3by2 (q, n1, n0, n1, np[1], np[0], d1, d0, dinv);

	  cy = mpn_submul_1 (np - dn, dp, dn, q);

	  cy1 = n0 < cy;
	  n0 = (n0 - cy) & GMP_NUMB_MASK;
	  cy = n1 < cy1;
	  n1 = (n1 - cy1) & GMP_NUMB_MASK;
	  np[0] = n0;

	  if (UNLIKELY (cy != 0))
	    {
	      n1 += d1 + mpn_add_n (np - dn, np - dn, dp, dn + 1);
	      q--;
	    }
	}

      *--qp = q;
    }
  np[1] = n1;

  return qh;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %r9, 0x48(%rsp)
movq %r8, %r15
movq %rcx, %r13
movq %rdi, %r14
movq %rdx, %rbp
leaq (%rsi,%rdx,8), %r12
leaq (,%r8,8), %rax
movq %r12, %rbx
subq %rax, %rbx
movq %rbx, %rdi
movq %rcx, %rsi
movq %r8, %rdx
callq 0x1ac5c
movl %eax, 0x1c(%rsp)
testl %eax, %eax
js 0x26363
movq %rbx, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x17ed0
movq %rbp, %rbx
subq %r15, %rbx
leaq (%r14,%rbx,8), %rbp
leaq -0x2(%r15), %rax
movq %rax, 0x40(%rsp)
leaq -0x1(%r15), %rax
movq %rax, 0x38(%rsp)
movq -0x10(%r13,%r15,8), %rdi
movq %r13, 0x8(%rsp)
movq -0x8(%r13,%r15,8), %r13
movq -0x8(%r12), %rcx
addq $-0x10, %r12
pushq $0x2
popq %rax
movq %r15, 0x30(%rsp)
subq %r15, %rax
movq %rax, 0x20(%rsp)
movq %rdi, 0x50(%rsp)
testq %rbx, %rbx
jle 0x2658c
leaq -0x8(%r12), %r8
cmpq %r13, %rcx
movq %r8, 0x10(%rsp)
je 0x26500
movq 0x48(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq %rcx, %rax
mulq 0xb0(%rsp)
movq %rax, %rsi
movq %rdx, %r14
movq (%r12), %r15
movq %r15, 0xa0(%rsp)
movq %rcx, 0xa8(%rsp)
addq 0xa0(%rsp), %rsi
adcq 0xa8(%rsp), %r14
movq %r14, %rax
imulq %r13, %rax
subq %rax, %r15
movq -0x8(%r12), %r12
movq %r13, 0x98(%rsp)
movq %rdi, 0x90(%rsp)
subq 0x90(%rsp), %r12
sbbq 0x98(%rsp), %r15
movq %r14, 0x88(%rsp)
movq %rdi, %rax
mulq 0x88(%rsp)
movq %rdx, 0x80(%rsp)
movq %rax, 0x78(%rsp)
subq 0x78(%rsp), %r12
sbbq 0x80(%rsp), %r15
cmpq %rsi, %r15
adcq $-0x1, %r14
cmpq %rsi, %r15
movl $0x0, %eax
cmovaeq %r13, %rax
movl $0x0, %ecx
cmovaeq %rdi, %rcx
incq %r14
movq %rax, 0x70(%rsp)
movq %rcx, 0x68(%rsp)
addq 0x68(%rsp), %r12
adcq 0x70(%rsp), %r15
cmpq %r13, %r15
movq %rbp, 0x28(%rsp)
jae 0x26534
movq %rbx, %rbp
movq 0x20(%rsp), %rax
leaq (%r8,%rax,8), %rbx
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq %r14, %rcx
callq 0x29f90
movq 0x10(%rsp), %rdx
subq %rax, %r12
sbbq $0x0, %r15
movq %r12, (%rdx)
jb 0x26564
movq %rbp, %rbx
movq 0x28(%rsp), %rbp
movq %r14, -0x8(%rbp)
addq $-0x8, %rbp
decq %rbx
movq %r15, %rcx
movq %rdx, %r12
movq 0x50(%rsp), %rdi
jmp 0x263ac
cmpq %rdi, (%r12)
jne 0x263c8
movq 0x20(%rsp), %rax
leaq (%r8,%rax,8), %rdi
movq 0x8(%rsp), %rsi
movq 0x30(%rsp), %rdx
pushq $-0x1
popq %r14
movq %r14, %rcx
callq 0x29f90
movq 0x10(%rsp), %rdx
movq (%r12), %r15
jmp 0x264e5
setbe %al
cmpq %rdi, %r12
setb %cl
testb %cl, %al
jne 0x264a7
movq %rbx, %rbp
incq %r14
movq %rdi, 0x58(%rsp)
movq %r13, 0x60(%rsp)
subq 0x58(%rsp), %r12
sbbq 0x60(%rsp), %r15
jmp 0x264aa
movq %rbx, %rdi
movq %rbx, %rsi
movq 0x8(%rsp), %rdx
movq 0x38(%rsp), %rcx
callq 0x17cf0
movq 0x10(%rsp), %rdx
addq %r13, %r15
addq %rax, %r15
decq %r14
jmp 0x264dd
xorl %eax, %eax
cmpl $0x0, 0x1c(%rsp)
setns %al
movq %rcx, 0x8(%r12)
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)