// File: /workspace/github_cpp_makefile_star2_O3/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 $0xc8, %rsp
movq %r9, 0x60(%rsp)
movq %r8, %r12
movq %rcx, 0x8(%rsp)
movq %rsi, %r13
movq %rdi, %rbx
leaq (%rsi,%rdx,8), %r15
leaq (,%r8,8), %rax
movq %r15, %rdi
subq %rax, %rdi
movq %rdx, 0x20(%rsp)
leaq (%rsi,%rdx,8), %rax
addq $-0x8, %rax
movq %r8, %rcx
testq %rcx, %rcx
jle 0x2bb9e
movq (%rax), %rdx
movq 0x8(%rsp), %rsi
movq -0x8(%rsi,%rcx,8), %rsi
decq %rcx
addq $-0x8, %rax
cmpq %rsi, %rdx
je 0x2bb7e
jbe 0x2bbb5
movq %rdi, %rsi
movq 0x8(%rsp), %rdx
movq %r12, %rcx
callq 0x1bca0
movl $0x1, %eax
jmp 0x2bbb7
xorl %eax, %eax
movq -0x8(%r15), %r14
movq 0x20(%rsp), %rdx
movq %rdx, %rbp
subq %r12, %rbp
jle 0x2be3f
movq %rax, 0x48(%rsp)
leaq -0x2(%r12), %rax
movq %rax, 0x50(%rsp)
leaq -0x1(%r12), %rax
movq %rax, 0x40(%rsp)
movq 0x8(%rsp), %rcx
movq -0x10(%rcx,%r12,8), %rdi
movq -0x8(%rcx,%r12,8), %r8
leaq (,%rdx,8), %r9
movq %r12, 0x38(%rsp)
notq %r12
leaq (%rbx,%r12,8), %r15
leaq (,%r12,8), %r12
addq %r13, %r12
addq $-0x10, %r13
incq %rbp
movq %rdi, 0x58(%rsp)
movq %r8, 0x10(%rsp)
movq %r9, 0x18(%rsp)
cmpq %r8, %r14
je 0x2bd8c
movq %r15, 0x28(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq %r14, %rax
mulq 0xc0(%rsp)
movq %rax, %rcx
movq %rdx, %rbx
movq (%r13,%r9), %rsi
movq %rsi, 0xb0(%rsp)
movq %r14, 0xb8(%rsp)
addq 0xb0(%rsp), %rcx
adcq 0xb8(%rsp), %rbx
movq %rbx, %rax
imulq %r8, %rax
subq %rax, %rsi
movq -0x8(%r13,%r9), %r15
movq %r8, 0xa8(%rsp)
movq %rdi, 0xa0(%rsp)
subq 0xa0(%rsp), %r15
sbbq 0xa8(%rsp), %rsi
movq %rbx, 0x98(%rsp)
movq %rdi, %rax
mulq 0x98(%rsp)
movq %rdx, 0x90(%rsp)
movq %rax, 0x88(%rsp)
subq 0x88(%rsp), %r15
sbbq 0x90(%rsp), %rsi
cmpq %rcx, %rsi
adcq $-0x1, %rbx
cmpq %rcx, %rsi
movl $0x0, %eax
cmovaeq %r8, %rax
movl $0x0, %ecx
cmovaeq %rdi, %rcx
incq %rbx
movq %rax, 0x80(%rsp)
movq %rcx, 0x78(%rsp)
addq 0x78(%rsp), %r15
adcq 0x80(%rsp), %rsi
movq %rsi, %r14
cmpq %r8, %rsi
movq %rbp, 0x30(%rsp)
jae 0x2bdc9
leaq (%r12,%r9), %rbp
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq %rbx, %rcx
callq 0x2ffb0
movq 0x18(%rsp), %r9
subq %rax, %r15
sbbq $0x0, %r14
movq %r15, -0x8(%r13,%r9)
jb 0x2bdf6
movq 0x30(%rsp), %rbp
movq 0x10(%rsp), %r8
movq 0x28(%rsp), %r15
movq %rbx, (%r15,%r9)
addq $-0x8, %r15
addq $-0x8, %r13
addq $-0x8, %r12
decq %rbp
cmpq $0x1, %rbp
movq 0x58(%rsp), %rdi
jg 0x2bc29
jmp 0x2be28
cmpq %rdi, (%r13,%r9)
jne 0x2bc32
leaq (%r12,%r9), %rdi
movq $-0x1, %rbx
movq 0x8(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq $-0x1, %rcx
callq 0x2ffb0
movq 0x18(%rsp), %r9
movq 0x10(%rsp), %r8
movq (%r13,%r9), %r14
jmp 0x2bd65
setbe %al
cmpq %rdi, %r15
setb %cl
testb %cl, %al
jne 0x2bd26
incq %rbx
movq %rdi, 0x68(%rsp)
movq %r8, 0x70(%rsp)
subq 0x68(%rsp), %r15
sbbq 0x70(%rsp), %r14
jmp 0x2bd26
movq %rbp, %rdi
movq %rbp, %rsi
movq 0x8(%rsp), %rdx
movq 0x40(%rsp), %rcx
callq 0x1ba80
movq 0x18(%rsp), %r9
movq 0x10(%rsp), %r8
addq %r8, %r14
addq %rax, %r14
decq %rbx
movq 0x30(%rsp), %rbp
jmp 0x2bd60
movq 0x20(%rsp), %rax
leaq (,%rax,8), %r15
addq %r13, %r15
movq 0x48(%rsp), %rax
jmp 0x2be43
addq $-0x10, %r15
movq %r14, 0x8(%r15)
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)