// File: /workspace/github_cpp_makefile_star2_O2/marxn[P]pupp/3rdparty/gmp/mpn/sbpi1_divappr_q.c
// Function: _gmpn_sbpi1_divappr_q
mp_limb_t
mpn_sbpi1_divappr_q (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 qn, i;
  mp_limb_t n1, n0;
  mp_limb_t d1, d0;
  mp_limb_t cy, cy1;
  mp_limb_t q;
  mp_limb_t flag;

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

  np += nn;

  qn = nn - dn;
  if (qn + 1 < dn)
    {
      dp += dn - (qn + 1);
      dn = qn + 1;
    }

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

  qp += qn;

  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 = qn - (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 -= cy1;
	  np[0] = n0;

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

      *--qp = q;
    }

  flag = ~CNST_LIMB(0);

  if (dn >= 0)
    {
      for (i = dn; i > 0; i--)
	{
	  np--;
	  if (UNLIKELY (n1 >= (d1 & flag)))
	    {
	      q = GMP_NUMB_MASK;
	      cy = mpn_submul_1 (np - dn, dp, dn + 2, q);

	      if (UNLIKELY (n1 != cy))
		{
		  if (n1 < (cy & flag))
		    {
		      q--;
		      mpn_add_n (np - dn, np - dn, dp, dn + 2);
		    }
		  else
		    flag = 0;
		}
	      n1 = np[1];
	    }
	  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 -= cy1;
	      np[0] = n0;

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

	  *--qp = q;

	  /* Truncate operands.  */
	  dn--;
	  dp++;
	}

      np--;
      if (UNLIKELY (n1 >= (d1 & flag)))
	{
	  q = GMP_NUMB_MASK;
	  cy = mpn_submul_1 (np, dp, 2, q);

	  if (UNLIKELY (n1 != cy))
	    {
	      if (n1 < (cy & flag))
		{
		  q--;
		  add_ssaaaa (np[1], np[0], np[1], np[0], dp[1], dp[0]);
		}
	      else
		flag = 0;
	    }
	  n1 = np[1];
	}
      else
	{
	  udiv_qr_3by2 (q, n1, n0, n1, np[1], np[0], d1, d0, dinv);

	  np[1] = n1;
	  np[0] = n0;
	}

      *--qp = q;
    }

  ASSERT_ALWAYS (np[1] == n1);

  return qh;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %r9, 0x48(%rsp)
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, 0x8(%rsp)
movq %rdx, %rax
subq %r8, %rax
movq %rax, (%rsp)
incq %rax
movq %rax, %rdx
subq %r8, %rdx
movq %r8, %rbx
cmovlq %rax, %rbx
negq %rdx
xorl %esi, %esi
movq %r8, 0x28(%rsp)
cmpq %rax, %r8
cmovgq %rdx, %rsi
leaq (%r12,%r13,8), %r14
leaq (%rcx,%rsi,8), %r15
leaq (,%rbx,8), %rcx
movq %rcx, 0x20(%rsp)
subq %rcx, %r14
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x1ac5c
movl %eax, 0x54(%rsp)
testl %eax, %eax
js 0x2663b
movq %r14, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x17ed0
leaq -0x2(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq -0x1(%rbx), %rax
movq %rax, 0x30(%rsp)
movq -0x10(%r15,%rbx,8), %r8
movq -0x8(%r15,%rbx,8), %rbp
leaq -0x18(%r12,%r13,8), %r10
movq 0x10(%r10), %r14
movq %rbx, 0x38(%rsp)
movq (%rsp), %r12
subq %rbx, %r12
shlq $0x3, %r13
negq 0x20(%rsp)
movq 0x28(%rsp), %rax
shlq $0x3, %rax
subq %rax, %r13
movq 0x8(%rsp), %rax
addq %r13, %rax
addq $-0x8, %rax
movq %rax, 0x28(%rsp)
movq %r8, 0x8(%rsp)
movq %r15, %rsi
movq %r15, 0x18(%rsp)
testq %r12, %r12
movq %r10, (%rsp)
js 0x26868
cmpq %rbp, %r14
je 0x267e8
movq 0x48(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq %r14, %rax
mulq 0xb0(%rsp)
movq %rax, %rcx
movq %rdx, %r13
movq 0x8(%r10), %rbx
movq %rbx, 0xa0(%rsp)
movq %r14, 0xa8(%rsp)
addq 0xa0(%rsp), %rcx
adcq 0xa8(%rsp), %r13
movq %r13, %rax
imulq %rbp, %rax
subq %rax, %rbx
movq (%r10), %r15
movq %rbp, 0x98(%rsp)
movq %r8, 0x90(%rsp)
subq 0x90(%rsp), %r15
sbbq 0x98(%rsp), %rbx
movq %r13, 0x88(%rsp)
movq %r8, %rax
mulq 0x88(%rsp)
movq %rdx, 0x80(%rsp)
movq %rax, 0x78(%rsp)
subq 0x78(%rsp), %r15
sbbq 0x80(%rsp), %rbx
cmpq %rcx, %rbx
adcq $-0x1, %r13
cmpq %rcx, %rbx
movl $0x0, %eax
cmovaeq %rbp, %rax
movl $0x0, %ecx
cmovaeq %r8, %rcx
incq %r13
movq %rax, 0x70(%rsp)
movq %rcx, 0x68(%rsp)
addq 0x68(%rsp), %r15
adcq 0x70(%rsp), %rbx
cmpq %rbp, %rbx
jae 0x2681a
movq 0x20(%rsp), %rax
leaq (%r10,%rax), %r14
addq $0x10, %r14
movq %r14, %rdi
movq 0x10(%rsp), %rdx
movq %r13, %rcx
callq 0x29f90
movq (%rsp), %r10
subq %rax, %r15
sbbq $0x0, %rbx
movq %r15, (%r10)
jb 0x26841
movq 0x28(%rsp), %rax
movq %r13, (%rax)
decq %r12
addq $-0x8, %r10
addq $-0x8, %rax
movq %rax, 0x28(%rsp)
movq %rbx, %r14
movq 0x8(%rsp), %r8
movq 0x18(%rsp), %rsi
jmp 0x2669f
cmpq %r8, 0x8(%r10)
jne 0x266b5
movq 0x20(%rsp), %rax
leaq (%r10,%rax), %rdi
addq $0x10, %rdi
movq 0x38(%rsp), %rdx
pushq $-0x1
popq %r13
movq %r13, %rcx
callq 0x29f90
movq (%rsp), %r10
movq 0x8(%r10), %rbx
jmp 0x267be
ja 0x26825
cmpq %r8, %r15
jb 0x2678d
incq %r13
movq %r8, 0x58(%rsp)
movq %rbp, 0x60(%rsp)
subq 0x58(%rsp), %r15
sbbq 0x60(%rsp), %rbx
jmp 0x2678d
movq %r14, %rdi
movq %r14, %rsi
movq 0x18(%rsp), %rdx
movq 0x30(%rsp), %rcx
callq 0x17cf0
movq (%rsp), %r10
addq %rbp, %rbx
addq %rax, %rbx
decq %r13
jmp 0x267be
movq 0x38(%rsp), %r15
cmpq $0x2, %r15
jl 0x26b36
pushq $0x2
popq %r12
subq %r15, %r12
pushq $-0x1
popq %rax
xorl %r11d, %r11d
movq %r10, %rdi
movq %rax, 0x10(%rsp)
movq %rbp, 0x30(%rsp)
leaq (%r15,%r11), %rcx
addq $-0x2, %rcx
movq 0x10(%rsp), %rax
andq %rbp, %rax
testq %rcx, %rcx
jle 0x26b42
cmpq %rax, %r14
movq %r11, 0x20(%rsp)
movq %r12, 0x18(%rsp)
jae 0x26a1b
movq 0x48(%rsp), %rax
movq %rax, 0x110(%rsp)
movq %r14, %rax
mulq 0x110(%rsp)
movq %rax, %r9
movq %rdx, %r13
movq %r10, %rdx
movq 0x8(%r10,%r11,8), %r10
movq %r10, 0x100(%rsp)
movq %r14, 0x108(%rsp)
addq 0x100(%rsp), %r9
adcq 0x108(%rsp), %r13
movq %r13, %rax
imulq %rbp, %rax
subq %rax, %r10
movq (%rdx,%r11,8), %rbx
movq %rbp, 0xf8(%rsp)
movq %r8, 0xf0(%rsp)
subq 0xf0(%rsp), %rbx
sbbq 0xf8(%rsp), %r10
movq %r13, 0xe8(%rsp)
movq %r8, %rax
mulq 0xe8(%rsp)
movq %rdx, 0xe0(%rsp)
movq %rax, 0xd8(%rsp)
subq 0xd8(%rsp), %rbx
sbbq 0xe0(%rsp), %r10
cmpq %r9, %r10
adcq $-0x1, %r13
cmpq %r9, %r10
movl $0x0, %eax
cmovaeq %rbp, %rax
movl $0x0, %edx
cmovaeq %r8, %rdx
incq %r13
movq %rax, 0xd0(%rsp)
movq %rdx, 0xc8(%rsp)
addq 0xc8(%rsp), %rbx
adcq 0xd0(%rsp), %r10
movq %r10, %r14
cmpq %rbp, %r10
jae 0x26a6c
movq %rdi, %rbp
leaq (%rdi,%r12,8), %r15
movq %r15, %rdi
movq %rsi, %r12
movq %rcx, %rdx
movq %r13, %rcx
callq 0x29f90
subq %rax, %rbx
sbbq $0x0, %r14
movq (%rsp), %rax
movq 0x20(%rsp), %r11
movq %rbx, (%rax,%r11,8)
jb 0x26a9f
movq 0x8(%rsp), %r8
movq %r12, %rsi
movq (%rsp), %r10
movq 0x38(%rsp), %r15
movq %rbp, %rdi
movq 0x30(%rsp), %rbp
movq 0x18(%rsp), %r12
movq 0x28(%rsp), %rax
movq %r13, (%rax,%r11,8)
addq $0x8, %rsi
incq %r12
decq %r11
addq $-0x8, %rdi
jmp 0x26891
movq %r12, %rax
movq %r10, %r12
movq %rdi, 0x40(%rsp)
leaq (%rdi,%rax,8), %rbp
addq %r11, %r15
movq %rbp, %rdi
movq %rsi, %rbx
movq %r15, %rdx
pushq $-0x1
popq %r13
movq %r13, %rcx
callq 0x29f90
cmpq %rax, %r14
jne 0x26aea
movq 0x8(%rsp), %r8
movq %rbx, %rsi
movq 0x40(%rsp), %rdi
movq %r12, %r10
movq 0x20(%rsp), %r11
movq 0x8(%r10,%r11,8), %r14
movq 0x38(%rsp), %r15
jmp 0x269f5
ja 0x26a77
cmpq %r8, %rbx
jb 0x269af
incq %r13
movq %r8, 0xb8(%rsp)
movq %rbp, 0xc0(%rsp)
subq 0xb8(%rsp), %rbx
sbbq 0xc0(%rsp), %r14
jmp 0x269af
movq 0x38(%rsp), %rax
leaq (%rax,%r11), %rcx
decq %rcx
movq %r15, %rdi
movq %r15, %rsi
movq %rax, %r15
movq %r12, %rbx
movq %r12, %rdx
movq %r11, %r12
callq 0x17cf0
movq %r12, %r11
movq %rbx, %rsi
movq 0x30(%rsp), %rcx
addq %rcx, %r14
addq %rax, %r14
decq %r13
movq 0x8(%rsp), %r8
movq (%rsp), %r10
movq %rbp, %rdi
movq %rcx, %rbp
jmp 0x269fa
andq 0x10(%rsp), %rax
cmpq %rax, %r14
jae 0x26b13
movq %rbp, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x17cf0
movq %rbx, %rsi
pushq $-0x2
popq %r13
movq 0x8(%rsp), %r8
jmp 0x26b28
movq $0x0, 0x10(%rsp)
pushq $-0x1
popq %r13
movq 0x8(%rsp), %r8
movq %rbx, %rsi
movq (%rsp), %r10
movq 0x40(%rsp), %rdi
jmp 0x26a5b
addq $0x8, %r10
movq %r10, %rdi
jmp 0x26c45
cmpq %rax, %r14
jae 0x26c7f
movq 0x48(%rsp), %rax
movq %rax, 0x170(%rsp)
movq %r14, %rax
mulq 0x170(%rsp)
movq %rax, %rcx
movq %rdx, %r15
movq 0x8(%r10,%r11,8), %r9
movq %r9, 0x160(%rsp)
movq %r14, 0x168(%rsp)
addq 0x160(%rsp), %rcx
adcq 0x168(%rsp), %r15
movq %r15, %rax
imulq %rbp, %rax
subq %rax, %r9
movq (%r10,%r11,8), %rsi
movq %rbp, 0x158(%rsp)
movq %r8, 0x150(%rsp)
subq 0x150(%rsp), %rsi
sbbq 0x158(%rsp), %r9
movq %r15, 0x148(%rsp)
movq %r8, %rax
mulq 0x148(%rsp)
movq %rdx, 0x140(%rsp)
movq %rax, 0x138(%rsp)
subq 0x138(%rsp), %rsi
sbbq 0x140(%rsp), %r9
cmpq %rcx, %r9
adcq $-0x1, %r15
xorl %eax, %eax
cmpq %rcx, %r9
movl $0x0, %ecx
cmovaeq %rbp, %rcx
cmovaeq %r8, %rax
incq %r15
movq %rcx, 0x130(%rsp)
movq %rax, 0x128(%rsp)
addq 0x128(%rsp), %rsi
adcq 0x130(%rsp), %r9
movq %r9, %r14
cmpq %rbp, %r9
jae 0x26cac
movq %r14, 0x8(%r10,%r11,8)
movq %rsi, (%r10,%r11,8)
movq 0x28(%rsp), %rax
movq %r15, (%rax,%r11,8)
cmpq %r14, 0x8(%rdi)
jne 0x26c67
xorl %eax, %eax
cmpl $0x0, 0x54(%rsp)
setns %al
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xcd77(%rip), %rdi      # 0x339e5
leaq 0xcd5c(%rip), %rdx      # 0x339d1
movl $0xc4, %esi
callq 0x29ce6
movq %r10, %r12
movq %r11, %rbp
pushq $0x2
popq %rdx
pushq $-0x1
popq %r15
movq %rdi, %r13
movq %r15, %rcx
movq %rsi, %rbx
callq 0x29f90
cmpq %rax, %r14
jne 0x26cdb
movq %rbp, %r11
movq 0x8(%r12,%rbp,8), %r14
movq %r13, %rdi
jmp 0x26c3c
ja 0x26cb3
cmpq %r8, %rsi
jb 0x26c33
incq %r15
movq %r8, 0x118(%rsp)
movq %rbp, 0x120(%rsp)
subq 0x118(%rsp), %rsi
sbbq 0x120(%rsp), %r14
jmp 0x26c33
andq 0x10(%rsp), %rax
cmpq %rax, %r14
movq 0x8(%r12,%rbp,8), %r14
jae 0x26d2e
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movq (%rsp), %rsi
movq %rbp, %r11
movq (%rsi,%rbp,8), %rdx
movq %rax, 0x178(%rsp)
movq %rcx, 0x180(%rsp)
addq 0x178(%rsp), %rdx
adcq 0x180(%rsp), %r14
movq %r14, 0x8(%rsi,%rbp,8)
movq %rdx, (%rsi,%rbp,8)
pushq $-0x2
popq %r15
jmp 0x26ca7
movq %r13, %rdi
movq %rbp, %r11
jmp 0x26c3c
nopl (%rax)