// File: /workspace/github_cpp_makefile_star2_O2/marxn[P]pupp/3rdparty/gmp/./mini-gmp/mini-gmp.c
// Function: mpz_rootrem
void
mpz_rootrem (mpz_t x, mpz_t r, const mpz_t y, unsigned long z)
{
  int sgn;
  mpz_t t, u;

  sgn = y->_mp_size < 0;
  if ((~z & sgn) != 0)
    gmp_die ("mpz_rootrem: Negative argument, with even root.");
  if (z == 0)
    gmp_die ("mpz_rootrem: Zeroth root.");

  if (mpz_cmpabs_ui (y, 1) <= 0) {
    if (x)
      mpz_set (x, y);
    if (r)
      r->_mp_size = 0;
    return;
  }

  mpz_init (u);
  {
    mp_bitcnt_t tb;
    tb = mpz_sizeinbase (y, 2) / z + 1;
    mpz_init2 (t, tb + 1);
    mpz_setbit (t, tb);
  }

  if (z == 2) /* simplify sqrt loop: z-1 == 1 */
    do {
      mpz_swap (u, t);			/* u = x */
      mpz_tdiv_q (t, y, u);		/* t = y/x */
      mpz_add (t, t, u);		/* t = y/x + x */
      mpz_tdiv_q_2exp (t, t, 1);	/* x'= (y/x + x)/2 */
    } while (mpz_cmpabs (t, u) < 0);	/* |x'| < |x| */
  else /* z != 2 */ {
    mpz_t v;

    mpz_init (v);
    if (sgn)
      mpz_neg (t, t);

    do {
      mpz_swap (u, t);			/* u = x */
      mpz_pow_ui (t, u, z - 1);		/* t = x^(z-1) */
      mpz_tdiv_q (t, y, t);		/* t = y/x^(z-1) */
      mpz_mul_ui (v, u, z - 1);		/* v = x*(z-1) */
      mpz_add (t, t, v);		/* t = y/x^(z-1) + x*(z-1) */
      mpz_tdiv_q_ui (t, t, z);		/* x'=(y/x^(z-1) + x*(z-1))/z */
    } while (mpz_cmpabs (t, u) < 0);	/* |x'| < |x| */

    mpz_clear (v);
  }

  if (r) {
    mpz_pow_ui (t, u, z);
    mpz_sub (r, y, t);
  }
  if (x)
    mpz_swap (x, u);
  mpz_clear (u);
  mpz_clear (t);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, %r13
movl 0x4(%rdx), %r15d
movl %r15d, %eax
shrl $0x1f, %eax
notl %ecx
testl %ecx, %eax
jne 0x582c
testq %r13, %r13
je 0x5838
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
pushq $0x1
popq %rsi
movq %rdx, %rdi
callq 0x29a4
testl %eax, %eax
jle 0x56ac
movl %r15d, -0x58(%rbp)
movq %r14, -0x88(%rbp)
movq %rbx, -0x90(%rbp)
pushq $0x8
popq %rdi
callq *0x9aaa(%rip)           # 0xf098
movq %r13, %r15
movq %rax, %r13
pushq $0x2
popq %rsi
movq %r12, -0x68(%rbp)
movq %r12, %rdi
callq 0x5844
xorl %ebx, %ebx
xorl %edx, %edx
divq %r15
leaq 0x1(%rax), %r12
leaq 0x2(%rax), %rsi
leaq -0x40(%rbp), %r14
movq %r14, %rdi
callq 0x219c
movq %r14, %rdi
movq %r12, %rsi
callq 0x496f
movq %r15, -0x60(%rbp)
cmpq $0x2, %r15
jne 0x56cf
pushq $0x1
popq %rcx
movl -0x40(%rbp), %r12d
movl -0x3c(%rbp), %r15d
movl %r15d, -0x4c(%rbp)
movl %ebx, -0x3c(%rbp)
movl %r12d, -0x50(%rbp)
movl %ecx, -0x40(%rbp)
movq -0x38(%rbp), %r14
movq %r14, -0x48(%rbp)
movq %r13, -0x38(%rbp)
leaq -0x40(%rbp), %rbx
movq %rbx, %rdi
movq -0x68(%rbp), %rsi
leaq -0x50(%rbp), %r13
movq %r13, %rdx
callq 0x36c3
movq %rbx, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x2c3d
movq %rbx, %rdi
movq %rbx, %rsi
pushq $0x1
popq %rdx
callq 0x38a6
movq %rbx, %rdi
movq %r13, %rsi
callq 0x29d7
movq %r14, %r13
movl %r12d, %ecx
movl %r15d, %ebx
testl %eax, %eax
js 0x563a
jmp 0x57aa
testq %rbx, %rbx
je 0x56bc
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2236
testq %r14, %r14
je 0x581d
andl $0x0, 0x4(%r14)
jmp 0x581d
movq $0x1, -0x80(%rbp)
pushq $0x8
popq %rdi
callq *0x99b8(%rip)           # 0xf098
movq %rax, -0x78(%rbp)
cmpl $0x0, -0x58(%rbp)
jns 0x56f6
leaq -0x40(%rbp), %rdi
movq %rdi, %rsi
callq 0x2a4c
movq -0x60(%rbp), %rax
decq %rax
movq %rax, -0x58(%rbp)
xorl %r15d, %r15d
pushq $0x1
popq %r12
leaq -0x40(%rbp), %rbx
movq -0x58(%rbp), %r14
movl %r15d, %eax
movl %r12d, %ecx
movq %r13, %rdx
movl -0x40(%rbp), %r12d
movl -0x3c(%rbp), %r15d
movl %r15d, -0x4c(%rbp)
movl %eax, -0x3c(%rbp)
movl %r12d, -0x50(%rbp)
movl %ecx, -0x40(%rbp)
movq -0x38(%rbp), %r13
movq %r13, -0x48(%rbp)
movq %rdx, -0x38(%rbp)
movq %rbx, %rdi
leaq -0x50(%rbp), %rsi
movq %r14, %rdx
callq 0x4bbd
movq %rbx, %rdi
movq -0x68(%rbp), %rsi
movq %rbx, %rdx
callq 0x36c3
leaq -0x80(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movq %r14, %rdx
callq 0x2ec3
movq %rbx, %rdi
movq %rbx, %rsi
leaq -0x80(%rbp), %rdx
callq 0x2c3d
movq %rbx, %rdi
movq %rbx, %rsi
movq -0x60(%rbp), %rdx
callq 0x3dfc
movq %rbx, %rdi
leaq -0x50(%rbp), %rsi
callq 0x29d7
testl %eax, %eax
js 0x5710
movq -0x78(%rbp), %rdi
xorl %esi, %esi
callq *0x9901(%rip)           # 0xf0a8
movq %r13, %r14
movq -0x88(%rbp), %r13
testq %r13, %r13
je 0x57d9
leaq -0x40(%rbp), %rbx
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
movq -0x60(%rbp), %rdx
callq 0x4bbd
movq %r13, %rdi
movq -0x68(%rbp), %rsi
movq %rbx, %rdx
callq 0x2e4a
movq -0x90(%rbp), %rcx
testq %rcx, %rcx
je 0x5806
movl 0x4(%rcx), %eax
movl %r15d, 0x4(%rcx)
movl %eax, -0x4c(%rbp)
movl (%rcx), %eax
movl %r12d, (%rcx)
movl %eax, -0x50(%rbp)
movq 0x8(%rcx), %rax
movq %r14, 0x8(%rcx)
movq %rax, -0x48(%rbp)
movq %rax, %r14
movq %r14, %rdi
xorl %esi, %esi
callq *0x9897(%rip)           # 0xf0a8
movq -0x38(%rbp), %rdi
xorl %esi, %esi
callq *0x988b(%rip)           # 0xf0a8
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3d50(%rip), %rdi      # 0x9583
callq 0x4fde
leaq 0x3d74(%rip), %rdi      # 0x95b3
callq 0x4fde