// File: marxn[P]pupp/3rdparty/gmp/printf/snprntffuns.c
// Function: gmp_snprintf_format
static int
gmp_snprintf_format (struct gmp_snprintf_t *d, const char *fmt,
                     va_list orig_ap)
{
  int      ret, step, alloc, avail;
  va_list  ap;
  char     *p;

  ASSERT (d->size >= 0);

  avail = d->size;
  if (avail > 1)
    {
      va_copy (ap, orig_ap);
      ret = vsnprintf (d->buf, avail, fmt, ap);
      if (ret == -1)
        {
          ASSERT (strlen (d->buf) == avail-1);
          ret = avail-1;
        }

      step = MIN (ret, avail-1);
      d->size -= step;
      d->buf += step;

      if (ret != avail-1)
        return ret;

      /* probably glibc 2.0.x truncated output, probe for actual size */
      alloc = MAX (128, ret);
    }
  else
    {
      /* no space to write anything, just probe for size */
      alloc = 128;
    }

  do
    {
      alloc *= 2;
      p = __GMP_ALLOCATE_FUNC_TYPE (alloc, char);
      va_copy (ap, orig_ap);
      ret = vsnprintf (p, alloc, fmt, ap);
      (*__gmp_free_func) (p, alloc);
    }
  while (ret == alloc-1 || ret == -1);

  return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
jmp 0x55f56
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, -0x30(%rbp)
cmpl $0x1, -0x30(%rbp)
jle 0x56033
leaq -0x50(%rbp), %rax
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movups (%rcx), %xmm0
movups %xmm0, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movslq -0x30(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x50(%rbp), %rcx
callq 0x61f0
movl %eax, -0x24(%rbp)
cmpl $-0x1, -0x24(%rbp)
jne 0x55faf
jmp 0x55fa4
jmp 0x55fa6
movl -0x30(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl -0x30(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x55fc4
movl -0x24(%rbp), %eax
movl %eax, -0x5c(%rbp)
jmp 0x55fcd
movl -0x30(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x28(%rbp)
movslq -0x28(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x8(%rax)
movl -0x28(%rbp), %edx
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, (%rax)
movl -0x24(%rbp), %eax
movl -0x30(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
je 0x56011
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x560cb
movl $0x80, %eax
cmpl -0x24(%rbp), %eax
jle 0x56025
movl $0x80, %eax
movl %eax, -0x60(%rbp)
jmp 0x5602b
movl -0x24(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x5603a
movl $0x80, -0x2c(%rbp)
jmp 0x5603c
movl -0x2c(%rbp), %eax
shll %eax
movl %eax, -0x2c(%rbp)
leaq 0x202d5(%rip), %rax     # 0x76320
movq (%rax), %rax
movslq -0x2c(%rbp), %rdi
shlq $0x0, %rdi
callq *%rax
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rax
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movups (%rcx), %xmm0
movups %xmm0, (%rax)
movq -0x58(%rbp), %rdi
movslq -0x2c(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x50(%rbp), %rcx
callq 0x61f0
movl %eax, -0x24(%rbp)
leaq 0x2029f(%rip), %rax     # 0x76330
movq (%rax), %rax
movq -0x58(%rbp), %rdi
movslq -0x2c(%rbp), %rsi
callq *%rax
movl -0x24(%rbp), %ecx
movl -0x2c(%rbp), %edx
subl $0x1, %edx
movb $0x1, %al
cmpl %edx, %ecx
movb %al, -0x61(%rbp)
je 0x560ba
cmpl $-0x1, -0x24(%rbp)
sete %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
testb $0x1, %al
jne 0x5603c
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)