// File: /workspace/github_c_makefile_star2_O0/liuhaotian[P]xmppsh/libstrophe/src/snprintf.c
// Function: fmtfp
static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
		  LDOUBLE fvalue, int min, int max, int flags)
{
  int signvalue = 0;
  LDOUBLE ufvalue;
  char iconvert[20];
  char fconvert[20];
  int iplace = 0;
  int fplace = 0;
  int padlen = 0; /* amount to pad */
  int zpadlen = 0; 
  int caps = 0;
  int total = 0;
  long intpart;
  long fracpart;
  
  /* 
   * AIX manpage says the default is 0, but Solaris says the default
   * is 6, and sprintf on AIX defaults to 6
   */
  if (max < 0)
    max = 6;

  ufvalue = abs_val (fvalue);

  if (fvalue < 0)
    signvalue = '-';
  else
    if (flags & DP_F_PLUS)  /* Do a sign (+/i) */
      signvalue = '+';
    else
      if (flags & DP_F_SPACE)
	signvalue = ' ';

#if 0
  if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
#endif

  intpart = ufvalue;

  /* 
   * Sorry, we only support 9 digits past the decimal because of our 
   * conversion method
   */
  if (max > 9)
    max = 9;

  /* We "cheat" by converting the fractional part to integer by
   * multiplying by a factor of 10
   */
  fracpart = _snp_round ((_snp_pow10 (max)) * (ufvalue - intpart));

  if (fracpart >= _snp_pow10 (max))
  {
    intpart++;
    fracpart -= _snp_pow10 (max);
  }

#ifdef DEBUG_SNPRINTF
  dprint (1, (debugfile, "fmtfp: %f =? %d.%d\n", fvalue, intpart, fracpart));
#endif

  /* Convert integer part */
  do {
    iconvert[iplace++] =
      (caps? "0123456789ABCDEF":"0123456789abcdef")[intpart % 10];
    intpart = (intpart / 10);
  } while(intpart && (iplace < 20));
  if (iplace == 20) iplace--;
  iconvert[iplace] = 0;

  /* Convert fractional part */
  do {
    fconvert[fplace++] =
      (caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10];
    fracpart = (fracpart / 10);
  } while(fracpart && (fplace < 20));
  if (fplace == 20) fplace--;
  fconvert[fplace] = 0;

  /* -1 for decimal point, another -1 if we are printing a sign */
  padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); 
  zpadlen = max - fplace;
  if (zpadlen < 0)
    zpadlen = 0;
  if (padlen < 0) 
    padlen = 0;
  if (flags & DP_F_MINUS) 
    padlen = -padlen; /* Left Justifty */

  if ((flags & DP_F_ZERO) && (padlen > 0)) 
  {
    if (signvalue) 
    {
      total += dopr_outch (buffer, currlen, maxlen, signvalue);
      --padlen;
      signvalue = 0;
    }
    while (padlen > 0)
    {
      total += dopr_outch (buffer, currlen, maxlen, '0');
      --padlen;
    }
  }
  while (padlen > 0)
  {
    total += dopr_outch (buffer, currlen, maxlen, ' ');
    --padlen;
  }
  if (signvalue) 
    total += dopr_outch (buffer, currlen, maxlen, signvalue);

  while (iplace > 0) 
    total += dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]);

  /*
   * Decimal point.  This should probably use locale to find the correct
   * char to print out.
   */
  if (max > 0)
  {
    total += dopr_outch (buffer, currlen, maxlen, '.');

    while (fplace > 0) 
      total += dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]);
  }

  while (zpadlen > 0)
  {
    total += dopr_outch (buffer, currlen, maxlen, '0');
    --zpadlen;
  }

  while (padlen < 0) 
  {
    total += dopr_outch (buffer, currlen, maxlen, ' ');
    ++padlen;
  }

  return total;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movsd %xmm0, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x74(%rbp)
