// File: /workspace/github_cpp_makefile_star2_O1/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 0x857e
movq %rcx, %r14
movl %edx, %r10d
cmpl $-0x1, %edx
je 0x83e7
cmpl $0x1, %r10d
jne 0x85e0
leal 0x1(%r8), %eax
cmpl $0x3, %eax
jae 0x8583
movq 0x10(%rbp), %r13
testq %r14, %r14
jne 0x8408
cmpl $0x0, 0x4(%r13)
jne 0x85ff
movl 0x4(%r13), %eax
testl %eax, %eax
je 0x8562
movl %eax, %r12d
negl %r12d
cmovsl %eax, %r12d
movq 0x8(%r13), %rax
movq -0x8(%rax,%r12,8), %rax
testq %rax, %rax
je 0x85a2
leaq (%r14,%r12,8), %rbx
addq $-0x9, %rbx
movq %rax, %rcx
shrq $0x8, %rcx
incq %rbx
cmpq $0xff, %rax
movq %rcx, %rax
ja 0x843b
xorl %r15d, %r15d
movq %rbx, %rax
xorl %edx, %edx
divq %r14
movq %rax, -0x38(%rbp)
testq %rdi, %rdi
jne 0x848a
movq -0x38(%rbp), %rdi
imulq %r14, %rdi
movq %rsi, -0x48(%rbp)
movl %r10d, -0x2c(%rbp)
movq %r8, -0x40(%rbp)
callq *0x7c25(%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 0x8535
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 0x8518
movl $0x8, %r8d
cmpq %r12, %rcx
jge 0x8518
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 0x84fd
incq %r15
addq %rax, %rdx
cmpq %rbx, %r15
jb 0x84fa
cmpq %r12, %rcx
jne 0x85c1
cmpq %rbx, %r15
je 0x8564
leaq 0x24af(%rip), %rdi      # 0xa9f9
leaq 0x1b13(%rip), %rsi      # 0xa064
leaq 0x241f(%rip), %rcx      # 0xa977
movl $0x110f, %edx           # imm = 0x110F
callq 0x1090
xorl %ebx, %ebx
testq %rsi, %rsi
je 0x856c
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 0x23bb(%rip), %rdi      # 0xa945
leaq 0x1ad3(%rip), %rsi      # 0xa064
leaq 0x23df(%rip), %rcx      # 0xa977
movl $0x10ca, %edx           # imm = 0x10CA
callq 0x1090
leaq 0x243e(%rip), %rdi      # 0xa9e7
leaq 0x1ab4(%rip), %rsi      # 0xa064
leaq 0x23c0(%rip), %rcx      # 0xa977
movl $0x10df, %edx           # imm = 0x10DF
callq 0x1090
leaq 0x2429(%rip), %rdi      # 0xa9f1
leaq 0x1a95(%rip), %rsi      # 0xa064
leaq 0x23a1(%rip), %rcx      # 0xa977
movl $0x110e, %edx           # imm = 0x110E
callq 0x1090
leaq 0x22f4(%rip), %rdi      # 0xa8db
leaq 0x1a76(%rip), %rsi      # 0xa064
leaq 0x2382(%rip), %rcx      # 0xa977
movl $0x10c9, %edx           # imm = 0x10C9
callq 0x1090
leaq 0x23c4(%rip), %rdi      # 0xa9ca
leaq 0x1a57(%rip), %rsi      # 0xa064
leaq 0x2363(%rip), %rcx      # 0xa977
movl $0x10cb, %edx           # imm = 0x10CB
callq 0x1090