// File: /workspace/github_cpp_makefile_star2_O2/marxn[P]pupp/3rdparty/gmp/mpf/div.c
// Function: _gmpf_div
void
mpf_div (mpf_ptr r, mpf_srcptr u, mpf_srcptr v)
{
  mp_srcptr up, vp;
  mp_ptr rp, tp, new_vp;
  mp_size_t usize, vsize, rsize, prospective_rsize, tsize, zeros;
  mp_size_t sign_quotient, prec, high_zero, chop;
  mp_exp_t rexp;
  int copy_u;
  TMP_DECL;

  usize = SIZ(u);
  vsize = SIZ(v);

  if (UNLIKELY (vsize == 0))
    DIVIDE_BY_ZERO;

  if (usize == 0)
    {
      SIZ(r) = 0;
      EXP(r) = 0;
      return;
    }

  sign_quotient = usize ^ vsize;
  usize = ABS (usize);
  vsize = ABS (vsize);
  prec = PREC(r);

  TMP_MARK;
  rexp = EXP(u) - EXP(v) + 1;

  rp = PTR(r);
  up = PTR(u);
  vp = PTR(v);

  prospective_rsize = usize - vsize + 1; /* quot from using given u,v sizes */
  rsize = prec + 1;			 /* desired quot */

  zeros = rsize - prospective_rsize;	 /* padding u to give rsize */
  copy_u = (zeros > 0 || rp == up);	 /* copy u if overlap or padding */

  chop = MAX (-zeros, 0);		 /* negative zeros means shorten u */
  up += chop;
  usize -= chop;
  zeros += chop;			 /* now zeros >= 0 */

  tsize = usize + zeros;		 /* size for possible copy of u */

  /* copy and possibly extend u if necessary */
  if (copy_u)
    {
      tp = TMP_ALLOC_LIMBS (tsize + 1);	/* +1 for mpn_div_q's scratch needs */
      MPN_ZERO (tp, zeros);
      MPN_COPY (tp+zeros, up, usize);
      up = tp;
      usize = tsize;
    }
  else
    {
      tp = TMP_ALLOC_LIMBS (usize + 1);
    }

  /* ensure divisor doesn't overlap quotient */
  if (rp == vp)
    {
      new_vp = TMP_ALLOC_LIMBS (vsize);
      MPN_COPY (new_vp, vp, vsize);
      vp = new_vp;
    }

  ASSERT (usize-vsize+1 == rsize);
  mpn_div_q (rp, up, usize, vp, vsize, tp);

  /* strip possible zero high limb */
  high_zero = (rp[rsize-1] == 0);
  rsize -= high_zero;
  rexp -= high_zero;

  SIZ(r) = sign_quotient >= 0 ? rsize : -rsize;
  EXP(r) = rexp;
  TMP_FREE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movslq 0x4(%rdx), %rax
testq %rax, %rax
je 0x17a08
movslq 0x4(%rsi), %r11
testl %r11d, %r11d
je 0x1790c
movq %r11, %r13
negq %r13
cmovsq %r11, %r13
movq %rax, %r8
negq %r8
movq %rax, -0x48(%rbp)
cmovsq %rax, %r8
movslq (%rdi), %r9
andq $0x0, -0x40(%rbp)
movq 0x8(%rsi), %rax
movq %rax, -0x78(%rbp)
movq 0x10(%rsi), %r10
movq 0x8(%rdx), %rax
movq %rax, -0x70(%rbp)
movq 0x10(%rdx), %rcx
movq %rdi, -0x80(%rbp)
movq 0x10(%rdi), %r14
movq %r13, %rax
notq %rax
addq %r8, %rax
movq %r9, -0x50(%rbp)
addq %r9, %rax
incq %rax
testq %rax, %rax
setg %dl
cmpq %r10, %r14
sete %sil
orb %dl, %sil
movq %rax, %rdx
negq %rdx
xorl %ebx, %ebx
testq %rdx, %rdx
cmovgq %rdx, %rbx
leaq (%r10,%rbx,8), %rdx
movq %r13, %r15
subq %rbx, %r15
cmpb $0x1, %sil
jne 0x1791a
addq %rax, %rbx
addq %rax, %r13
leaq 0x8(,%r13,8), %rsi
cmpq $0x7f00, %rsi           # imm = 0x7F00
movq %rcx, -0x60(%rbp)
ja 0x17a14
movq %rsp, %r12
addq $0xf, %rsi
andq $-0x10, %rsi
subq %rsi, %r12
movq %r12, %rsp
movq %r11, -0x58(%rbp)
movq %r8, -0x68(%rbp)
testq %rbx, %rbx
je 0x178ec
movq %rdx, -0x38(%rbp)
leaq (,%rbx,8), %rdx
movq %r12, %rdi
xorl %esi, %esi
callq 0x6170
movq -0x38(%rbp), %rdx
leaq (%r12,%rbx,8), %rdi
movq %rdx, %rsi
movq %r15, %rdx
callq 0x290c6
movq %r12, %rdx
movq -0x68(%rbp), %r8
movq -0x60(%rbp), %rcx
movq -0x58(%rbp), %r11
jmp 0x17943
andl $0x0, 0x4(%rdi)
andq $0x0, 0x8(%rdi)
jmp 0x179f9
leaq 0x8(,%r15,8), %rsi
cmpq $0x7f00, %rsi           # imm = 0x7F00
ja 0x17a41
movq %rsp, %r12
addq $0xf, %rsi
andq $-0x10, %rsi
subq %rsi, %r12
movq %r12, %rsp
movq %r15, %r13
movq -0x48(%rbp), %r15
xorq %r11, %r15
movq -0x50(%rbp), %rax
leaq 0x1(%rax), %rbx
cmpq %rcx, %r14
jne 0x179ac
movq %rdx, -0x38(%rbp)
movq %r14, -0x30(%rbp)
movq %r15, -0x48(%rbp)
leaq (,%r8,8), %rsi
cmpq $0xfe0, %r8             # imm = 0xFE0
ja 0x17a72
movq %rsp, %r15
addq $0xf, %rsi
andq $-0x10, %rsi
subq %rsi, %r15
movq %r15, %rsp
movq %r15, %rdi
movq %rcx, %rsi
movq %r8, %rdx
movq %r8, %r14
callq 0x290c6
movq %r14, %r8
movq %r15, %rcx
movq -0x48(%rbp), %r15
movq -0x30(%rbp), %r14
movq -0x38(%rbp), %rdx
movq %r14, %rdi
movq %rdx, %rsi
movq %r13, %rdx
movq %r12, %r9
callq 0x1ac84
xorl %eax, %eax
movq -0x50(%rbp), %rcx
cmpq $0x0, (%r14,%rcx,8)
sete %al
subl %eax, %ebx
movq -0x78(%rbp), %rdx
subq -0x70(%rbp), %rdx
subq %rax, %rdx
incq %rdx
movl %ebx, %eax
negl %eax
testq %r15, %r15
cmovnsl %ebx, %eax
movq -0x80(%rbp), %rcx
movl %eax, 0x4(%rcx)
movq %rdx, 0x8(%rcx)
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
jne 0x17a0d
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x29d3c
callq 0x29df3
jmp 0x179f9
movq %r14, -0x30(%rbp)
leaq -0x40(%rbp), %rdi
movq %r8, %r12
movq %rdx, -0x38(%rbp)
movq %r11, %r14
callq 0x29dc0
movq %r14, %r11
movq -0x38(%rbp), %rdx
movq %r12, %r8
movq -0x30(%rbp), %r14
movq %rax, %r12
jmp 0x178c5
movq %r14, -0x30(%rbp)
leaq -0x40(%rbp), %rdi
movq %r8, %rbx
movq %rcx, %r12
movq %rdx, %r14
movq %r11, %r13
callq 0x29dc0
movq %r13, %r11
movq %r14, %rdx
movq %r12, %rcx
movq %rbx, %r8
movq -0x30(%rbp), %r14
movq %rax, %r12
jmp 0x17940
leaq -0x40(%rbp), %rdi
movq %r8, %r15
movq %rcx, %r14
callq 0x29dc0
movq %r14, %rcx
movq %r15, %r8
movq %rax, %r15
jmp 0x17989
nop