movl $0x0, -0x78(%rbp)
movl $0x0, -0x7c(%rbp)
movl $0x0, -0x80(%rbp)
movl $0x0, -0x84(%rbp)
movl $0x0, -0x88(%rbp)
cmpl $0x0, -0x28(%rbp)
jge 0x1048b
movl $0x6, -0x28(%rbp)
movsd -0x20(%rbp), %xmm0
callq 0x10aa0
movsd %xmm0, -0x38(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x20(%rbp), %xmm0
jbe 0x104ad
movl $0x2d, -0x30(%rbp)
jmp 0x104d7
movl -0x2c(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x104c1
movl $0x2b, -0x30(%rbp)
jmp 0x104d5
movl -0x2c(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x104d3
movl $0x20, -0x30(%rbp)
jmp 0x104d5
jmp 0x104d7
cvttsd2si -0x38(%rbp), %rax
movq %rax, -0x90(%rbp)
cmpl $0x9, -0x28(%rbp)
jle 0x104f1
movl $0x9, -0x28(%rbp)
movl -0x28(%rbp), %edi
callq 0x10b40
movsd -0x38(%rbp), %xmm1
cvtsi2sdq -0x90(%rbp), %xmm2
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
callq 0x10af0
movq %rax, -0x98(%rbp)
cvtsi2sdq -0x98(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movl -0x28(%rbp), %edi
callq 0x10b40
movaps %xmm0, %xmm1
movsd -0xa0(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x1057b
movq -0x90(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x90(%rbp)
movl -0x28(%rbp), %edi
callq 0x10b40
movaps %xmm0, %xmm1
cvtsi2sdq -0x98(%rbp), %xmm0
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x98(%rbp)
jmp 0x1057d
movl -0x84(%rbp), %edx
leaq 0x4c3f(%rip), %rax      # 0x151c9
leaq 0x4c27(%rip), %rcx      # 0x151b8
cmpl $0x0, %edx
cmovneq %rcx, %rax
movq %rax, -0xa8(%rbp)
movq -0x90(%rbp), %rax
movl $0xa, %ecx
cqto
idivq %rcx
movq -0xa8(%rbp), %rax
movb (%rax,%rdx), %cl
movl -0x74(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x74(%rbp)
cltq
movb %cl, -0x50(%rbp,%rax)
movq -0x90(%rbp), %rax
movl $0xa, %ecx
cqto
idivq %rcx
movq %rax, -0x90(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x90(%rbp)
movb %al, -0xa9(%rbp)
je 0x10602
cmpl $0x14, -0x74(%rbp)
setl %al
movb %al, -0xa9(%rbp)
movb -0xa9(%rbp), %al
testb $0x1, %al
jne 0x1057d
cmpl $0x14, -0x74(%rbp)
jne 0x1061f
movl -0x74(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x74(%rbp)
movslq -0x74(%rbp), %rax
movb $0x0, -0x50(%rbp,%rax)
movl -0x84(%rbp), %edx
leaq 0x4b94(%rip), %rax      # 0x151c9
leaq 0x4b7c(%rip), %rcx      # 0x151b8
cmpl $0x0, %edx
cmovneq %rcx, %rax
movq %rax, -0xb8(%rbp)
movq -0x98(%rbp), %rax
movl $0xa, %ecx
cqto
idivq %rcx
movq -0xb8(%rbp), %rax
movb (%rax,%rdx), %cl
movl -0x78(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x78(%rbp)
cltq
movb %cl, -0x70(%rbp,%rax)
movq -0x98(%rbp), %rax
movl $0xa, %ecx
cqto
idivq %rcx
movq %rax, -0x98(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x98(%rbp)
movb %al, -0xb9(%rbp)
je 0x106ad
cmpl $0x14, -0x78(%rbp)
setl %al
movb %al, -0xb9(%rbp)
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x10628
cmpl $0x14, -0x78(%rbp)
jne 0x106ca
movl -0x78(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x78(%rbp)
movslq -0x78(%rbp), %rax
movb $0x0, -0x70(%rbp,%rax)
movl -0x24(%rbp), %eax
subl -0x74(%rbp), %eax
subl -0x28(%rbp), %eax
subl $0x1, %eax
movl -0x30(%rbp), %esi
xorl %ecx, %ecx
movl $0x1, %edx
cmpl $0x0, %esi
cmovnel %edx, %ecx
subl %ecx, %eax
movl %eax, -0x7c(%rbp)
movl -0x28(%rbp), %eax
subl -0x78(%rbp), %eax
movl %eax, -0x80(%rbp)
cmpl $0x0, -0x80(%rbp)
jge 0x1070a
movl $0x0, -0x80(%rbp)
cmpl $0x0, -0x7c(%rbp)
jge 0x10717
movl $0x0, -0x7c(%rbp)
movl -0x2c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1072a
xorl %eax, %eax
subl -0x7c(%rbp), %eax
movl %eax, -0x7c(%rbp)
movl -0x2c(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x107ab
cmpl $0x0, -0x7c(%rbp)
jle 0x107ab
cmpl $0x0, -0x30(%rbp)
je 0x10774
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x30(%rbp), %eax
movsbl %al, %ecx
callq 0x100e0
addl -0x88(%rbp), %eax
movl %eax, -0x88(%rbp)
movl -0x7c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x7c(%rbp)
movl $0x0, -0x30(%rbp)
jmp 0x10776
cmpl $0x0, -0x7c(%rbp)
jle 0x107a9
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl $0x30, %ecx
callq 0x100e0
addl -0x88(%rbp), %eax
movl %eax, -0x88(%rbp)
movl -0x7c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x10776
jmp 0x107ab
jmp 0x107ad
cmpl $0x0, -0x7c(%rbp)
jle 0x107e0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl $0x20, %ecx
callq 0x100e0
addl -0x88(%rbp), %eax
movl %eax, -0x88(%rbp)
movl -0x7c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x107ad
cmpl $0x0, -0x30(%rbp)
je 0x10809
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x30(%rbp), %eax
movsbl %al, %ecx
callq 0x100e0
addl -0x88(%rbp), %eax
movl %eax, -0x88(%rbp)
jmp 0x1080b
cmpl $0x0, -0x74(%rbp)
jle 0x10840
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x74(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x74(%rbp)
cltq
movsbl -0x50(%rbp,%rax), %ecx
callq 0x100e0
addl -0x88(%rbp), %eax
movl %eax, -0x88(%rbp)
jmp 0x1080b
cmpl $0x0, -0x28(%rbp)
jle 0x1089f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl $0x2e, %ecx
callq 0x100e0
addl -0x88(%rbp), %eax
movl %eax, -0x88(%rbp)
cmpl $0x0, -0x78(%rbp)
jle 0x1089d
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl -0x78(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x78(%rbp)
cltq
movsbl -0x70(%rbp,%rax), %ecx
callq 0x100e0
addl -0x88(%rbp), %eax
movl %eax, -0x88(%rbp)
jmp 0x10868
jmp 0x1089f
jmp 0x108a1
cmpl $0x0, -0x80(%rbp)
jle 0x108d4
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl $0x30, %ecx
callq 0x100e0
addl -0x88(%rbp), %eax
movl %eax, -0x88(%rbp)
movl -0x80(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x108a1
jmp 0x108d6
cmpl $0x0, -0x7c(%rbp)
jge 0x10909
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movl $0x20, %ecx
callq 0x100e0
addl -0x88(%rbp), %eax
movl %eax, -0x88(%rbp)
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x108d6
movl -0x88(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax,%rax)