// File: /workspace/github_cpp_makefile_star2_O1/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 $0x198, %rsp            # imm = 0x198
movq %r9, 0x58(%rsp)
movq %r8, %r15
movq %rsi, %rbp
movq %rdi, %r12
leaq (%rsi,%rdx,8), %rdi
movq %rdx, %r14
subq %r8, %r14
leaq 0x1(%r14), %rax
movq %rax, %r8
subq %r15, %r8
movq %r15, %r13
cmovlq %rax, %r13
negq %r8
leaq (,%r13,8), %rsi
movq %rdi, %rbx
movq %rsi, 0x48(%rsp)
subq %rsi, %rdi
xorl %esi, %esi
cmpq %rax, %r15
cmovgq %r8, %rsi
cmovgq %r15, %rax
leaq (%rcx,%rsi,8), %r10
addq %r15, %rax
shlq $0x3, %rax
leaq (,%rdx,8), %rsi
movq %rsi, 0x8(%rsp)
subq %rsi, %rax
addq %rcx, %rax
addq $-0x10, %rax
movq %rdx, 0x50(%rsp)
leaq -0x8(,%rdx,8), %rcx
addq %rbp, %rcx
movq %r13, %rdx
testq %rdx, %rdx
jle 0x2c323
movq (%rax,%rdx,8), %rsi
decq %rdx
leaq -0x8(%rcx), %r8
cmpq %rsi, (%rcx)
movq %r8, %rcx
je 0x2c306
seta %al
jmp 0x2c325
movb $0x1, %al
movb %al, 0x7(%rsp)
testb %al, %al
movq %r10, 0x20(%rsp)
je 0x2c345
movq %rdi, %rsi
movq %r10, %rdx
movq %r13, %rcx
callq 0x1c1c0
movq 0x20(%rsp), %r10
movq -0x10(%r10,%r13,8), %r9
movq -0x8(%r10,%r13,8), %r8
movq %rbx, %rcx
movq -0x8(%rbx), %rdi
movq %r14, %rbx
subq %r13, %rbx
movq %r8, 0x18(%rsp)
movq %r9, 0x40(%rsp)
movq %r13, 0x38(%rsp)
js 0x2c5d9
leaq -0x2(%r13), %rax
movq %rax, 0x28(%rsp)
leaq -0x1(%r13), %rax
movq %rax, 0x60(%rsp)
shlq $0x3, %r15
subq %r15, %r12
movq 0x48(%rsp), %rax
negq %rax
leaq (%rax,%rbp), %r13
addq $-0x8, %r13
addq $-0x10, %rbp
incq %rbx
movq 0x8(%rsp), %r11
cmpq %r8, %rdi
je 0x2c518
movq %r12, 0x30(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x190(%rsp)
movq %rdi, %rax
mulq 0x190(%rsp)
movq %rax, %rcx
movq %rdx, %r15
movq (%rbp,%r11), %rsi
movq %rsi, 0x180(%rsp)
movq %rdi, 0x188(%rsp)
addq 0x180(%rsp), %rcx
adcq 0x188(%rsp), %r15
movq %r15, %rax
imulq %r8, %rax
subq %rax, %rsi
movq -0x8(%rbp,%r11), %r12
movq %r8, 0x178(%rsp)
movq %r9, 0x170(%rsp)
subq 0x170(%rsp), %r12
sbbq 0x178(%rsp), %rsi
movq %r15, 0x168(%rsp)
movq %r9, %rax
mulq 0x168(%rsp)
movq %rdx, 0x160(%rsp)
movq %rax, 0x158(%rsp)
subq 0x158(%rsp), %r12
sbbq 0x160(%rsp), %rsi
cmpq %rcx, %rsi
adcq $-0x1, %r15
cmpq %rcx, %rsi
movl $0x0, %eax
cmovaeq %r8, %rax
movl $0x0, %ecx
cmovaeq %r9, %rcx
incq %r15
movq %rax, 0x150(%rsp)
movq %rcx, 0x148(%rsp)
addq 0x148(%rsp), %r12
adcq 0x150(%rsp), %rsi
movq %rsi, %rax
cmpq %r8, %rsi
movq %rbp, 0x10(%rsp)
jae 0x2c553
movq %rax, %rbp
leaq (%r11,%r13), %r14
movq %r14, %rdi
movq %r10, %rsi
movq 0x28(%rsp), %rdx
movq %r15, %rcx
callq 0x30370
movq 0x8(%rsp), %r11
subq %rax, %r12
movq %rbp, %rdi
sbbq $0x0, %rdi
movq 0x10(%rsp), %rbp
movq %r12, -0x8(%rbp,%r11)
jb 0x2c586
movq 0x18(%rsp), %r8
movq 0x30(%rsp), %r12
movq %r15, -0x8(%r12,%r11)
addq $-0x8, %r12
addq $-0x8, %rbp
addq $-0x8, %r13
decq %rbx
testq %rbx, %rbx
movq 0x40(%rsp), %r9
movq 0x20(%rsp), %r10
jg 0x2c3a6
jmp 0x2c5b9
cmpq %r9, (%rbp,%r11)
jne 0x2c3af
leaq (%r11,%r13), %rdi
movq $-0x1, %r15
movq %r10, %rsi
movq 0x38(%rsp), %rdx
movq $-0x1, %rcx
callq 0x30370
movq 0x8(%rsp), %r11
movq 0x18(%rsp), %r8
movq (%rbp,%r11), %rdi
jmp 0x2c4ec
ja 0x2c55e
cmpq %r9, %r12
jb 0x2c4a9
incq %r15
movq %r9, 0x138(%rsp)
movq %r8, 0x140(%rsp)
subq 0x138(%rsp), %r12
sbbq 0x140(%rsp), %rax
jmp 0x2c4a9
movq %rdi, %r12
movq %r14, %rdi
movq %r14, %rsi
movq 0x20(%rsp), %rdx
movq 0x60(%rsp), %rcx
callq 0x1bfa0
movq 0x8(%rsp), %r11
movq %r12, %rdi
movq 0x18(%rsp), %r8
addq %r8, %rdi
addq %rax, %rdi
decq %r15
jmp 0x2c4e7
movq 0x50(%rsp), %rcx
leaq (%r12,%rcx,8), %rax
movq %rax, 0x30(%rsp)
leaq (,%rcx,8), %r12
addq %rbp, %r12
movq 0x38(%rsp), %r13
jmp 0x2c5e9
leaq (%r12,%r14,8), %rax
movq %rax, 0x30(%rsp)
addq $-0x10, %rcx
movq %rcx, %r12
cmpq $0x2, %r13
movb 0x7(%rsp), %bl
jl 0x2c8c5
movq $-0x1, %rcx
je 0x2c8dc
movq %r12, %rax
subq 0x48(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
xorl %r15d, %r15d
xorl %ebx, %ebx
movq %r12, 0x28(%rsp)
leaq (%r10,%rbx), %rsi
leaq (%r15,%r13), %r11
addq $-0x2, %r11
movq %rcx, 0x10(%rsp)
movq %rcx, %rax
andq %r8, %rax
cmpq %rax, %rdi
movq %rsi, 0x48(%rsp)
jae 0x2c799
movq 0x58(%rsp), %rax
movq %rax, 0x130(%rsp)
movq %rdi, %rax
mulq 0x130(%rsp)
movq %rax, %rcx
movq %rdx, %rbp
movq (%r12,%r15,8), %r10
movq %r10, 0x120(%rsp)
movq %rdi, 0x128(%rsp)
addq 0x120(%rsp), %rcx
adcq 0x128(%rsp), %rbp
movq %rbp, %rax
imulq %r8, %rax
subq %rax, %r10
movq -0x8(%r12,%r15,8), %r13
movq %r8, 0x118(%rsp)
movq %r9, 0x110(%rsp)
subq 0x110(%rsp), %r13
sbbq 0x118(%rsp), %r10
movq %rbp, 0x108(%rsp)
movq %r9, %rax
mulq 0x108(%rsp)
movq %rdx, 0x100(%rsp)
movq %rax, 0xf8(%rsp)
subq 0xf8(%rsp), %r13
sbbq 0x100(%rsp), %r10
cmpq %rcx, %r10
adcq $-0x1, %rbp
cmpq %rcx, %r10
movl $0x0, %eax
cmovaeq %r8, %rax
movl $0x0, %ecx
cmovaeq %r9, %rcx
incq %rbp
movq %rax, 0xf0(%rsp)
movq %rcx, 0xe8(%rsp)
addq 0xe8(%rsp), %r13
adcq 0xf0(%rsp), %r10
movq %r10, %r12
cmpq %r8, %r10
jae 0x2c7ed
movq 0x8(%rsp), %rdi
movq %r11, %r14
movq %r11, %rdx
movq %rbp, %rcx
callq 0x30370
subq %rax, %r13
movq %r12, %rdi
sbbq $0x0, %rdi
movq 0x28(%rsp), %r12
movq %r13, -0x8(%r12,%r15,8)
jb 0x2c820
movq 0x18(%rsp), %r8
movq 0x40(%rsp), %r9
movq 0x20(%rsp), %r10
movq 0x38(%rsp), %r13
movq 0x10(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rbp, -0x8(%rax,%r15,8)
addq $0x8, %rbx
decq %r15
cmpq $0x1, %r14
jg 0x2c61f
jmp 0x2c8cd
movq %r11, 0x50(%rsp)
leaq (%r15,%r13), %r14
movq $-0x1, %rbp
movq %rdi, %r12
movq 0x8(%rsp), %rdi
movq %r14, %rdx
movq $-0x1, %rcx
callq 0x30370
cmpq %rax, %r12
jne 0x2c866
movq 0x18(%rsp), %r8
movq 0x40(%rsp), %r9
movq 0x20(%rsp), %r10
movq 0x28(%rsp), %r12
movq 0x10(%rsp), %rcx
movq (%r12,%r15,8), %rdi
movq 0x50(%rsp), %r14
jmp 0x2c779
ja 0x2c7f8
cmpq %r9, %r13
jb 0x2c733
incq %rbp
movq %r9, 0xd8(%rsp)
movq %r8, 0xe0(%rsp)
subq 0xd8(%rsp), %r13
sbbq 0xe0(%rsp), %r12
jmp 0x2c733
movq 0x38(%rsp), %r13
leaq (%r15,%r13), %rcx
decq %rcx
movq %rdi, %r12
movq 0x8(%rsp), %rdi
movq %rdi, %rsi
movq 0x48(%rsp), %rdx
callq 0x1bfa0
movq %r12, %rdi
movq 0x28(%rsp), %r12
movq 0x18(%rsp), %r8
addq %r8, %rdi
addq %rax, %rdi
decq %rbp
movq 0x40(%rsp), %r9
movq 0x20(%rsp), %r10
jmp 0x2c774
movq 0x48(%rsp), %rdx
andq 0x10(%rsp), %rax
cmpq %rax, %r12
jae 0x2c8a5
movq 0x8(%rsp), %rdi
movq %rdi, %rsi
movq %r14, %rcx
callq 0x1bfa0
movq $-0x2, %rbp
movq 0x18(%rsp), %r8
movq 0x40(%rsp), %r9
movq 0x20(%rsp), %r10
movq 0x38(%rsp), %r13
jmp 0x2c7d8
xorl %ecx, %ecx
movq 0x18(%rsp), %r8
movq 0x40(%rsp), %r9
movq 0x20(%rsp), %r10
movq 0x38(%rsp), %r13
movq 0x28(%rsp), %r12
jmp 0x2c7e2
movq %r12, %r14
jmp 0x2c9e6
subq %rbx, 0x30(%rsp)
subq %rbx, %r12
addq %rbx, %r10
movb 0x7(%rsp), %bl
leaq -0x8(%r12), %r14
movq %rcx, %rax
andq %r8, %rax
cmpq %rax, %rdi
jae 0x2ca06
movq 0x58(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq %rdi, %rax
mulq 0xc0(%rsp)
movq %rax, %rcx
movq %r12, %r11
movq %rdx, %r12
movq (%r11), %rsi
movq %rsi, 0xb0(%rsp)
movq %rdi, 0xb8(%rsp)
addq 0xb0(%rsp), %rcx
adcq 0xb8(%rsp), %r12
movq %r12, %rax
imulq %r8, %rax
subq %rax, %rsi
movq %r11, %r10
movq -0x8(%r11), %rdi
movq %r8, 0xa8(%rsp)
movq %r9, 0xa0(%rsp)
subq 0xa0(%rsp), %rdi
sbbq 0xa8(%rsp), %rsi
movq %r12, 0x98(%rsp)
movq %r9, %rax
mulq 0x98(%rsp)
movq %rdx, 0x90(%rsp)
movq %rax, 0x88(%rsp)
subq 0x88(%rsp), %rdi
sbbq 0x90(%rsp), %rsi
cmpq %rcx, %rsi
adcq $-0x1, %r12
xorl %eax, %eax
cmpq %rcx, %rsi
movl $0x0, %ecx
cmovaeq %r8, %rcx
cmovaeq %r9, %rax
incq %r12
movq %rcx, 0x80(%rsp)
movq %rax, 0x78(%rsp)
addq 0x78(%rsp), %rdi
adcq 0x80(%rsp), %rsi
cmpq %r8, %rsi
jae 0x2ca3f
movq %rsi, (%r10)
movq %rdi, -0x8(%r10)
movq 0x30(%rsp), %rax
movq %r12, -0x8(%rax)
movq %rsi, %rdi
cmpq %rdi, 0x8(%r14)
jne 0x2ca01
movzbl %bl, %eax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x7461
movq %rcx, 0x10(%rsp)
movq %r12, %r13
movq $-0x1, %r12
movl $0x2, %edx
movq %rdi, %rbp
movq %r14, %rdi
movq %r10, %rsi
movq $-0x1, %rcx
movq %r10, %r15
callq 0x30370
cmpq %rax, %rbp
jne 0x2ca62
movq %r13, %rdi
movq (%rdi), %rsi
jmp 0x2c9da
ja 0x2ca46
cmpq %r9, %rdi
jb 0x2c9d3
incq %r12
movq %r9, 0x68(%rsp)
movq %r8, 0x70(%rsp)
subq 0x68(%rsp), %rdi
sbbq 0x70(%rsp), %rsi
jmp 0x2c9d3
andq 0x10(%rsp), %rax
cmpq %rax, %rbp
movq %r13, %rdi
jae 0x2ca3a
movq %r15, %rdx
movq -0x8(%rdi), %rax
movq (%rdi), %rcx
movq (%rdx), %rdx
movq 0x8(%r15), %rsi
movq %rdx, 0xc8(%rsp)
movq %rsi, 0xd0(%rsp)
addq 0xc8(%rsp), %rax
adcq 0xd0(%rsp), %rcx
movq %rcx, (%rdi)
movq %rax, -0x8(%rdi)
movq $-0x2, %r12
jmp 0x2ca3a