// File: /workspace/github_cpp_makefile_star2_O3/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 0x4dc0
movq %rcx, %r15
movq %rsi, -0xc8(%rbp)
testl %ebx, %ebx
je 0x4e2e
movq %r13, -0xd8(%rbp)
movq %r12, -0x98(%rbp)
movl $0x1, %r14d
leaq -0x90(%rbp), %r12
movq %r14, (%r12)
movl $0x8, %edi
movq %r8, %r13
callq *0xb417(%rip)           # 0x100a0
movq %rax, 0x8(%r12)
leaq -0x60(%rbp), %rbx
movq %r14, (%rbx)
movl $0x8, %edi
callq *0xb400(%rip)           # 0x100a0
movq %rax, 0x8(%rbx)
movq %r14, -0x40(%rbp)
movl $0x8, %edi
callq *0xb3ed(%rip)           # 0x100a0
movq %rax, -0x38(%rbp)
movq %r14, -0x70(%rbp)
movl $0x8, %edi
callq *0xb3da(%rip)           # 0x100a0
movq %rax, -0x68(%rbp)
movq %r14, -0x50(%rbp)
movl $0x8, %edi
callq *0xb3c7(%rip)           # 0x100a0
movq %rax, -0x48(%rbp)
movq %r14, -0xb0(%rbp)
movl $0x8, %edi
callq *0xb3b1(%rip)           # 0x100a0
movq %rax, -0xa8(%rbp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x24a2
movl 0x4(%r12), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl %ecx, 0x4(%r12)
movq %r12, %rdi
callq 0x4bbf
movq %rax, %r14
movq %rbx, %rdi
movq %r13, -0x78(%rbp)
movq %r13, %rsi
callq 0x24a2
movl 0x4(%rbx), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl %ecx, 0x4(%rbx)
movq %rbx, %rdi
callq 0x4bbf
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 0x4e80
movl %ecx, -0x8c(%rbp)
movl %eax, -0x5c(%rbp)
movl -0x90(%rbp), %eax
movl -0x60(%rbp), %ecx
movl %ecx, -0x90(%rbp)
movl %eax, -0x60(%rbp)
movq -0x88(%rbp), %rax
movq -0x58(%rbp), %rcx
movq %rcx, -0x88(%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 0x4eb5
xorl %r14d, %r14d
testl %ebx, %ebx
setne -0x78(%rbp)
movq %r13, %rdi
movq %rsi, %r15
movq %r8, %rsi
callq 0x24a2
movl 0x4(%r13), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl %ecx, 0x4(%r13)
testq %r15, %r15
je 0x4df3
movl $0x0, 0x4(%r15)
testq %r12, %r12
je 0x52f3
sarl $0x1f, %ebx
movb -0x78(%rbp), %al
movb %al, %r14b
orl %ebx, %r14d
movslq %r14d, %rax
testl %ebx, %ebx
js 0x52b5
testl %r14d, %r14d
je 0x52cb
movq 0x8(%r12), %rcx
movq %rax, (%rcx)
movl $0x1, %eax
jmp 0x52cd
movq %r13, %rdi
movq %r15, %rsi
callq 0x24a2
movl 0x4(%r13), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl %ecx, 0x4(%r13)
movq -0xc8(%rbp), %rdx
testq %rdx, %rdx
je 0x52e5
sarl $0x1f, %r14d
movl %r14d, %eax
orl $0x1, %eax
cltq
testl %r14d, %r14d
js 0x52d4
movq 0x8(%rdx), %rcx
movq %rax, (%rcx)
movl $0x1, 0x4(%rdx)
jmp 0x52e5
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 0x5305
leaq -0xb0(%rbp), %r15
leaq -0x90(%rbp), %rbx
leaq -0x60(%rbp), %rcx
movq %r15, %rdi
movq %rbx, %rsi
movq %rbx, %rdx
movl $0x2, %r8d
callq 0x3943
movq %r15, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x362c
leaq -0x70(%rbp), %rdi
movq -0xd0(%rbp), %rsi
callq 0x5305
addq %r14, %r13
cmpl $0x0, 0x4(%rbx)
jle 0x502f
movq %rbx, %rdi
callq 0x4bbf
movq %rax, %r14
leaq -0x50(%rbp), %rdi
movq %rdi, %rsi
movq %rax, %rdx
callq 0x362c
leaq -0x40(%rbp), %rdi
movq %rdi, %rsi
movq %r14, %rdx
callq 0x362c
addq %r14, %r13
leaq -0x60(%rbp), %rsi
movq %rbx, %rdi
callq 0x2cfb
testl %eax, %eax
je 0x502f
leaq -0x60(%rbp), %rbx
leaq -0x90(%rbp), %r15
testl %eax, %eax
js 0x4fbd
movq %r15, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x33cf
leaq -0xb0(%rbp), %rdi
leaq -0x50(%rbp), %r14
movq %r14, %rsi
movq %rdi, %rdx
callq 0x30c3
leaq -0x70(%rbp), %rdi
leaq -0x40(%rbp), %rbx
movq %rbx, %rsi
movq %rdi, %rdx
callq 0x30c3
movq %r15, %rdi
callq 0x4bbf
movq %rax, %r12
movq %r14, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x362c
movq %rbx, %rdi
movq %rbx, %rsi
leaq -0x60(%rbp), %rbx
jmp 0x5011
movq %rbx, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x33cf
leaq -0x50(%rbp), %rdi
movq %rdi, %rsi
leaq -0xb0(%rbp), %r14
movq %r14, %rdx
callq 0x30c3
leaq -0x40(%rbp), %rdi
movq %rdi, %rsi
leaq -0x70(%rbp), %rdx
callq 0x30c3
movq %rbx, %rdi
callq 0x4bbf
movq %rax, %r12
movq %r14, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x362c
leaq -0x70(%rbp), %rdi
movq %rdi, %rsi
movq %r12, %rdx
callq 0x362c
addq %r12, %r13
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2cfb
testl %eax, %eax
jne 0x4f5d
leaq -0x60(%rbp), %rbx
movq %rbx, %rdi
movq %rbx, %rsi
movq -0xe0(%rbp), %rdx
callq 0x362c
negl -0x3c(%rbp)
leaq -0x70(%rbp), %r14
movq %r14, %rdi
movq -0xc0(%rbp), %rsi
movq %rbx, %rdx
callq 0x42a1
movl 0x4(%r14), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl %ecx, 0x4(%r14)
leaq -0xb0(%rbp), %r14
movq %r14, %rdi
movq -0x78(%rbp), %rsi
movq %rbx, %rdx
callq 0x42a1
movl 0x4(%r14), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl %ecx, 0x4(%r14)
testq %r13, %r13
je 0x5112
leaq -0x40(%rbp), %rbx
leaq -0x50(%rbp), %r14
leaq -0x70(%rbp), %r15
leaq -0xb0(%rbp), %r12
cmpl $0x0, -0x3c(%rbp)
je 0x50bc
movq -0x38(%rbp), %rax
movq (%rax), %rax
andl $0x1, %eax
jne 0x50ce
cmpl $0x0, -0x4c(%rbp)
je 0x50ea
movq -0x48(%rbp), %rax
movq (%rax), %rax
andl $0x1, %eax
je 0x50ea
movq %rbx, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x33cf
movq %r14, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x30c3
decq %r13
movl $0x2, %edx
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x4694
movl $0x2, %edx
movq %r14, %rdi
movq %r14, %rsi
callq 0x4694
testq %r13, %r13
jne 0x50aa
leaq -0x40(%rbp), %rbx
leaq -0x70(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x30c3
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 0x5180
movl %edi, %edi
movq -0x98(%rbp), %rbx
movq -0xd8(%rbp), %r14
movq -0xb8(%rbp), %r15
testq %rdi, %rdi
jle 0x51c4
movq -0x8(%rdx,%rdi,8), %r8
leaq -0x1(%rdi), %r9
cmpq %r8, -0x8(%rax,%rdi,8)
movq %r9, %rdi
je 0x5164
ja 0x5197
jmp 0x51c4
movq -0x98(%rbp), %rbx
movq -0xd8(%rbp), %r14
movq -0xb8(%rbp), %r15
jb 0x51c4
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 -0xb0(%rbp), %rdx
movq %rdi, %rsi
callq 0x33cf
movq -0x78(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jns 0x51d1
negl -0x3c(%rbp)
movq -0xc0(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jns 0x51e1
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 0x5236
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 0x5265
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 -0x88(%rbp), %rdi
xorl %esi, %esi
callq *0xae3c(%rip)           # 0x100b0
movq -0x58(%rbp), %rdi
xorl %esi, %esi
callq *0xae30(%rip)           # 0x100b0
movq -0x38(%rbp), %rdi
xorl %esi, %esi
callq *0xae24(%rip)           # 0x100b0
movq -0x68(%rbp), %rdi
xorl %esi, %esi
callq *0xae18(%rip)           # 0x100b0
movq -0x48(%rbp), %rdi
xorl %esi, %esi
callq *0xae0c(%rip)           # 0x100b0
movq -0xa8(%rbp), %rdi
xorl %esi, %esi
callq *0xadfd(%rip)           # 0x100b0
jmp 0x52f3
movl $0xffffffff, 0x4(%r12)  # imm = 0xFFFFFFFF
negq %rax
movq 0x8(%r12), %rcx
movq %rax, (%rcx)
jmp 0x52f3
xorl %eax, %eax
movl %eax, 0x4(%r12)
jmp 0x52f3
movl $0xffffffff, 0x4(%rdx)  # imm = 0xFFFFFFFF
negq %rax
movq 0x8(%rdx), %rcx
movq %rax, (%rcx)
testq %r12, %r12
je 0x52f3
movl $0x0, 0x4(%r12)
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq