user: Please show me the C implementation that matches the assembly code listed below:

```asm
<fmtint>:
  endbr64
  push   %r15
  mov    %rcx,%rax
  mov    %r8d,%ecx
  push   %r14
  push   %r13
  mov    %r9d,%r13d
  push   %r12
  mov    %rdi,%r12
  mov    %rax,%rdi
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x78,%rsp
  mov    %fs:0x28,%rdx
  mov    %rdx,0x68(%rsp)
  xor    %edx,%edx
  mov    0xb8(%rsp),%r14d
  mov    %r14d,%r10d
  and    $0x20,%r10d
  test   $0x80,%r14b
  je     L244
  movl   $0x0,0x14(%rsp)
  xor    %r15d,%r15d
L312:
  lea    0x30(%rsp),%r9
  mov    %r14d,%r8d
  mov    $0x2b,%edx
  mov    %r10d,0x10(%rsp)
  and    $0x40,%r8d
  mov    %r9,%rsi
  mov    %r9,0x8(%rsp)
  mov    %r8d,0x24(%rsp)
  mov    %ecx,0x20(%rsp)
  mov    %rdi,0x18(%rsp)
  call   <convert@plt>
  test   $0x8,%r14b
  mov    0x8(%rsp),%r9
  mov    0x10(%rsp),%r10d
  mov    %eax,%edx
  je     L15
  mov    0x18(%rsp),%rdi
  mov    0x20(%rsp),%ecx
  mov    0x24(%rsp),%r8d
  test   %rdi,%rdi
  jne    L195
L15:
  mov    0xb0(%rsp),%ecx
L229:
  sub    %edx,%ecx
  mov    %edx,%r11d
  cmp    %edx,0xb0(%rsp)
  cmovge 0xb0(%rsp),%r11d
  xor    %esi,%esi
  xor    %r8d,%r8d
L323:
  test   %r10d,%r10d
  jne    L333
L198:
  mov    %r13d,%eax
  mov    %r14d,%r13d
  sub    %r11d,%eax
  sub    0x14(%rsp),%eax
  sub    %esi,%eax
  xor    %esi,%esi
  test   %ecx,%ecx
  cmovs  %esi,%ecx
  test   %eax,%eax
  cmovns %eax,%esi
  and    $0x1,%r13d
  je     L461
  neg    %esi
  mov    %esi,%r13d
L297:
  test   %r15b,%r15b
  je     L485
  mov    (%rbx),%rsi
  lea    0x1(%rsi),%rax
  cmp    %rbp,%rax
  jb     L255
L354:
  mov    %rax,(%rbx)
L485:
  test   %r8b,%r8b
  je     L6
  mov    (%rbx),%rax
  lea    0x1(%rax),%rsi
  cmp    %rbp,%rsi
  jae    L460
  movb   $0x30,(%r12,%rax,1)
  mov    (%rbx),%rax
  lea    0x1(%rax),%rsi
L460:
  add    $0x2,%rax
  mov    %rsi,(%rbx)
  cmp    %rbp,%rax
  jb     L451
L330:
  mov    %rax,(%rbx)
L6:
  test   %ecx,%ecx
  je     L159
  mov    (%rbx),%rax
  jmp    L86
  nopw   0x0(%rax,%rax,1)
L48:
  movb   $0x30,(%r12,%rax,1)
  mov    (%rbx),%rax
  add    $0x1,%rax
  mov    %rax,(%rbx)
  sub    $0x1,%ecx
  je     L159
L86:
  lea    0x1(%rax),%rsi
  cmp    %rbp,%rsi
  jb     L48
  mov    %rsi,%rax
  mov    %rax,(%rbx)
  sub    $0x1,%ecx
  jne    L86
L159:
  test   %edx,%edx
  jle    L199
  test   %r10d,%r10d
  mov    %r12,%rdi
  mov    (%rbx),%rcx
  mov    %r9,%r12
  setg   %r15b
  sub    $0x1,%edx
  movslq %edx,%r14
  jmp    L2
  nopl   0x0(%rax)
L299:
  imul   $0xaaaaaaab,%edx,%edx
  cmp    $0x55555555,%edx
  jbe    L305
L95:
  mov    %rax,%rcx
  sub    $0x1,%r14
L2:
  lea    0x1(%rcx),%rax
  mov    %r14d,%edx
  cmp    %rbp,%rax
  jae    L110
  movzbl (%r12,%r14,1),%eax
  mov    %al,(%rdi,%rcx,1)
  mov    (%rbx),%rax
  add    $0x1,%rax
L110:
  mov    %rax,(%rbx)
  test   %r14d,%r14d
  jle    L96
  test   %r15b,%r15b
  jne    L299
  test   %r14d,%r14d
  jg     L95
  xchg   %ax,%ax
L96:
  mov    %rdi,%r12
L199:
  test   %r13d,%r13d
  je     L388
  mov    (%rbx),%rax
  jmp    L291
  nopl   (%rax)
L288:
  movb   $0x20,(%r12,%rax,1)
  mov    (%rbx),%rax
  add    $0x1,%rax
  mov    %rax,(%rbx)
  add    $0x1,%r13d
  je     L388
L291:
  lea    0x1(%rax),%rdx
  cmp    %rbp,%rdx
  jb     L288
  mov    %rdx,%rax
  mov    %rax,(%rbx)
  add    $0x1,%r13d
  jne    L291
L388:
  mov    0x68(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L5
  add    $0x78,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L305:
  mov    %rbp,%rdx
  mov    %rbx,%rsi
  mov    %rdi,0x8(%rsp)
  call   <printsep@plt>
  mov    (%rbx),%rax
  mov    0x8(%rsp),%rdi
  jmp    L95
  nopl   (%rax)
L461:
  and    $0x10,%r14d
  je     L196
  cmpl   $0xffffffff,0xb0(%rsp)
  je     L158
L196:
  test   %eax,%eax
  jle    L259
  mov    (%rbx),%rax
  mov    %esi,%edi
  jmp    L75
  nop
L383:
  movb   $0x20,(%r12,%rax,1)
  mov    (%rbx),%rax
  add    $0x1,%rax
  mov    %rax,(%rbx)
  sub    $0x1,%edi
  je     L251
L75:
  lea    0x1(%rax),%r11
  cmp    %rbp,%r11
  jb     L383
  mov    %r11,%rax
  mov    %rax,(%rbx)
  sub    $0x1,%edi
  jne    L75
L251:
  test   %esi,%esi
  mov    $0x1,%eax
  cmovg  %esi,%eax
  sub    %eax,%esi
L259:
  mov    %esi,%r13d
  jmp    L297
  nopl   0x0(%rax)
L244:
  neg    %rdi
  cmovs  %rax,%rdi
  test   %rax,%rax
  js     L219
  test   $0x2,%r14b
  je     L185
  movl   $0x1,0x14(%rsp)
  mov    $0x2b,%r15d
  jmp    L312
  nopl   (%rax)
L451:
  mov    %r8b,(%r12,%rsi,1)
  mov    (%rbx),%rax
  add    $0x1,%rax
  jmp    L330
L255:
  mov    %r15b,(%r12,%rsi,1)
  mov    (%rbx),%rax
  add    $0x1,%rax
  jmp    L354
L195:
  cmp    $0x8,%ecx
  je     L129
  cmp    $0x10,%ecx
  mov    0xb0(%rsp),%ecx
  jne    L229
  sub    %eax,%ecx
  mov    %eax,%r11d
  cmp    %eax,0xb0(%rsp)
  cmovge 0xb0(%rsp),%r11d
  cmp    $0x1,%r8d
  mov    $0x2,%esi
  sbb    %r8d,%r8d
  and    $0x20,%r8d
  add    $0x58,%r8d
  jmp    L323
  nopw   0x0(%rax,%rax,1)
L219:
  movl   $0x1,0x14(%rsp)
  mov    $0x2d,%r15d
  jmp    L312
  nopl   0x0(%rax,%rax,1)
L333:
  mov    %edx,%edi
  mov    %r9,0x28(%rsp)
  mov    %esi,0x24(%rsp)
  mov    %r11d,0x20(%rsp)
  mov    %ecx,0x18(%rsp)
  mov    %r8b,0x10(%rsp)
  mov    %edx,0x8(%rsp)
  call   <getnumsep@plt>
  mov    0x18(%rsp),%ecx
  mov    0x28(%rsp),%r9
  mov    0x24(%rsp),%esi
  mov    0x20(%rsp),%r11d
  mov    %eax,%r10d
  sub    %eax,%r13d
  movzbl 0x10(%rsp),%r8d
  mov    0x8(%rsp),%edx
  sub    %eax,%ecx
  jmp    L198
  nopl   0x0(%rax,%rax,1)
L185:
  mov    %r14d,%r15d
  xor    %eax,%eax
  shr    $0x2,%r15d
  and    $0x1,%r15d
  shl    $0x5,%r15b
  setne  %al
  mov    %eax,0x14(%rsp)
  jmp    L312
L129:
  cmp    %eax,0xb0(%rsp)
  jg     L471
  lea    0x1(%rax),%r11d
  xor    %esi,%esi
  mov    $0x1,%ecx
  xor    %r8d,%r8d
  jmp    L323
L158:
  add    %esi,%ecx
  jmp    L297
L471:
  mov    0xb0(%rsp),%ecx
  mov    0xb0(%rsp),%r11d
  xor    %esi,%esi
  xor    %r8d,%r8d
  sub    %eax,%ecx
  jmp    L323
L5:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void fmtint(char *str, size_t *len, size_t size, long int value, int base, int width, int precision, int flags) {
  unsigned long int uvalue;
  char iconvert[43];
  char sign = 0;
  char hexprefix = 0;
  int spadlen = 0;
  int zpadlen = 0;
  int pos;
  int separators = (flags & (1 << 5));
  int noprecision = (precision == -1);
  if (flags & (1 << 7))
    uvalue = value;
  else {
    uvalue = (value >= 0) ? value : -value;
    if (value < 0)
      sign = '-';
    else if (flags & (1 << 1))
      sign = '+';
    else if (flags & (1 << 2))
      sign = ' ';
  }
  pos = convert(uvalue, iconvert, sizeof(iconvert), base, flags & (1 << 6));
  if (flags & (1 << 3) && uvalue != 0) {
    switch (base) {
    case 8:
      if (precision <= pos)
        precision = pos + 1;
      break;
    case 16:
      hexprefix = (flags & (1 << 6)) ? 'X' : 'x';
      break;
    }
  }
  if (separators)
    separators = getnumsep(pos);
  zpadlen = precision - pos - separators;
  spadlen = width - separators - ((precision >= pos) ? precision : pos) - ((sign != 0) ? 1 : 0) - ((hexprefix != 0) ? 2 : 0);
  if (zpadlen < 0)
    zpadlen = 0;
  if (spadlen < 0)
    spadlen = 0;
  if (flags & (1 << 0))
    spadlen = -spadlen;
  else if (flags & (1 << 4) && noprecision) {
    zpadlen += spadlen;
    spadlen = 0;
  }
  while (spadlen > 0) {
    do {
      if (*len + 1 < size)
        str[*len] = ' ';
      (*len)++;
    } while (0);
    spadlen--;
  }
  if (sign != 0)
    do {
      if (*len + 1 < size)
        str[*len] = sign;
      (*len)++;
    } while (0);
  if (hexprefix != 0) {
    do {
      if (*len + 1 < size)
        str[*len] = '0';
      (*len)++;
    } while (0);
    do {
      if (*len + 1 < size)
        str[*len] = hexprefix;
      (*len)++;
    } while (0);
  }
  while (zpadlen > 0) {
    do {
      if (*len + 1 < size)
        str[*len] = '0';
      (*len)++;
    } while (0);
    zpadlen--;
  }
  while (pos > 0) {
    pos--;
    do {
      if (*len + 1 < size)
        str[*len] = iconvert[pos];
      (*len)++;
    } while (0);
    if (separators > 0 && pos > 0 && pos % 3 == 0)
      printsep(str, len, size);
  }
  while (spadlen < 0) {
    do {
      if (*len + 1 < size)
        str[*len] = ' ';
      (*len)++;
    } while (0);
    spadlen++;
  }
}
```