// File: /workspace/github_c_makefile_star2_O1/liuhaotian[P]xmppsh/libstrophe/src/snprintf.c
// Function: fmtint
static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
		   long value, int base, int min, int max, int flags)
{
  int signvalue = 0;
  unsigned long uvalue;
  char convert[20];
  int place = 0;
  int spadlen = 0; /* amount to space pad */
  int zpadlen = 0; /* amount to zero pad */
  int caps = 0;
  int total = 0;
  
  if (max < 0)
    max = 0;

  uvalue = value;

  if(!(flags & DP_F_UNSIGNED))
  {
    if( value < 0 ) {
      signvalue = '-';
      uvalue = -value;
    }
    else
      if (flags & DP_F_PLUS)  /* Do a sign (+/i) */
	signvalue = '+';
    else
      if (flags & DP_F_SPACE)
	signvalue = ' ';
  }
  
  if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */

  do {
    convert[place++] =
      (caps? "0123456789ABCDEF":"0123456789abcdef")
      [uvalue % (unsigned)base  ];
    uvalue = (uvalue / (unsigned)base );
  } while(uvalue && (place < 20));
  if (place == 20) place--;
  convert[place] = 0;

  zpadlen = max - place;
  spadlen = min - MAX (max, place) - (signvalue ? 1 : 0);
  if (zpadlen < 0) zpadlen = 0;
  if (spadlen < 0) spadlen = 0;
  if (flags & DP_F_ZERO)
  {
    zpadlen = MAX(zpadlen, spadlen);
    spadlen = 0;
  }
  if (flags & DP_F_MINUS) 
    spadlen = -spadlen; /* Left Justifty */

#ifdef DEBUG_SNPRINTF
  dprint (1, (debugfile, "zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
      zpadlen, spadlen, min, max, place));
#endif

  /* Spaces */
  while (spadlen > 0) 
  {
    total += dopr_outch (buffer, currlen, maxlen, ' ');
    --spadlen;
  }

  /* Sign */
  if (signvalue) 
    total += dopr_outch (buffer, currlen, maxlen, signvalue);

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

  /* Digits */
  while (place > 0) 
    total += dopr_outch (buffer, currlen, maxlen, convert[--place]);
  
  /* Left Justified spaces */
  while (spadlen < 0) {
    total += dopr_outch (buffer, currlen, maxlen, ' ');
    ++spadlen;
  }

  return total;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %r10
movq %rdx, %rcx
movl 0x40(%rsp), %ebp
movl 0x38(%rsp), %r14d
xorl %r11d, %r11d
testl %r14d, %r14d
cmovlel %r11d, %r14d
testb $0x40, %bpl
jne 0xa9f4
testq %r10, %r10
js 0xa9f8
testb $0x2, %bpl
jne 0xaa00
movl %ebp, %r11d
andl $0x4, %r11d
sete %bl
shlb $0x3, %r11b
jmp 0xaa05
movb $0x1, %bl
jmp 0xaa05
negq %r10
movb $0x2d, %r11b
jmp 0xaa03
movb $0x2b, %r11b
xorl %ebx, %ebx
testb $0x20, %bpl
leaq 0x36e9(%rip), %rax      # 0xe0f9
leaq 0x36d1(%rip), %r15      # 0xe0e8
cmoveq %rax, %r15
movl %r8d, %r8d
xorl %r12d, %r12d
movq %r10, %rax
xorl %edx, %edx
divq %r8
movb (%r15,%rdx), %dl
leaq 0x1(%r12), %r13
movb %dl, -0x18(%rsp,%r12)
cmpq %r8, %r10
jb 0xaa48
movq %rax, %r10
cmpq $0x13, %r12
movq %r13, %r12
jb 0xaa21
leaq -0x1(%r13), %rdx
cmpq $0x14, %r13
cmovneq %r13, %rdx
movl %edx, %eax
movl %r14d, %r8d
subl %edx, %r8d
cmovlel %edx, %r14d
movl %ebx, %r10d
xorb $0x1, %r10b
movzbl %r10b, %r10d
subl %r10d, %r9d
subl %r14d, %r9d
xorl %r14d, %r14d
testl %r8d, %r8d
cmovlel %r14d, %r8d
testl %r9d, %r9d
cmovlel %r14d, %r9d
cmpl %r9d, %r8d
movl %r9d, %r10d
cmoval %r8d, %r10d
movb $0x0, -0x18(%rsp,%rax)
testb $0x10, %bpl
cmovnel %r14d, %r9d
cmovel %r8d, %r10d
movl %r9d, %eax
negl %eax
testb $0x1, %bpl
cmovel %r9d, %eax
testl %eax, %eax
jle 0xaacf
movl %eax, %r8d
movq (%rsi), %r9
leaq 0x1(%r9), %r14
cmpq %rcx, %r14
jae 0xaac5
movq %r14, (%rsi)
movb $0x20, (%rdi,%r9)
decl %r8d
jne 0xaab1
xorl %r8d, %r8d
jmp 0xaad4
movl %eax, %r8d
xorl %eax, %eax
testb %bl, %bl
jne 0xaaed
movq (%rsi), %r9
leaq 0x1(%r9), %rbx
cmpq %rcx, %rbx
jae 0xaaeb
movq %rbx, (%rsi)
movb %r11b, (%rdi,%r9)
incl %eax
testl %r10d, %r10d
je 0xab19
leal 0x1(%r10), %r9d
movq (%rsi), %r11
leaq 0x1(%r11), %rbx
cmpq %rcx, %rbx
jae 0xab0a
movq %rbx, (%rsi)
movb $0x30, (%rdi,%r11)
decl %r9d
cmpl $0x1, %r9d
jg 0xaaf6
addl %eax, %r10d
movl %r10d, %eax
testl %edx, %edx
je 0xab4f
movl %edx, %r9d
incl %edx
leaq -0x18(%rsp), %r10
addq %r10, %r9
decq %r9
movq (%rsi), %r10
leaq 0x1(%r10), %r11
cmpq %rcx, %r11
jae 0xab43
movb (%r9), %bl
movq %r11, (%rsi)
movb %bl, (%rdi,%r10)
incl %eax
decl %edx
decq %r9
cmpl $0x1, %edx
jg 0xab2d
testl %r8d, %r8d
jns 0xab72
movl %r8d, %edx
movq (%rsi), %r9
leaq 0x1(%r9), %r10
cmpq %rcx, %r10
jae 0xab6b
movq %r10, (%rsi)
movb $0x20, (%rdi,%r9)
incl %edx
jne 0xab57
subl %r8d, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)