// File: /workspace/github_cpp_makefile_star2_O3/marxn[P]pupp/3rdparty/gmp/./mini-gmp/mini-gmp.c
// Function: mpz_export
void *
mpz_export (void *r, size_t *countp, int order, size_t size, int endian,
	    size_t nails, const mpz_t u)
{
  size_t count;
  mp_size_t un;

  if (nails != 0)
    gmp_die ("mpz_import: Nails not supported.");

  assert (order == 1 || order == -1);
  assert (endian >= -1 && endian <= 1);
  assert (size > 0 || u->_mp_size == 0);

  un = u->_mp_size;
  count = 0;
  if (un != 0)
    {
      size_t k;
      unsigned char *p;
      ptrdiff_t word_step;
      /* The current (partial) limb. */
      mp_limb_t limb;
      /* The number of bytes left to to in this limb. */
      size_t bytes;
      /* The index where the limb was read. */
      mp_size_t i;

      un = GMP_ABS (un);

      /* Count bytes in top limb. */
      limb = u->_mp_d[un-1];
      assert (limb != 0);

      k = 0;
      do {
	k++; limb >>= CHAR_BIT;
      } while (limb != 0);

      count = (k + (un-1) * sizeof (mp_limb_t) + size - 1) / size;

      if (!r)
	r = gmp_xalloc (count * size);

      if (endian == 0)
	endian = gmp_detect_endian ();

      p = (unsigned char *) r;

      word_step = (order != endian) ? 2 * size : 0;

      /* Process bytes from the least significant end, so point p at the
	 least significant word. */
      if (order == 1)
	{
	  p += size * (count - 1);
	  word_step = - word_step;
	}

      /* And at least significant byte of that word. */
      if (endian == 1)
	p += (size - 1);

      for (bytes = 0, i = 0, k = 0; k < count; k++, p += word_step)
	{
	  size_t j;
	  for (j = 0; j < size; j++, p -= (ptrdiff_t) endian)
	    {
	      if (bytes == 0)
		{
		  if (i < un)
		    limb = u->_mp_d[i++];
		  bytes = sizeof (mp_limb_t);
		}
	      *p = limb;
	      limb >>= CHAR_BIT;
	      bytes--;
	    }
	}
      assert (i == un);
      assert (k == count);
    }

  if (countp)
    *countp = count;

  return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
testq %r9, %r9
jne 0x8419
movq %rcx, %r14
movl %edx, %r10d
cmpl $-0x1, %edx
je 0x8281
cmpl $0x1, %r10d
jne 0x843d
leal 0x1(%r8), %eax
cmpl $0x3, %eax
jae 0x841e
movq 0x10(%rbp), %r13
movl 0x4(%r13), %eax
testq %r14, %r14
je 0x83f5
testl %eax, %eax
je 0x83fd
movl %eax, %r12d
negl %r12d
cmovsl %eax, %r12d
movq 0x8(%r13), %rax
movq -0x8(%rax,%r12,8), %rax
testq %rax, %rax
je 0x845c
leaq (%r14,%r12,8), %rbx
addq $-0x9, %rbx
movq %rax, %rcx
shrq $0x8, %rcx
incq %rbx
cmpq $0xff, %rax
movq %rcx, %rax
ja 0x82ce
xorl %r15d, %r15d
movq %rbx, %rax
xorl %edx, %edx
divq %r14
movq %rax, -0x38(%rbp)
testq %rdi, %rdi
jne 0x831d
movq -0x38(%rbp), %rdi
imulq %r14, %rdi
movq %rsi, -0x48(%rbp)
movl %r10d, -0x2c(%rbp)
movq %r8, -0x40(%rbp)
callq *0x7d92(%rip)           # 0x100a0
movq -0x40(%rbp), %r8
movl -0x2c(%rbp), %r10d
movq -0x48(%rbp), %rsi
movq %rax, %rdi
cmpl $0x1, %r8d
movl $0x0, %r9d
sbbl %r9d, %r9d
orl %r8d, %r9d
leaq (%r14,%r14), %rcx
cmpl %r10d, %r9d
cmoveq %r15, %rcx
movq %rcx, %rax
negq %rax
cmpl $0x1, %r10d
cmovneq %rcx, %rax
movl $0x0, %ecx
cmpq %r14, %rbx
movq -0x38(%rbp), %rbx
jb 0x83c8
leaq -0x1(%rbx), %r8
imulq %r14, %r8
xorl %ecx, %ecx
cmpl $0x1, %r10d
cmovneq %rcx, %r8
addq %rdi, %r8
cmpl $0x1, %r9d
leaq -0x1(%r14,%r8), %rdx
cmovneq %r8, %rdx
movslq %r9d, %r11
negq %r11
cmpq $0x1, %r14
adcq $0x0, %r14
xorl %r8d, %r8d
xorl %r9d, %r9d
xorl %r15d, %r15d
movq %r14, %r10
testq %r8, %r8
jne 0x83ab
movl $0x8, %r8d
cmpq %r12, %rcx
jge 0x83ab
movq 0x8(%r13), %r9
movq (%r9,%rcx,8), %r9
incq %rcx
movb %r9b, (%rdx)
shrq $0x8, %r9
decq %r8
addq %r11, %rdx
decq %r10
jne 0x8390
incq %r15
addq %rax, %rdx
cmpq %rbx, %r15
jb 0x838d
cmpq %r12, %rcx
jne 0x847b
cmpq %rbx, %r15
je 0x83ff
leaq 0x261c(%rip), %rdi      # 0xa9f9
leaq 0x1c80(%rip), %rsi      # 0xa064
leaq 0x258c(%rip), %rcx      # 0xa977
movl $0x110f, %edx           # imm = 0x110F
callq 0x1090
testl %eax, %eax
jne 0x849a
xorl %ebx, %ebx
testq %rsi, %rsi
je 0x8407
movq %rbx, (%rsi)
movq %rdi, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1270
leaq 0x2520(%rip), %rdi      # 0xa945
leaq 0x1c38(%rip), %rsi      # 0xa064
leaq 0x2544(%rip), %rcx      # 0xa977
movl $0x10ca, %edx           # imm = 0x10CA
callq 0x1090
leaq 0x2497(%rip), %rdi      # 0xa8db
leaq 0x1c19(%rip), %rsi      # 0xa064
leaq 0x2525(%rip), %rcx      # 0xa977
movl $0x10c9, %edx           # imm = 0x10C9
callq 0x1090
leaq 0x2584(%rip), %rdi      # 0xa9e7
leaq 0x1bfa(%rip), %rsi      # 0xa064
leaq 0x2506(%rip), %rcx      # 0xa977
movl $0x10df, %edx           # imm = 0x10DF
callq 0x1090
leaq 0x256f(%rip), %rdi      # 0xa9f1
leaq 0x1bdb(%rip), %rsi      # 0xa064
leaq 0x24e7(%rip), %rcx      # 0xa977
movl $0x110e, %edx           # imm = 0x110E
callq 0x1090
leaq 0x2529(%rip), %rdi      # 0xa9ca
leaq 0x1bbc(%rip), %rsi      # 0xa064
leaq 0x24c8(%rip), %rcx      # 0xa977
movl $0x10cb, %edx           # imm = 0x10CB
callq 0x1090