// File: /workspace/github_cpp_makefile_star2_O1/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 $0x98, %rsp
movq %rdi, %r13
movslq 0x4(%rcx), %rdi
testq %rdi, %rdi
je 0x3da5
movq %rdx, %r14
movslq 0x4(%rdx), %rax
testl %eax, %eax
je 0x3a1e
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 0x3a43
cmpl $0x1, %r8d
sete %al
testq %rdi, %rdi
setns %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x3ae8
testq %rsi, %rsi
je 0x3a02
movq %rsi, %rdi
movq %r14, %rsi
movq %rcx, %rdx
callq 0x3412
movl $0x1, %r14d
testq %r13, %r13
je 0x3d6b
movl $0x1, 0x4(%r13)
jmp 0x3b29
testq %r13, %r13
je 0x3a2b
movl $0x0, 0x4(%r13)
xorl %r14d, %r14d
testq %rsi, %rsi
je 0x3d6b
movl $0x0, 0x4(%rsi)
jmp 0x3d6b
movq %rax, -0x90(%rbp)
movq %rdi, -0x98(%rbp)
movl %r8d, -0x6c(%rbp)
movq %rcx, -0x60(%rbp)
movq %rsi, -0xa0(%rbp)
movq %r13, -0x78(%rbp)
leaq -0x50(%rbp), %r13
movq $0x1, (%r13)
movl $0x8, %edi
callq *0xc625(%rip)           # 0x100a0
movq %rax, 0x8(%r13)
movq %r13, %rdi
movq %r14, %rsi
callq 0x24be
movq 0x8(%r13), %r13
movq %rbx, -0x88(%rbp)
leaq 0x1(%rbx), %rdx
cmpq $0x0, -0x78(%rbp)
movq %rdx, -0x80(%rbp)
je 0x3b39
testq %rdx, %rdx
movabsq $0x3ffffffffffffff, %rax # imm = 0x3FFFFFFFFFFFFFF
movq %rax, %rcx
cmoveq %rdx, %rcx
addq %rdx, %rcx
andq %rax, %rcx
leaq 0x1(%rcx), %rax
movl %eax, -0x40(%rbp)
movl $0x0, -0x3c(%rbp)
leaq 0x8(,%rcx,8), %rdi
callq *0xc5c2(%rip)           # 0x100a0
movq %rax, -0x68(%rbp)
movq %rax, -0x38(%rbp)
jmp 0x3b41
testl %r8d, %r8d
sete %al
testq %rdi, %rdi
sets %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x3d80
testq %rsi, %rsi
je 0x3b12
movq %rsi, %rdi
movq %r14, %rsi
movq %rcx, %rdx
callq 0x30fc
movl $0x1, %r14d
testq %r13, %r13
je 0x3d6b
movl $0xffffffff, 0x4(%r13)  # imm = 0xFFFFFFFF
movq 0x8(%r13), %rax
movq $0x1, (%rax)
jmp 0x3d6b
movq $0x0, -0x68(%rbp)
cmpq %r12, %r15
jb 0x3daa
movq -0x60(%rbp), %rax
movq 0x8(%rax), %r14
leaq -0xc0(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x5a8b
cmpq $0x3, %r12
setae %al
movl (%rbx), %edx
testl %edx, %edx
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x3bcc
leaq (,%r12,8), %rdi
movl %edx, -0x58(%rbp)
callq *0xc513(%rip)           # 0x100a0
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
movq %r12, %rdx
movl -0x58(%rbp), %ecx
callq 0x1a6f
movq %rbx, -0x58(%rbp)
movq %rbx, %r14
testq %rax, %rax
je 0x3bd4
leaq 0x6881(%rip), %rdi      # 0xa435
leaq 0x64a9(%rip), %rsi      # 0xa064
leaq 0x7604(%rip), %rcx      # 0xb1c6
movl $0x448, %edx            # imm = 0x448
callq 0x1090
movq $0x0, -0x58(%rbp)
leaq -0xc0(%rbp), %r9
movq -0x68(%rbp), %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %r14, %rcx
movq %r12, %r8
callq 0x5bf5
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x3c01
xorl %esi, %esi
callq *0xc4af(%rip)           # 0x100b0
movq -0x68(%rbp), %rbx
testq %rbx, %rbx
movq -0x98(%rbp), %rdi
je 0x3c31
movq -0x88(%rbp), %rax
cmpq $0x1, (%rbx,%rax,8)
movq -0x80(%rbp), %rcx
sbbl $0x0, %ecx
movl %ecx, %eax
negl %eax
testq %rdi, %rdi
cmovnsl %ecx, %eax
movl %eax, -0x3c(%rbp)
movl -0x6c(%rbp), %esi
movq -0xa0(%rbp), %rbx
cmpq $0x0, -0x8(%r13,%r12,8)
jne 0x3c54
leaq -0x1(%r12), %rax
cmpq $0x1, %r12
movq %rax, %r12
jg 0x3c3b
xorl %r12d, %r12d
movq %r12, %rax
negq %rax
setb %cl
cmpl $0x0, -0x90(%rbp)
cmovnsl %r12d, %eax
movl %eax, -0x4c(%rbp)
testl %esi, %esi
sete %al
testq %rdi, %rdi
sets %dl
andb %al, %dl
andb %cl, %dl
cmpb $0x1, %dl
movq -0x78(%rbp), %r14
jne 0x3cb0
testq %r14, %r14
je 0x3c99
leaq -0x40(%rbp), %rdi
movl $0x1, %edx
movq %rdi, %rsi
callq 0x3096
testq %rbx, %rbx
je 0x3cf3
leaq -0x50(%rbp), %rdi
movq %rdi, %rsi
movq -0x60(%rbp), %rdx
callq 0x30fc
jmp 0x3cf3
testq %r12, %r12
sete %al
cmpl $0x1, %esi
setne %cl
testq %rdi, %rdi
sets %dl
orb %cl, %dl
orb %al, %dl
jne 0x3cf3
testq %r14, %r14
je 0x3cde
leaq -0x40(%rbp), %rdi
movl $0x1, %edx
movq %rdi, %rsi
callq 0x2e9e
testq %rbx, %rbx
je 0x3cf3
leaq -0x50(%rbp), %rdi
movq %rdi, %rsi
movq -0x60(%rbp), %rdx
callq 0x3412
testq %r14, %r14
je 0x3d2a
movl -0x3c(%rbp), %eax
movl 0x4(%r14), %ecx
movl %ecx, -0x3c(%rbp)
movl %eax, 0x4(%r14)
movl -0x40(%rbp), %eax
movl (%r14), %ecx
movl %ecx, -0x40(%rbp)
movl %eax, (%r14)
movq -0x38(%rbp), %rax
movq 0x8(%r14), %rdi
movq %rdi, -0x38(%rbp)
movq %rax, 0x8(%r14)
xorl %esi, %esi
callq *0xc386(%rip)           # 0x100b0
testq %rbx, %rbx
je 0x3d55
movl -0x4c(%rbp), %eax
movl 0x4(%rbx), %ecx
movl %ecx, -0x4c(%rbp)
movl %eax, 0x4(%rbx)
movl -0x50(%rbp), %eax
movl (%rbx), %ecx
movl %ecx, -0x50(%rbp)
movl %eax, (%rbx)
movq -0x48(%rbp), %rax
movq 0x8(%rbx), %rcx
movq %rcx, -0x48(%rbp)
movq %rax, 0x8(%rbx)
xorl %r14d, %r14d
testq %r12, %r12
setne %r14b
movq -0x48(%rbp), %rdi
xorl %esi, %esi
callq *0xc345(%rip)           # 0x100b0
movl %r14d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rsi, %rsi
je 0x3d90
movq %rsi, %rdi
movq %r14, %rsi
callq 0x24be
movl $0x1, %r14d
testq %r13, %r13
je 0x3d6b
movl $0x0, 0x4(%r13)
jmp 0x3d6b
callq 0x1180
leaq 0x7456(%rip), %rdi      # 0xb207
leaq 0x62ac(%rip), %rsi      # 0xa064
leaq 0x7407(%rip), %rcx      # 0xb1c6
movl $0x442, %edx            # imm = 0x442
callq 0x1090