user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<fmtint>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,%r12
  mov    %rsi,%r13
  mov    %rdx,%r14
  mov    %rcx,%rax
  mov    0x70(%rsp),%r11d
  mov    0x78(%rsp),%ebx
  mov    %fs:0x28,%rdx
  mov    %rdx,0x28(%rsp)
  xor    %edx,%edx
  test   %r11d,%r11d
  cmovs  %edx,%r11d
  movl   $0x0,0xc(%rsp)
  test   $0x40,%bl
  jne    L84
  test   %rcx,%rcx
  js     L79
  movl   $0x2b,0xc(%rsp)
  test   $0x2,%bl
  jne    L84
  lea    0x0(,%rbx,8),%eax
  and    $0x20,%eax
  mov    %eax,0xc(%rsp)
  jmp    L84
L79:
  neg    %rax
  mov    %rax,%rcx
  movl   $0x2d,0xc(%rsp)
L84:
  test   $0x20,%bl
  lea    D19(%rip),%rdi
  lea    D2(%rip),%rax
  cmove  %rax,%rdi
  mov    $0x1,%esi
  mov    %r8d,%r8d
  lea    0xf(%rsp),%r10
L39:
  mov    %esi,%r15d
  mov    %esi,0x8(%rsp)
  mov    %rcx,%rax
  mov    $0x0,%edx
  div    %r8
  movzbl (%rdi,%rdx,1),%edx
  mov    %dl,(%r10,%rsi,1)
  mov    %rcx,%rdx
  mov    %rax,%rcx
  add    $0x1,%rsi
  cmp    %rdx,%r8
  ja     L149
  cmp    $0x17,%r15d
  jbe    L39
L149:
  mov    0x8(%rsp),%edi
  cmp    $0x18,%edi
  mov    $0x17,%eax
  cmovne %edi,%eax
  mov    %eax,%esi
  mov    %eax,0x8(%rsp)
  mov    %eax,%eax
  movb   $0x0,0x10(%rsp,%rax,1)
  cmpl   $0x1,0xc(%rsp)
  adc    $0xffffffff,%r9d
  cmp    %esi,%r11d
  mov    %esi,%eax
  cmovae %r11d,%eax
  sub    %eax,%r9d
  sub    %esi,%r11d
  mov    $0x0,%eax
  cmovns %r11d,%eax
  mov    %eax,(%rsp)
  test   %r9d,%r9d
  mov    $0x0,%ebp
  cmovns %r9d,%ebp
  test   $0x10,%bl
  je     L122
  cmp    %ebp,%eax
  cmovge %eax,%ebp
  mov    %ebp,(%rsp)
  and    $0x1,%ebx
  mov    %ebx,%ebp
  je     L59
  mov    $0x0,%ebp
L76:
  neg    %ebp
  mov    $0x0,%ebx
  jmp    L59
L122:
  and    $0x1,%ebx
  jne    L76
  test   %r9d,%r9d
  jle    L59
  mov    %ebp,%r15d
L162:
  mov    $0x20,%ecx
  mov    %r14,%rdx
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <dopr_outch@plt>
  add    %eax,%ebx
  sub    $0x1,%r15d
  test   %r15d,%r15d
  jg     L162
  test   %ebp,%ebp
  mov    $0x1,%eax
  cmovg  %ebp,%eax
  sub    %eax,%ebp
L59:
  cmpl   $0x0,0xc(%rsp)
  jne    L41
L153:
  cmpl   $0x0,(%rsp)
  jle    L69
L12:
  mov    $0x30,%ecx
  mov    %r14,%rdx
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <dopr_outch@plt>
  add    %eax,%ebx
  subl   $0x1,(%rsp)
  jne    L12
L69:
  cmpl   $0x0,0x8(%rsp)
  je     L103
  lea    0x10(%rsp),%rax
  mov    %rax,(%rsp)
  mov    0x8(%rsp),%esi
  lea    -0x1(%rsi),%r15d
  add    %rax,%r15
L30:
  movsbl (%r15),%ecx
  mov    %r14,%rdx
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <dopr_outch@plt>
  add    %eax,%ebx
  mov    %r15,%rax
  sub    $0x1,%r15
  cmp    %rax,(%rsp)
  jne    L30
L103:
  test   %ebp,%ebp
  jns    L42
L68:
  mov    $0x20,%ecx
  mov    %r14,%rdx
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <dopr_outch@plt>
  add    %eax,%ebx
  add    $0x1,%ebp
  jne    L68
L42:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L132
  mov    %ebx,%eax
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L41:
  movsbl 0xc(%rsp),%ecx
  mov    %r14,%rdx
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <dopr_outch@plt>
  add    %eax,%ebx
  jmp    L153
L132:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: label: D19
data_type: string
name: disassemble_data
arguments: label: D2
data_type: string

tool: D19: 0123456789ABCDEF

tool: D2: 0123456789abcdef

assistant: ```c
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[24];
  unsigned int place = 0;
  int spadlen = 0;
  int zpadlen = 0;
  const char *digits;
  int total = 0;
  if (max < 0)
    max = 0;
  uvalue = value;
  if (!(flags & (1 << 6))) {
    if (value < 0) {
      signvalue = '-';
      uvalue = -value;
    } else if (flags & (1 << 1))
      signvalue = '+';
    else if (flags & (1 << 2))
      signvalue = ' ';
  }
  if (flags & (1 << 5))
    digits = "0123456789ABCDEF";
  else
    digits = "0123456789abcdef";
  do {
    convert[place++] = digits[uvalue % (unsigned)base];
    uvalue = (uvalue / (unsigned)base);
  } while (uvalue && (place < sizeof(convert)));
  if (place == sizeof(convert))
    place--;
  convert[place] = 0;
  zpadlen = max - place;
  spadlen = min - (((unsigned int)max >= place) ? (unsigned int)max : place) - (signvalue ? 1 : 0);
  if (zpadlen < 0)
    zpadlen = 0;
  if (spadlen < 0)
    spadlen = 0;
  if (flags & (1 << 4)) {
    zpadlen = ((zpadlen >= spadlen) ? zpadlen : spadlen);
    spadlen = 0;
  }
  if (flags & (1 << 0))
    spadlen = -spadlen;
  while (spadlen > 0) {
    total += dopr_outch(buffer, currlen, maxlen, ' ');
    --spadlen;
  }
  if (signvalue)
    total += dopr_outch(buffer, currlen, maxlen, signvalue);
  if (zpadlen > 0) {
    while (zpadlen > 0) {
      total += dopr_outch(buffer, currlen, maxlen, '0');
      --zpadlen;
    }
  }
  while (place > 0)
    total += dopr_outch(buffer, currlen, maxlen, convert[--place]);
  while (spadlen < 0) {
    total += dopr_outch(buffer, currlen, maxlen, ' ');
    ++spadlen;
  }
  return total;
}
```