// File: /workspace/github_cpp_makefile_star2_O1/marxn[P]pupp/3rdparty/gmp/./mini-gmp/mini-gmp.c
// Function: mpz_gcdext
void
mpz_gcdext (mpz_t g, mpz_t s, mpz_t t, const mpz_t u, const mpz_t v)
{
  mpz_t tu, tv, s0, s1, t0, t1;
  mp_bitcnt_t uz, vz, gz;
  mp_bitcnt_t power;

  if (u->_mp_size == 0)
    {
      /* g = 0 u + sgn(v) v */
      signed long sign = mpz_sgn (v);
      mpz_abs (g, v);
      if (s)
	mpz_set_ui (s, 0);
      if (t)
	mpz_set_si (t, sign);
      return;
    }

  if (v->_mp_size == 0)
    {
      /* g = sgn(u) u + 0 v */
      signed long sign = mpz_sgn (u);
      mpz_abs (g, u);
      if (s)
	mpz_set_si (s, sign);
      if (t)
	mpz_set_ui (t, 0);
      return;
    }

  mpz_init (tu);
  mpz_init (tv);
  mpz_init (s0);
  mpz_init (s1);
  mpz_init (t0);
  mpz_init (t1);

  mpz_abs (tu, u);
  uz = mpz_make_odd (tu);
  mpz_abs (tv, v);
  vz = mpz_make_odd (tv);
  gz = GMP_MIN (uz, vz);

  uz -= gz;
  vz -= gz;

  /* Cofactors corresponding to odd gcd. gz handled later. */
  if (tu->_mp_size < tv->_mp_size)
    {
      mpz_swap (tu, tv);
      MPZ_SRCPTR_SWAP (u, v);
      MPZ_PTR_SWAP (s, t);
      MP_BITCNT_T_SWAP (uz, vz);
    }

  /* Maintain
   *
   * u = t0 tu + t1 tv
   * v = s0 tu + s1 tv
   *
   * where u and v denote the inputs with common factors of two
   * eliminated, and det (s0, t0; s1, t1) = 2^p. Then
   *
   * 2^p tu =  s1 u - t1 v
   * 2^p tv = -s0 u + t0 v
   */

  /* After initial division, tu = q tv + tu', we have
   *
   * u = 2^uz (tu' + q tv)
   * v = 2^vz tv
   *
   * or
   *
   * t0 = 2^uz, t1 = 2^uz q
   * s0 = 0,    s1 = 2^vz
   */

  mpz_setbit (t0, uz);
  mpz_tdiv_qr (t1, tu, tu, tv);
  mpz_mul_2exp (t1, t1, uz);

  mpz_setbit (s1, vz);
  power = uz + vz;

  if (tu->_mp_size > 0)
    {
      mp_bitcnt_t shift;
      shift = mpz_make_odd (tu);
      mpz_mul_2exp (t0, t0, shift);
      mpz_mul_2exp (s0, s0, shift);
      power += shift;

      for (;;)
	{
	  int c;
	  c = mpz_cmp (tu, tv);
	  if (c == 0)
	    break;

	  if (c < 0)
	    {
	      /* tv = tv' + tu
	       *
	       * u = t0 tu + t1 (tv' + tu) = (t0 + t1) tu + t1 tv'
	       * v = s0 tu + s1 (tv' + tu) = (s0 + s1) tu + s1 tv' */

	      mpz_sub (tv, tv, tu);
	      mpz_add (t0, t0, t1);
	      mpz_add (s0, s0, s1);

	      shift = mpz_make_odd (tv);
	      mpz_mul_2exp (t1, t1, shift);
	      mpz_mul_2exp (s1, s1, shift);
	    }
	  else
	    {
	      mpz_sub (tu, tu, tv);
	      mpz_add (t1, t0, t1);
	      mpz_add (s1, s0, s1);

	      shift = mpz_make_odd (tu);
	      mpz_mul_2exp (t0, t0, shift);
	      mpz_mul_2exp (s0, s0, shift);
	    }
	  power += shift;
	}
    }

  /* Now tv = odd part of gcd, and -s0 and t0 are corresponding
     cofactors. */

  mpz_mul_2exp (tv, tv, gz);
  mpz_neg (s0, s0);

  /* 2^p g = s0 u + t0 v. Eliminate one factor of two at a time. To
     adjust cofactors, we need u / g and v / g */

  mpz_divexact (s1, v, tv);
  mpz_abs (s1, s1);
  mpz_divexact (t1, u, tv);
  mpz_abs (t1, t1);

  while (power-- > 0)
    {
      /* s0 u + t0 v = (s0 - v/g) u - (t0 + u/g) v */
      if (mpz_odd_p (s0) || mpz_odd_p (t0))
	{
	  mpz_sub (s0, s0, s1);
	  mpz_add (t0, t0, t1);
	}
      mpz_divexact_ui (s0, s0, 2);
      mpz_divexact_ui (t0, t0, 2);
    }

  /* Arrange so that |s| < |u| / 2g */
  mpz_add (s1, s0, s1);
  if (mpz_cmpabs (s0, s1) > 0)
    {
      mpz_swap (s0, s1);
      mpz_sub (t0, t0, t1);
    }
  if (u->_mp_size < 0)
    mpz_neg (s0, s0);
  if (v->_mp_size < 0)
    mpz_neg (t0, t0);

  mpz_swap (g, tv);
  if (s)
    mpz_swap (s, s0);
  if (t)
    mpz_swap (t, t0);

  mpz_clear (tu);
  mpz_clear (tv);
  mpz_clear (s0);
  mpz_clear (s1);
  mpz_clear (t0);
  mpz_clear (t1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdx, %r12
movq %rdi, %r13
movl 0x4(%rcx), %r14d
movl 0x4(%r8), %ebx
testl %r14d, %r14d
je 0x4e3f
movq %rcx, %r15
movq %rsi, -0xc8(%rbp)
testl %ebx, %ebx
je 0x4ea9
movq %r13, -0xd8(%rbp)
movq %r12, -0x98(%rbp)
movl $0x1, %r14d
leaq -0xb0(%rbp), %r12
movq %r14, (%r12)
movl $0x8, %edi
movq %r8, %r13
callq *0xb398(%rip)           # 0x100a0
movq %rax, 0x8(%r12)
leaq -0x60(%rbp), %rbx
movq %r14, (%rbx)
movl $0x8, %edi
callq *0xb381(%rip)           # 0x100a0
movq %rax, 0x8(%rbx)
movq %r14, -0x40(%rbp)
movl $0x8, %edi
callq *0xb36e(%rip)           # 0x100a0
movq %rax, -0x38(%rbp)
movq %r14, -0x70(%rbp)
movl $0x8, %edi
callq *0xb35b(%rip)           # 0x100a0
movq %rax, -0x68(%rbp)
movq %r14, -0x50(%rbp)
movl $0x8, %edi
callq *0xb348(%rip)           # 0x100a0
movq %rax, -0x48(%rbp)
movq %r14, -0x90(%rbp)
movl $0x8, %edi
callq *0xb332(%rip)           # 0x100a0
movq %rax, -0x88(%rbp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x24be
movl 0x4(%r12), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl %ecx, 0x4(%r12)
movq %r12, %rdi
callq 0x4c3e
movq %rax, %r14
movq %rbx, %rdi
movq %r13, -0x78(%rbp)
movq %r13, %rsi
callq 0x24be
movl 0x4(%rbx), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl %ecx, 0x4(%rbx)
movq %rbx, %rdi
callq 0x4c3e
movq %rax, %r13
cmpq %rax, %r14
movq %rax, %rdx
cmovbq %r14, %rdx
subq %rdx, %r14
subq %rdx, %r13
movl 0x4(%r12), %eax
movl 0x4(%rbx), %ecx
cmpl %ecx, %eax
movq %rdx, -0xe0(%rbp)
jge 0x4ef4
movl %ecx, -0xac(%rbp)
movl %eax, -0x5c(%rbp)
movl -0xb0(%rbp), %eax
movl -0x60(%rbp), %ecx
movl %ecx, -0xb0(%rbp)
movl %eax, -0x60(%rbp)
movq -0xa8(%rbp), %rax
movq -0x58(%rbp), %rcx
movq %rcx, -0xa8(%rbp)
movq %rax, -0x58(%rbp)
movq %r14, -0xd0(%rbp)
movq %r13, %r12
movq %r15, -0xc0(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0xb8(%rbp)
jmp 0x4f29
xorl %r14d, %r14d
testl %ebx, %ebx
setne -0x78(%rbp)
movq %r13, %rdi
movq %rsi, %r15
movq %r8, %rsi
callq 0x24be
movl 0x4(%r13), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl %ecx, 0x4(%r13)
testq %r15, %r15
je 0x4e72
movl $0x0, 0x4(%r15)
testq %r12, %r12
je 0x535b
sarl $0x1f, %ebx
movb -0x78(%rbp), %al
movb %al, %r14b
orl %ebx, %r14d
movslq %r14d, %rax
testl %ebx, %ebx
js 0x5326
testl %r14d, %r14d
je 0x5352
movl $0x1, 0x4(%r12)
jmp 0x5332
movq %r13, %rdi
movq %r15, %rsi
callq 0x24be
movl 0x4(%r13), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl %ecx, 0x4(%r13)
movq -0xc8(%rbp), %rcx
testq %rcx, %rcx
je 0x534d
sarl $0x1f, %r14d
movl %r14d, %eax
orl $0x1, %eax
cltq
testl %r14d, %r14d
js 0x533c
movl $0x1, 0x4(%rcx)
jmp 0x5346
movq %r13, -0xd0(%rbp)
movq %r14, %r12
movq -0x78(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq %r15, -0x78(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0x50(%rbp), %rdi
movq %r12, %rsi
callq 0x536d
leaq -0x90(%rbp), %r15
leaq -0xb0(%rbp), %rbx
leaq -0x60(%rbp), %rcx
movq %r15, %rdi
movq %rbx, %rsi
movq %rbx, %rdx
movl $0x2, %r8d
callq 0x3989
movq %r15, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x366f
leaq -0x70(%rbp), %rdi
movq -0xd0(%rbp), %rsi
callq 0x536d
addq %r14, %r13
cmpl $0x0, 0x4(%rbx)
jle 0x5097
movq %rbx, %rdi
callq 0x4c3e
movq %rax, %r14
leaq -0x50(%rbp), %rdi
movq %rdi, %rsi
movq %rax, %rdx
callq 0x366f
leaq -0x40(%rbp), %rdi
movq %rdi, %rsi
movq %r14, %rdx
callq 0x366f
addq %r14, %r13
leaq -0x60(%rbp), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2d3a
movl %eax, %r15d
testl %eax, %eax
je 0x508e
js 0x502e
movq %rbx, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x3412
leaq -0x90(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movq %rdi, %rdx
callq 0x30fc
leaq -0x70(%rbp), %rdi
movq %rbx, %r12
leaq -0x40(%rbp), %rbx
movq %rbx, %rsi
movq %rdi, %rdx
callq 0x30fc
movq %r12, %rdi
callq 0x4c3e
movq %rax, %r14
leaq -0x50(%rbp), %rdi
movq %rdi, %rsi
movq %rax, %rdx
callq 0x366f
movq %rbx, %rdi
movq %rbx, %rsi
movq %r12, %rbx
leaq -0x60(%rbp), %r12
jmp 0x5083
movq %r12, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x3412
leaq -0x50(%rbp), %rdi
movq %rdi, %rsi
leaq -0x90(%rbp), %rdx
callq 0x30fc
leaq -0x40(%rbp), %rdi
movq %rdi, %rsi
leaq -0x70(%rbp), %rdx
callq 0x30fc
movq %r12, %rdi
callq 0x4c3e
movq %rax, %r14
leaq -0x90(%rbp), %rdi
movq %rdi, %rsi
movq %rax, %rdx
callq 0x366f
leaq -0x70(%rbp), %rdi
movq %rdi, %rsi
movq %r14, %rdx
callq 0x366f
addq %r14, %r13
testl %r15d, %r15d
jne 0x4fb6
leaq -0x60(%rbp), %rbx
movq %rbx, %rdi
movq %rbx, %rsi
movq -0xe0(%rbp), %rdx
callq 0x366f
negl -0x3c(%rbp)
leaq -0x70(%rbp), %r14
movq %r14, %rdi
movq -0xc0(%rbp), %rsi
movq %rbx, %rdx
callq 0x4313
movl 0x4(%r14), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl %ecx, 0x4(%r14)
leaq -0x90(%rbp), %r14
movq %r14, %rdi
movq -0x78(%rbp), %rsi
movq %rbx, %rdx
callq 0x4313
movl 0x4(%r14), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl %ecx, 0x4(%r14)
testq %r13, %r13
je 0x517a
leaq -0x40(%rbp), %rbx
leaq -0x50(%rbp), %r14
leaq -0x70(%rbp), %r15
leaq -0x90(%rbp), %r12
cmpl $0x0, -0x3c(%rbp)
je 0x5124
movq -0x38(%rbp), %rax
movq (%rax), %rax
andl $0x1, %eax
jne 0x5136
cmpl $0x0, -0x4c(%rbp)
je 0x5152
movq -0x48(%rbp), %rax
movq (%rax), %rax
andl $0x1, %eax
je 0x5152
movq %rbx, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x3412
movq %r14, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x30fc
decq %r13
movl $0x2, %edx
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x4721
movl $0x2, %edx
movq %r14, %rdi
movq %r14, %rsi
callq 0x4721
testq %r13, %r13
jne 0x5112
leaq -0x40(%rbp), %rbx
leaq -0x70(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x30fc
movl 0x4(%rbx), %ecx
movl %ecx, %edi
negl %edi
cmovsl %ecx, %edi
movq 0x8(%rbx), %rax
movq 0x8(%r14), %rdx
movl 0x4(%r14), %esi
movl %esi, %r8d
negl %r8d
cmovsl %esi, %r8d
cmpl %r8d, %edi
jne 0x51ea
movl %edi, %edi
movq -0x98(%rbp), %rbx
movq -0xd8(%rbp), %r14
movq -0xb8(%rbp), %r15
testq %rdi, %rdi
jle 0x5235
movq -0x8(%rdx,%rdi,8), %r8
leaq -0x1(%rdi), %r9
cmpq %r8, -0x8(%rax,%rdi,8)
movq %r9, %rdi
je 0x51cc
seta %dil
jmp 0x5203
setae %dil
movq -0x98(%rbp), %rbx
movq -0xd8(%rbp), %r14
movq -0xb8(%rbp), %r15
testb %dil, %dil
je 0x5235
movl %esi, -0x3c(%rbp)
movl %ecx, -0x6c(%rbp)
movl -0x40(%rbp), %ecx
movl -0x70(%rbp), %esi
movl %esi, -0x40(%rbp)
movl %ecx, -0x70(%rbp)
movq %rdx, -0x38(%rbp)
movq %rax, -0x68(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x90(%rbp), %rdx
movq %rdi, %rsi
callq 0x3412
movq -0x78(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jns 0x5242
negl -0x3c(%rbp)
movq -0xc0(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jns 0x5252
negl -0x4c(%rbp)
movl 0x4(%r14), %eax
movl -0x5c(%rbp), %ecx
movl %ecx, 0x4(%r14)
movl %eax, -0x5c(%rbp)
movl (%r14), %eax
movl -0x60(%rbp), %ecx
movl %ecx, (%r14)
movl %eax, -0x60(%rbp)
movq 0x8(%r14), %rax
movq -0x58(%rbp), %rcx
movq %rcx, 0x8(%r14)
movq %rax, -0x58(%rbp)
testq %rbx, %rbx
je 0x52a7
movl 0x4(%rbx), %eax
movl -0x3c(%rbp), %ecx
movl %ecx, 0x4(%rbx)
movl %eax, -0x3c(%rbp)
movl (%rbx), %eax
movl -0x40(%rbp), %ecx
movl %ecx, (%rbx)
movl %eax, -0x40(%rbp)
movq 0x8(%rbx), %rax
movq -0x38(%rbp), %rcx
movq %rcx, 0x8(%rbx)
movq %rax, -0x38(%rbp)
testq %r15, %r15
je 0x52d6
movl 0x4(%r15), %eax
movl -0x4c(%rbp), %ecx
movl %ecx, 0x4(%r15)
movl %eax, -0x4c(%rbp)
movl (%r15), %eax
movl -0x50(%rbp), %ecx
movl %ecx, (%r15)
movl %eax, -0x50(%rbp)
movq 0x8(%r15), %rax
movq -0x48(%rbp), %rcx
movq %rcx, 0x8(%r15)
movq %rax, -0x48(%rbp)
movq -0xa8(%rbp), %rdi
xorl %esi, %esi
callq *0xadcb(%rip)           # 0x100b0
movq -0x58(%rbp), %rdi
xorl %esi, %esi
callq *0xadbf(%rip)           # 0x100b0
movq -0x38(%rbp), %rdi
xorl %esi, %esi
callq *0xadb3(%rip)           # 0x100b0
movq -0x68(%rbp), %rdi
xorl %esi, %esi
callq *0xada7(%rip)           # 0x100b0
movq -0x48(%rbp), %rdi
xorl %esi, %esi
callq *0xad9b(%rip)           # 0x100b0
movq -0x88(%rbp), %rdi
xorl %esi, %esi
callq *0xad8c(%rip)           # 0x100b0
jmp 0x535b
movl $0xffffffff, 0x4(%r12)  # imm = 0xFFFFFFFF
negq %rax
movq 0x8(%r12), %rcx
movq %rax, (%rcx)
jmp 0x535b
movl $0xffffffff, 0x4(%rcx)  # imm = 0xFFFFFFFF
negq %rax
movq 0x8(%rcx), %rcx
movq %rax, (%rcx)
testq %r12, %r12
je 0x535b
movl $0x0, 0x4(%r12)
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq