// File: /workspace/github_cpp_makefile_star2_O3/marxn[P]pupp/3rdparty/gmp/./mini-gmp/mini-gmp.c
// Function: mpz_div_qr
static int
mpz_div_qr (mpz_t q, mpz_t r,
	    const mpz_t n, const mpz_t d, enum mpz_div_round_mode mode)
{
  mp_size_t ns, ds, nn, dn, qs;
  ns = n->_mp_size;
  ds = d->_mp_size;

  if (ds == 0)
    gmp_die("mpz_div_qr: Divide by zero.");

  if (ns == 0)
    {
      if (q)
	q->_mp_size = 0;
      if (r)
	r->_mp_size = 0;
      return 0;
    }

  nn = GMP_ABS (ns);
  dn = GMP_ABS (ds);

  qs = ds ^ ns;

  if (nn < dn)
    {
      if (mode == GMP_DIV_CEIL && qs >= 0)
	{
	  /* q = 1, r = n - d */
	  if (r)
	    mpz_sub (r, n, d);
	  if (q)
	    mpz_set_ui (q, 1);
	}
      else if (mode == GMP_DIV_FLOOR && qs < 0)
	{
	  /* q = -1, r = n + d */
	  if (r)
	    mpz_add (r, n, d);
	  if (q)
	    mpz_set_si (q, -1);
	}
      else
	{
	  /* q = 0, r = d */
	  if (r)
	    mpz_set (r, n);
	  if (q)
	    q->_mp_size = 0;
	}
      return 1;
    }
  else
    {
      mp_ptr np, qp;
      mp_size_t qn, rn;
      mpz_t tq, tr;

      mpz_init_set (tr, n);
      np = tr->_mp_d;

      qn = nn - dn + 1;

      if (q)
	{
	  mpz_init2 (tq, qn * GMP_LIMB_BITS);
	  qp = tq->_mp_d;
	}
      else
	qp = NULL;

      mpn_div_qr (qp, np, nn, d->_mp_d, dn);

      if (qp)
	{
	  qn -= (qp[qn-1] == 0);

	  tq->_mp_size = qs < 0 ? -qn : qn;
	}
      rn = mpn_normalized_size (np, dn);
      tr->_mp_size = ns < 0 ? - rn : rn;

      if (mode == GMP_DIV_FLOOR && qs < 0 && rn != 0)
	{
	  if (q)
	    mpz_sub_ui (tq, tq, 1);
	  if (r)
	    mpz_add (tr, tr, d);
	}
      else if (mode == GMP_DIV_CEIL && qs >= 0 && rn != 0)
	{
	  if (q)
	    mpz_add_ui (tq, tq, 1);
	  if (r)
	    mpz_sub (tr, tr, d);
	}

      if (q)
	{
	  mpz_swap (tq, q);
	  mpz_clear (tq);
	}
      if (r)
	mpz_swap (tr, r);

      mpz_clear (tr);

      return rn != 0;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %r13
movslq 0x4(%rcx), %rdi
testq %rdi, %rdi
je 0x3d56
movq %rdx, %r14
movslq 0x4(%rdx), %rax
testl %eax, %eax
je 0x39e8
movq %rsi, -0x70(%rbp)
movq %rax, %r15
negq %r15
cmovsq %rax, %r15
movq %rdi, %r12
negq %r12
cmovsq %rdi, %r12
xorq %rax, %rdi
movq %r15, %rbx
subq %r12, %rbx
jae 0x3a0d
cmpl $0x1, %r8d
sete %al
testq %rdi, %rdi
setns %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x3aac
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x39c1
movq %r14, %rsi
movq %rcx, %rdx
callq 0x33cf
movl $0x1, %r14d
testq %r13, %r13
je 0x3d1f
movq 0x8(%r13), %rax
movq $0x1, (%rax)
movl $0x1, 0x4(%r13)
jmp 0x3d1f
testq %r13, %r13
je 0x39f5
movl $0x0, 0x4(%r13)
xorl %r14d, %r14d
testq %rsi, %rsi
je 0x3d1f
movl $0x0, 0x4(%rsi)
jmp 0x3d1f
movq %rdi, -0xa0(%rbp)
movq %rax, -0xa8(%rbp)
movl %r8d, -0x74(%rbp)
movq %rcx, -0x48(%rbp)
movq %r13, -0x88(%rbp)
leaq -0x40(%rbp), %r13
movq $0x1, (%r13)
movl $0x8, %edi
callq *0xc65f(%rip)           # 0x100a0
movq %rax, 0x8(%r13)
movq %r13, %rdi
movq %r14, %rsi
callq 0x24a2
movq 0x8(%r13), %r13
movq %rbx, -0x98(%rbp)
incq %rbx
cmpq $0x0, -0x88(%rbp)
je 0x3afe
testq %rbx, %rbx
movabsq $0x3ffffffffffffff, %rax # imm = 0x3FFFFFFFFFFFFFF
movq %rax, %rcx
cmoveq %rbx, %rcx
addq %rbx, %rcx
andq %rax, %rcx
leaq 0x1(%rcx), %rax
movl %eax, -0x60(%rbp)
movl $0x0, -0x5c(%rbp)
leaq 0x8(,%rcx,8), %rdi
callq *0xc5fe(%rip)           # 0x100a0
movq %rax, -0x68(%rbp)
movq %rax, -0x58(%rbp)
jmp 0x3b06
testl %r8d, %r8d
sete %al
testq %rdi, %rdi
sets %dl
andb %al, %dl
cmpb $0x1, %dl
movq -0x70(%rbp), %rdi
jne 0x3d34
testq %rdi, %rdi
je 0x3ad7
movq %r14, %rsi
movq %rcx, %rdx
callq 0x30c3
movl $0x1, %r14d
testq %r13, %r13
je 0x3d1f
movl $0xffffffff, 0x4(%r13)  # imm = 0xFFFFFFFF
movq 0x8(%r13), %rax
movq $0x1, (%rax)
jmp 0x3d1f
movq $0x0, -0x68(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0xc8(%rbp), %r14
movq %r14, %rdi
movq %rsi, -0x80(%rbp)
movq %r12, %rdx
callq 0x5a01
cmpq $0x3, %r12
setae %al
movl (%r14), %r14d
testl %r14d, %r14d
setne %cl
testb %cl, %al
je 0x3ba0
leaq (,%r12,8), %rdi
callq *0xc55a(%rip)           # 0x100a0
movq %rax, -0x90(%rbp)
movq %rax, %rdi
movq -0x80(%rbp), %rsi
movq %r12, %rdx
movl %r14d, %ecx
callq 0x1a5d
testq %rax, %rax
jne 0x3d5b
leaq -0xc8(%rbp), %r9
movq -0x68(%rbp), %r14
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq -0x90(%rbp), %r15
movq %r15, %rcx
movq %r12, %r8
callq 0x5b6b
testq %r15, %r15
je 0x3bc0
movq %r15, %rdi
xorl %esi, %esi
callq *0xc512(%rip)           # 0x100b0
jmp 0x3bc0
leaq -0xc8(%rbp), %r9
movq -0x68(%rbp), %r14
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq -0x80(%rbp), %rcx
movq %r12, %r8
callq 0x5b6b
testq %r14, %r14
movq -0x70(%rbp), %r15
movq -0xa0(%rbp), %r8
je 0x3bec
movq -0x98(%rbp), %rax
cmpq $0x1, (%r14,%rax,8)
sbbl $0x0, %ebx
movl %ebx, %eax
negl %eax
testq %r8, %r8
cmovnsl %ebx, %eax
movl %eax, -0x5c(%rbp)
movq -0x48(%rbp), %rdx
movl -0x74(%rbp), %edi
cmpq $0x0, -0x8(%r13,%r12,8)
jne 0x3c0c
leaq -0x1(%r12), %rax
cmpq $0x1, %r12
movq %rax, %r12
jg 0x3bf3
xorl %r12d, %r12d
movq %r12, %rax
negq %rax
setb %cl
cmpl $0x0, -0xa8(%rbp)
cmovnsl %r12d, %eax
movl %eax, -0x3c(%rbp)
testl %edi, %edi
sete %al
testq %r8, %r8
sets %sil
andb %al, %sil
andb %cl, %sil
cmpb $0x1, %sil
movq -0x88(%rbp), %r14
jne 0x3c6f
testq %r14, %r14
je 0x3c5c
leaq -0x60(%rbp), %rdi
movl $0x1, %edx
movq %rdi, %rsi
callq 0x305d
movq -0x48(%rbp), %rdx
testq %r15, %r15
je 0x3cb5
leaq -0x40(%rbp), %rdi
movq %rdi, %rsi
callq 0x30c3
jmp 0x3cb5
testq %r12, %r12
sete %al
cmpl $0x1, %edi
setne %cl
testq %r8, %r8
sets %sil
orb %cl, %sil
orb %al, %sil
jne 0x3cb5
testq %r14, %r14
je 0x3ca4
leaq -0x60(%rbp), %rdi
movl $0x1, %edx
movq %rdi, %rsi
callq 0x2e5f
movq -0x48(%rbp), %rdx
testq %r15, %r15
je 0x3cb5
leaq -0x40(%rbp), %rdi
movq %rdi, %rsi
callq 0x33cf
testq %r14, %r14
je 0x3cdb
movl -0x5c(%rbp), %eax
movl %eax, 0x4(%r14)
movl -0x60(%rbp), %eax
movl %eax, (%r14)
movq -0x58(%rbp), %rax
movq 0x8(%r14), %rdi
movq %rax, 0x8(%r14)
xorl %esi, %esi
callq *0xc3d5(%rip)           # 0x100b0
movq -0x38(%rbp), %rdi
testq %r15, %r15
je 0x3d0d
movl -0x3c(%rbp), %eax
movl 0x4(%r15), %ecx
movl %ecx, -0x3c(%rbp)
movl %eax, 0x4(%r15)
movl -0x40(%rbp), %eax
movl (%r15), %ecx
movl %ecx, -0x40(%rbp)
movl %eax, (%r15)
movq 0x8(%r15), %rax
movq %rax, -0x38(%rbp)
movq %rdi, 0x8(%r15)
movq %rax, %rdi
xorl %r14d, %r14d
testq %r12, %r12
setne %r14b
xorl %esi, %esi
callq *0xc391(%rip)           # 0x100b0
movl %r14d, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rdi, %rdi
je 0x3d41
movq %r14, %rsi
callq 0x24a2
movl $0x1, %r14d
testq %r13, %r13
je 0x3d1f
movl $0x0, 0x4(%r13)
jmp 0x3d1f
callq 0x1180
leaq 0x66d3(%rip), %rdi      # 0xa435
leaq 0x62fb(%rip), %rsi      # 0xa064
leaq 0x7456(%rip), %rcx      # 0xb1c6
movl $0x448, %edx            # imm = 0x448
callq 0x1090