// File: /workspace/github_cpp_makefile_star2_O2/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
movslq 0x4(%rcx), %r14
testq %r14, %r14
je 0x366d
movslq 0x4(%rdx), %rbx
testl %ebx, %ebx
je 0x3369
movq %rsi, -0x48(%rbp)
movq %rdi, -0x30(%rbp)
movq %rbx, %r15
negq %r15
cmovsq %rbx, %r15
movq %r14, %r13
negq %r13
cmovsq %r14, %r13
xorq %rbx, %r14
movq %r15, %r12
subq %r13, %r12
jae 0x3387
cmpl $0x1, %r8d
sete %al
testq %r14, %r14
setns %sil
andb %al, %sil
cmpb $0x1, %sil
jne 0x33d8
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
movq -0x30(%rbp), %rbx
je 0x3345
movq %rdx, %rsi
movq %rcx, %rdx
callq 0x2e4a
pushq $0x1
popq %r15
testq %rbx, %rbx
je 0x363c
movq 0x8(%rbx), %rax
movq $0x1, (%rax)
movl $0x1, 0x4(%rbx)
jmp 0x363c
testq %rdi, %rdi
je 0x3372
andl $0x0, 0x4(%rdi)
xorl %r15d, %r15d
testq %rsi, %rsi
je 0x363c
andl $0x0, 0x4(%rsi)
jmp 0x363c
movl %r8d, -0x80(%rbp)
movq %rcx, -0x68(%rbp)
leaq -0x40(%rbp), %rdi
movq %rdx, %rsi
callq 0x2340
leaq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x90(%rbp)
leaq 0x1(%r12), %rsi
cmpq $0x0, -0x30(%rbp)
movq %rsi, -0x98(%rbp)
je 0x342b
shlq $0x6, %rsi
leaq -0x60(%rbp), %rdi
callq 0x219c
leaq -0x60(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
jmp 0x3433
testl %r8d, %r8d
sete %al
testq %r14, %r14
sets %sil
andb %al, %sil
cmpb $0x1, %sil
movq -0x30(%rbp), %rbx
movq -0x48(%rbp), %rdi
jne 0x3651
testq %rdi, %rdi
je 0x340a
movq %rdx, %rsi
movq %rcx, %rdx
callq 0x2c3d
pushq $0x1
popq %r15
testq %rbx, %rbx
je 0x363c
orl $-0x1, 0x4(%rbx)
movq 0x8(%rbx), %rax
movq $0x1, (%rax)
jmp 0x363c
movq $0x0, -0x78(%rbp)
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0xb8(%rbp), %rdi
movq %rsi, -0x88(%rbp)
movq %r13, %rdx
callq 0x5002
cmpq $0x3, %r13
setae %al
leaq -0xb8(%rbp), %rcx
movl (%rcx), %edx
testl %edx, %edx
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x34bf
leaq (,%r13,8), %rdi
movl %edx, -0x7c(%rbp)
callq *0xbc1a(%rip)           # 0xf098
movq %rax, -0x70(%rbp)
movq %rax, %rdi
movq -0x88(%rbp), %rsi
movq %r13, %rdx
movl -0x7c(%rbp), %ecx
callq 0x187e
movq -0x70(%rbp), %rcx
testq %rax, %rax
je 0x34ce
leaq 0x5f8e(%rip), %rdi      # 0x9435
leaq 0x5bb6(%rip), %rsi      # 0x9064
leaq 0x6d11(%rip), %rcx      # 0xa1c6
movl $0x448, %edx            # imm = 0x448
callq 0x1090
movq $0x0, -0x70(%rbp)
movq -0x88(%rbp), %rcx
leaq -0xb8(%rbp), %r9
movq -0x78(%rbp), %rdi
movq -0x90(%rbp), %rsi
movq %r15, %rdx
movq %r13, %r8
callq 0x5144
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x34fc
xorl %esi, %esi
callq *0xbbac(%rip)           # 0xf0a8
movq -0x78(%rbp), %rax
testq %rax, %rax
je 0x3521
cmpq $0x1, (%rax,%r12,8)
movq -0x98(%rbp), %rcx
sbbl $0x0, %ecx
movl %ecx, %eax
negl %eax
testq %r14, %r14
cmovnsl %ecx, %eax
movl %eax, -0x5c(%rbp)
movq -0x90(%rbp), %rdi
movq %r13, %rsi
callq 0x1369
movq %rax, %r13
movq %rax, %rcx
negq %rcx
setb %al
testl %ebx, %ebx
cmovnsl %r13d, %ecx
movl %ecx, -0x3c(%rbp)
movl -0x80(%rbp), %ecx
testl %ecx, %ecx
jne 0x3588
testq %r14, %r14
jns 0x3588
testb %al, %al
je 0x3588
movq -0x30(%rbp), %rbx
testq %rbx, %rbx
movq -0x48(%rbp), %r14
je 0x3571
leaq -0x60(%rbp), %rdi
pushq $0x1
popq %rdx
movq %rdi, %rsi
callq 0x2bd7
testq %r14, %r14
je 0x35d4
leaq -0x40(%rbp), %rdi
movq %rdi, %rsi
movq -0x68(%rbp), %rdx
callq 0x2c3d
jmp 0x35d4
testq %r13, %r13
setne %al
cmpl $0x1, %ecx
sete %cl
testq %r14, %r14
setns %dl
andb %cl, %dl
andb %al, %dl
cmpb $0x1, %dl
movq -0x30(%rbp), %rbx
movq -0x48(%rbp), %r14
jne 0x35d4
testq %rbx, %rbx
je 0x35bf
leaq -0x60(%rbp), %rdi
pushq $0x1
popq %rdx
movq %rdi, %rsi
callq 0x2a8e
testq %r14, %r14
je 0x35d4
leaq -0x40(%rbp), %rdi
movq %rdi, %rsi
movq -0x68(%rbp), %rdx
callq 0x2e4a
testq %rbx, %rbx
je 0x35f8
movl -0x5c(%rbp), %eax
movl %eax, 0x4(%rbx)
movl -0x60(%rbp), %eax
movl %eax, (%rbx)
movq -0x58(%rbp), %rax
movq 0x8(%rbx), %rdi
movq %rax, 0x8(%rbx)
xorl %esi, %esi
callq *0xbab0(%rip)           # 0xf0a8
movq -0x38(%rbp), %rdi
testq %r14, %r14
je 0x362a
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 0x8(%r14), %rax
movq %rax, -0x38(%rbp)
movq %rdi, 0x8(%r14)
movq %rax, %rdi
xorl %r15d, %r15d
testq %r13, %r13
setne %r15b
xorl %esi, %esi
callq *0xba6c(%rip)           # 0xf0a8
movl %r15d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rdi, %rdi
je 0x365e
movq %rdx, %rsi
callq 0x2236
pushq $0x1
popq %r15
testq %rbx, %rbx
je 0x363c
andl $0x0, 0x4(%rbx)
jmp 0x363c
leaq 0x6b2f(%rip), %rdi      # 0xa1a3
callq 0x4fde