// File: marxn[P]pupp/3rdparty/gmp/mpn/divrem.c
// Function: _gmpn_divrem
mp_limb_t
mpn_divrem (mp_ptr qp, mp_size_t qxn,
	    mp_ptr np, mp_size_t nn,
	    mp_srcptr dp, mp_size_t dn)
{
  ASSERT (qxn >= 0);
  ASSERT (nn >= dn);
  ASSERT (dn >= 1);
  ASSERT (dp[dn-1] & GMP_NUMB_HIGHBIT);
  ASSERT (! MPN_OVERLAP_P (np, nn, dp, dn));
  ASSERT (! MPN_OVERLAP_P (qp, nn-dn+qxn, np, nn) || qp==np+dn+qxn);
  ASSERT (! MPN_OVERLAP_P (qp, nn-dn+qxn, dp, dn));
  ASSERT_MPN (np, nn);
  ASSERT_MPN (dp, dn);

  if (dn == 1)
    {
      mp_limb_t ret;
      mp_ptr q2p;
      mp_size_t qn;
      TMP_DECL;

      TMP_MARK;
      q2p = TMP_ALLOC_LIMBS (nn + qxn);

      np[0] = mpn_divrem_1 (q2p, qxn, np, nn, dp[0]);
      qn = nn + qxn - 1;
      MPN_COPY (qp, q2p, qn);
      ret = q2p[qn];

      TMP_FREE;
      return ret;
    }
  else if (dn == 2)
    {
      return mpn_divrem_2 (qp, qxn, np, nn, dp);
    }
  else
    {
      mp_ptr rp, q2p;
      mp_limb_t qhl;
      mp_size_t qn;
      TMP_DECL;

      TMP_MARK;
      if (UNLIKELY (qxn != 0))
	{
	  mp_ptr n2p;
	  n2p = TMP_ALLOC_LIMBS (nn + qxn);
	  MPN_ZERO (n2p, qxn);
	  MPN_COPY (n2p + qxn, np, nn);
	  q2p = TMP_ALLOC_LIMBS (nn - dn + qxn + 1);
	  rp = TMP_ALLOC_LIMBS (dn);
	  mpn_tdiv_qr (q2p, rp, 0L, n2p, nn + qxn, dp, dn);
	  MPN_COPY (np, rp, dn);
	  qn = nn - dn + qxn;
	  MPN_COPY (qp, q2p, qn);
	  qhl = q2p[qn];
	}
      else
	{
	  q2p = TMP_ALLOC_LIMBS (nn - dn + 1);
	  rp = TMP_ALLOC_LIMBS (dn);
	  mpn_tdiv_qr (q2p, rp, 0L, np, nn, dp, dn);
	  MPN_COPY (np, rp, dn);	/* overwrite np area with remainder */
	  qn = nn - dn;
	  MPN_COPY (qp, q2p, qn);
	  qhl = q2p[qn];
	}
      TMP_FREE;
      return qhl;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
jmp 0x37555
jmp 0x37557
jmp 0x37559
jmp 0x3755b
jmp 0x3755d
jmp 0x3755f
jmp 0x37561
jmp 0x37563
jmp 0x37565
jmp 0x37567
jmp 0x37569
jmp 0x3756b
jmp 0x3756d
jmp 0x3756f
jmp 0x37571
jmp 0x37573
jmp 0x37575
cmpq $0x1, -0x38(%rbp)
jne 0x376a4
movq $0x0, -0x58(%rbp)
movq -0x28(%rbp), %rax
addq -0x18(%rbp), %rax
shlq $0x3, %rax
cmpq $0x7f00, %rax           # imm = 0x7F00
setbe %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x375de
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
addq %rcx, %rax
leaq 0xf(,%rax,8), %rcx
andq $-0x10, %rcx
movq %rsp, %rax
subq %rcx, %rax
movq %rax, %rsp
movq %rax, -0xa0(%rbp)
jmp 0x375fa
movq -0x28(%rbp), %rsi
addq -0x18(%rbp), %rsi
shlq $0x3, %rsi
leaq -0x58(%rbp), %rdi
callq 0x56430
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rax
movq (%rax), %r8
callq 0x37ba0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
addq -0x18(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x3763d
jmp 0x3763f
jmp 0x37641
jmp 0x37643
jmp 0x37645
jmp 0x37647
jmp 0x37649
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x554c6
jmp 0x3765c
movq -0x48(%rbp), %rax
movq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x58(%rbp)
setne %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x37695
movq -0x58(%rbp), %rdi
callq 0x564a0
jmp 0x37697
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x37b5a
cmpq $0x2, -0x38(%rbp)
jne 0x376cd
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x37dc0
movq %rax, -0x8(%rbp)
jmp 0x37b5a
movq $0x0, -0x80(%rbp)
cmpq $0x0, -0x18(%rbp)
setne %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x379a9
movq -0x28(%rbp), %rax
addq -0x18(%rbp), %rax
shlq $0x3, %rax
cmpq $0x7f00, %rax           # imm = 0x7F00
setbe %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x3774f
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
addq %rcx, %rax
leaq 0xf(,%rax,8), %rcx
andq $-0x10, %rcx
movq %rsp, %rax
subq %rcx, %rax
movq %rax, %rsp
movq %rax, -0xa8(%rbp)
jmp 0x3776b
movq -0x28(%rbp), %rsi
addq -0x18(%rbp), %rsi
shlq $0x3, %rsi
leaq -0x80(%rbp), %rdi
callq 0x56430
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x3777b
jmp 0x3777d
cmpq $0x0, -0x18(%rbp)
je 0x377db
jmp 0x37786
movq -0x88(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x98(%rbp)
jmp 0x377a1
jmp 0x377a3
movq -0x90(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x90(%rbp)
movq $0x0, (%rax)
movq -0x98(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x98(%rbp)
cmpq $0x0, %rax
jne 0x377a3
jmp 0x377d9
jmp 0x377db
jmp 0x377dd
jmp 0x377df
jmp 0x377e1
jmp 0x377e3
jmp 0x377e5
jmp 0x377e7
jmp 0x377e9
jmp 0x377eb
jmp 0x377ed
movq -0x88(%rbp), %rdi
movq -0x18(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x554c6
jmp 0x3780e
movq -0x28(%rbp), %rax
subq -0x38(%rbp), %rax
addq -0x18(%rbp), %rax
addq $0x1, %rax
shlq $0x3, %rax
cmpq $0x7f00, %rax           # imm = 0x7F00
setbe %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x37873
movq -0x28(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
movq -0x18(%rbp), %rcx
addq %rcx, %rax
leaq 0x17(,%rax,8), %rcx
andq $-0x10, %rcx
movq %rsp, %rax
subq %rcx, %rax
movq %rax, %rsp
movq %rax, -0xb0(%rbp)
jmp 0x37897
movq -0x28(%rbp), %rsi
subq -0x38(%rbp), %rsi
addq -0x18(%rbp), %rsi
addq $0x1, %rsi
shlq $0x3, %rsi
leaq -0x80(%rbp), %rdi
callq 0x56430
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x38(%rbp), %rax
shlq $0x3, %rax
cmpq $0x7f00, %rax           # imm = 0x7F00
setbe %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x378ed
movq -0x38(%rbp), %rax
leaq 0xf(,%rax,8), %rcx
andq $-0x10, %rcx
movq %rsp, %rax
subq %rcx, %rax
movq %rax, %rsp
movq %rax, -0xb8(%rbp)
jmp 0x37905
movq -0x38(%rbp), %rsi
shlq $0x3, %rsi
leaq -0x80(%rbp), %rdi
callq 0x56430
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x88(%rbp), %rcx
movq -0x28(%rbp), %r8
addq -0x18(%rbp), %r8
movq -0x30(%rbp), %r9
movq -0x38(%rbp), %rax
xorl %edx, %edx
subq $0x10, %rsp
movq %rax, (%rsp)
callq 0x3cde0
addq $0x10, %rsp
jmp 0x37944
jmp 0x37946
jmp 0x37948
jmp 0x3794a
jmp 0x3794c
jmp 0x3794e
jmp 0x37950
movq -0x20(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x554c6
jmp 0x37963
movq -0x28(%rbp), %rax
subq -0x38(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x37975
jmp 0x37977
jmp 0x37979
jmp 0x3797b
jmp 0x3797d
jmp 0x3797f
jmp 0x37981
movq -0x10(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x78(%rbp), %rdx
callq 0x554c6
jmp 0x37994
movq -0x68(%rbp), %rax
movq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x70(%rbp)
jmp 0x37b25
movq -0x28(%rbp), %rax
subq -0x38(%rbp), %rax
addq $0x1, %rax
shlq $0x3, %rax
cmpq $0x7f00, %rax           # imm = 0x7F00
setbe %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x37a03
movq -0x28(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
leaq 0x17(,%rax,8), %rcx
andq $-0x10, %rcx
movq %rsp, %rax
subq %rcx, %rax
movq %rax, %rsp
movq %rax, -0xc0(%rbp)
jmp 0x37a23
movq -0x28(%rbp), %rsi
subq -0x38(%rbp), %rsi
addq $0x1, %rsi
shlq $0x3, %rsi
leaq -0x80(%rbp), %rdi
callq 0x56430
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x38(%rbp), %rax
shlq $0x3, %rax
cmpq $0x7f00, %rax           # imm = 0x7F00
setbe %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x37a79
movq -0x38(%rbp), %rax
leaq 0xf(,%rax,8), %rcx
andq $-0x10, %rcx
movq %rsp, %rax
subq %rcx, %rax
movq %rax, %rsp
movq %rax, -0xc8(%rbp)
jmp 0x37a91
movq -0x38(%rbp), %rsi
shlq $0x3, %rsi
leaq -0x80(%rbp), %rdi
callq 0x56430
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
movq -0x38(%rbp), %rax
xorl %edx, %edx
subq $0x10, %rsp
movq %rax, (%rsp)
callq 0x3cde0
addq $0x10, %rsp
jmp 0x37ac9
jmp 0x37acb
jmp 0x37acd
jmp 0x37acf
jmp 0x37ad1
jmp 0x37ad3
jmp 0x37ad5
movq -0x20(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x554c6
jmp 0x37ae8
movq -0x28(%rbp), %rax
subq -0x38(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x37af6
jmp 0x37af8
jmp 0x37afa
jmp 0x37afc
jmp 0x37afe
jmp 0x37b00
jmp 0x37b02
movq -0x10(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x78(%rbp), %rdx
callq 0x554c6
jmp 0x37b15
movq -0x68(%rbp), %rax
movq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x70(%rbp)
jmp 0x37b27
cmpq $0x0, -0x80(%rbp)
setne %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x37b50
movq -0x80(%rbp), %rdi
callq 0x564a0
jmp 0x37b52
movq -0x70(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rbp, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)