user: Translate the below assembly code into C programming language:

```asm
<fmtint>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  push   %r14
  push   %r13
  mov    %rdx,%r13
  push   %r12
  push   %rbp
  mov    %rsi,%rbp
  mov    %rcx,%rsi
  push   %rbx
  mov    %r9d,%ebx
  sub    $0x48,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  mov    0x80(%rsp),%r14d
  mov    0x88(%rsp),%edi
  test   %r14d,%r14d
  cmovs  %eax,%r14d
  test   $0x40,%dil
  jne    L122
  test   %rcx,%rcx
  js     L179
  test   $0x2,%dil
  je     L125
  movl   $0x2b,0x18(%rsp)
  mov    $0x1,%r11d
  jmp    L146
L122:
  movl   $0x0,0x18(%rsp)
  xor    %r11d,%r11d
L146:
  lea    0x1f(%rsp),%r12
  test   $0x20,%dil
  mov    %r8d,%r8d
  mov    $0x1,%ecx
  lea    D19(%rip),%r9
  lea    D12(%rip),%rax
  mov    %r12,0x8(%rsp)
  cmove  %rax,%r9
  nopl   0x0(%rax,%rax,1)
L4:
  mov    %rsi,%rax
  xor    %edx,%edx
  mov    %ecx,%r10d
  div    %r8
  movzbl (%r9,%rdx,1),%edx
  mov    %dl,(%r12,%rcx,1)
  mov    %rsi,%rdx
  mov    %rax,%rsi
  cmp    %r8,%rdx
  setae  %dl
  cmp    $0x17,%ecx
  setbe  %al
  add    $0x1,%rcx
  test   %al,%dl
  jne    L4
  cmp    $0x18,%r10d
  mov    $0x17,%eax
  mov    $0x0,%esi
  mov    %edi,%r12d
  cmove  %eax,%r10d
  movslq %r10d,%rax
  cmp    %r10d,%r14d
  mov    %rax,0x10(%rsp)
  movb   $0x0,0x20(%rsp,%rax,1)
  mov    %r10d,%eax
  cmovge %r14d,%eax
  sub    %eax,%ebx
  mov    %ebx,%eax
  sub    %r11d,%eax
  sub    %r10d,%r14d
  cmovns %r14d,%esi
  xor    %ebx,%ebx
  test   %eax,%eax
  cmovns %eax,%ebx
  and    $0x1,%r12d
  and    $0x10,%edi
  mov    %esi,0x4(%rsp)
  je     L186
  cmp    %ebx,%esi
  cmovge %esi,%ebx
  mov    %ebx,0x4(%rsp)
  xor    %ebx,%ebx
  test   %r12d,%r12d
  je     L131
L13:
  xor    %r8d,%r8d
  xor    %r12d,%r12d
L181:
  mov    0x18(%rsp),%eax
  test   %eax,%eax
  jne    L139
L114:
  mov    0x4(%rsp),%r14d
  test   %r14d,%r14d
  jne    L192
L161:
  mov    0x10(%rsp),%r14
  mov    %ebx,0x4(%rsp)
  mov    %r14,%rbx
  mov    0x8(%rsp),%r14
  nopl   (%rax)
L218:
  movsbl (%r14,%rbx,1),%ecx
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    %r15,%rdi
  sub    $0x1,%rbx
  call   <dopr_outch@plt>
  add    %eax,%r12d
  test   %ebx,%ebx
  jne    L218
  mov    0x4(%rsp),%ebx
  test   %ebx,%ebx
  je     L34
  cs nopw 0x0(%rax,%rax,1)
L6:
  mov    $0x20,%ecx
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    %r15,%rdi
  call   <dopr_outch@plt>
  add    %eax,%r12d
  add    $0x1,%ebx
  jne    L6
L34:
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L38
  add    $0x48,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L192:
  mov    $0x30,%ecx
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    %r15,%rdi
  call   <dopr_outch@plt>
  add    %eax,%r12d
  sub    $0x1,%r14d
  jne    L192
  jmp    L161
  nopl   0x0(%rax)
L186:
  test   %r12d,%r12d
  jne    L206
  test   %eax,%eax
  jle    L131
  mov    %ebx,%r14d
  nopl   0x0(%rax)
L92:
  mov    $0x20,%ecx
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    %r15,%rdi
  call   <dopr_outch@plt>
  lea    (%r12,%rax,1),%r8d
  mov    %r8d,%r12d
  sub    $0x1,%r14d
  jne    L92
  test   %ebx,%ebx
  mov    $0x1,%eax
  cmovg  %ebx,%eax
  sub    %eax,%ebx
  mov    0x18(%rsp),%eax
  test   %eax,%eax
  je     L114
L139:
  mov    0x18(%rsp),%ecx
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    %r15,%rdi
  mov    %r8d,0x1c(%rsp)
  call   <dopr_outch@plt>
  mov    0x1c(%rsp),%r8d
  lea    (%r8,%rax,1),%r12d
  jmp    L114
  nopl   (%rax)
L131:
  xor    %r8d,%r8d
  jmp    L181
  nopl   0x0(%rax,%rax,1)
L206:
  neg    %ebx
  jmp    L13
  nopw   0x0(%rax,%rax,1)
L179:
  movl   $0x2d,0x18(%rsp)
  neg    %rsi
  mov    $0x1,%r11d
  jmp    L146
  cs nopw 0x0(%rax,%rax,1)
L125:
  lea    0x0(,%rdi,8),%eax
  and    $0x20,%eax
  setne  %r11b
  mov    %eax,0x18(%rsp)
  movzbl %r11b,%r11d
  jmp    L146
L38:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: label: D19
type_guessed: string
name: parse_data
arguments: label: D12
type_guessed: string

tool: D19: 0123456789ABCDEF

tool: D12: 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];
  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 - ((max >= place) ? 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;
}
```