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

```asm
<af_fmt2str>:
  endbr64
  test   %edx,%edx
  jle    L178
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %edi,%r13d
  mov    %rsi,%rbp
  lea    -0x1(%rdx),%r12d
  test   $0x1,%dil
  je     L1
  lea    D58(%rip),%rdx
  mov    %r12d,%esi
  mov    %rbp,%rdi
  mov    $0x0,%eax
  call   <snprintf@plt>
  mov    %eax,%ebx
L49:
  mov    %r13d,%eax
  and    $0x1c0,%eax
  je     L42
  cmp    $0x100,%eax
  je     L109
  jg     L142
  cmp    $0x80,%eax
  je     L78
  cmp    $0xc0,%eax
  jne    L119
  mov    %r12d,%esi
  sub    %ebx,%esi
  movslq %ebx,%rdi
  add    %rbp,%rdi
  lea    D73(%rip),%rdx
  mov    $0x0,%eax
  call   <snprintf@plt>
  add    %eax,%ebx
  jmp    L73
L1:
  lea    D131(%rip),%rdx
  mov    %r12d,%esi
  mov    %rbp,%rdi
  mov    $0x0,%eax
  call   <snprintf@plt>
  mov    %eax,%ebx
  jmp    L49
L119:
  cmp    $0x40,%eax
  jne    L61
  mov    %r12d,%esi
  sub    %ebx,%esi
  movslq %ebx,%rdi
  add    %rbp,%rdi
  lea    D123(%rip),%rdx
  mov    $0x0,%eax
  call   <snprintf@plt>
  add    %eax,%ebx
  jmp    L73
L142:
  cmp    $0x140,%eax
  je     L9
  cmp    $0x180,%eax
  jne    L61
  mov    %r12d,%esi
  sub    %ebx,%esi
  movslq %ebx,%rdi
  add    %rbp,%rdi
  lea    D71(%rip),%rdx
  mov    $0x0,%eax
  call   <snprintf@plt>
  add    %eax,%ebx
  jmp    L73
L78:
  mov    %r12d,%esi
  sub    %ebx,%esi
  movslq %ebx,%rdi
  add    %rbp,%rdi
  lea    D94(%rip),%rdx
  mov    $0x0,%eax
  call   <snprintf@plt>
  add    %eax,%ebx
  jmp    L73
L109:
  mov    %r12d,%esi
  sub    %ebx,%esi
  movslq %ebx,%rdi
  add    %rbp,%rdi
  lea    D104(%rip),%rdx
  mov    $0x0,%eax
  call   <snprintf@plt>
  add    %eax,%ebx
  jmp    L73
L9:
  mov    %r12d,%esi
  sub    %ebx,%esi
  movslq %ebx,%rdi
  add    %rbp,%rdi
  lea    D70(%rip),%rdx
  mov    $0x0,%eax
  call   <snprintf@plt>
  add    %eax,%ebx
  jmp    L73
L61:
  mov    %r12d,%esi
  sub    %ebx,%esi
  movslq %ebx,%rdi
  add    %rbp,%rdi
  lea    D96(%rip),%rdx
  mov    $0x0,%eax
  call   <snprintf@plt>
  add    %eax,%ebx
  jmp    L73
L42:
  mov    %r13d,%edi
  call   <af_fmt2bits@plt>
  mov    %eax,%ecx
  mov    %r12d,%esi
  sub    %ebx,%esi
  movslq %ebx,%rdi
  add    %rbp,%rdi
  lea    D115(%rip),%rdx
  mov    $0x0,%eax
  call   <snprintf@plt>
  add    %eax,%ebx
  test   $0x4,%r13b
  jne    L6
  test   $0x2,%r13b
  je     L136
  mov    %r12d,%esi
  sub    %ebx,%esi
  movslq %ebx,%rdi
  add    %rbp,%rdi
  lea    D127(%rip),%rdx
  mov    $0x0,%eax
  call   <snprintf@plt>
  add    %eax,%ebx
L186:
  mov    %r12d,%esi
  sub    %ebx,%esi
  movslq %ebx,%rdi
  add    %rbp,%rdi
  lea    D135(%rip),%rdx
  mov    $0x0,%eax
  call   <snprintf@plt>
  add    %eax,%ebx
L73:
  test   %ebx,%ebx
  jle    L240
  movslq %ebx,%rax
  cmpb   $0x20,-0x1(%rbp,%rax,1)
  je     L160
L240:
  movslq %ebx,%rbx
  movb   $0x0,0x0(%rbp,%rbx,1)
  mov    %rbp,%rax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L6:
  mov    %r12d,%esi
  sub    %ebx,%esi
  movslq %ebx,%rdi
  add    %rbp,%rdi
  lea    D80(%rip),%rdx
  mov    $0x0,%eax
  call   <snprintf@plt>
  add    %eax,%ebx
  jmp    L73
L136:
  mov    %r12d,%esi
  sub    %ebx,%esi
  movslq %ebx,%rdi
  add    %rbp,%rdi
  lea    D50(%rip),%rdx
  mov    $0x0,%eax
  call   <snprintf@plt>
  add    %eax,%ebx
  jmp    L186
L160:
  sub    $0x1,%ebx
  jmp    L240
L178:
  mov    $0x0,%eax
  ret
```

tool_calls: name: parse_data
arguments: label: D58
type_guessed: string
name: parse_data
arguments: label: D73
type_guessed: string
name: parse_data
arguments: label: D131
type_guessed: string
name: parse_data
arguments: label: D123
type_guessed: string
name: parse_data
arguments: label: D71
type_guessed: string
name: parse_data
arguments: label: D94
type_guessed: string
name: parse_data
arguments: label: D104
type_guessed: string
name: parse_data
arguments: label: D70
type_guessed: string
name: parse_data
arguments: label: D96
type_guessed: string
name: parse_data
arguments: label: D115
type_guessed: string
name: parse_data
arguments: label: D127
type_guessed: string
name: parse_data
arguments: label: D135
type_guessed: string
name: parse_data
arguments: label: D80
type_guessed: string
name: parse_data
arguments: label: D50
type_guessed: string

tool: D58: little-endian 

tool: D73: MPEG-2 

tool: D131: big-endian 

tool: D123: mu-law 

tool: D71: IEC61937 

tool: D94: A-law 

tool: D104: AC3 

tool: D70: IMA-ADPCM 

tool: D96: unknown format 

tool: D115: %d-bit 

tool: D127: unsigned 

tool: D135: int 

tool: D80: float 

tool: D50: signed 

assistant: ```c
char *af_fmt2str(int format, char *str, int size) {
  int i = 0;
  if (size < 1)
    return NULL;
  size--;
  if ((1 << 0) == (format & (1 << 0)))
    i += snprintf(str, size - i, "little-endian ");
  else
    i += snprintf(str, size - i, "big-endian ");
  if (format & (7 << 6)) {
    switch (format & (7 << 6)) {
    case ((1 << 6)):
      i += snprintf(&str[i], size - i, "mu-law ");
      break;
    case ((2 << 6)):
      i += snprintf(&str[i], size - i, "A-law ");
      break;
    case ((3 << 6)):
      i += snprintf(&str[i], size - i, "MPEG-2 ");
      break;
    case ((4 << 6)):
      i += snprintf(&str[i], size - i, "AC3 ");
      break;
    case ((6 << 6)):
      i += snprintf(&str[i], size - i, "IEC61937 ");
      break;
    case ((5 << 6)):
      i += snprintf(&str[i], size - i, "IMA-ADPCM ");
      break;
    default:
      i += snprintf(&str[i], size - i, "unknown format ");
    }
  } else {
    i += snprintf(&str[i], size - i, "%d-bit ", af_fmt2bits(format));
    if ((1 << 2) == (format & (1 << 2)))
      i += snprintf(&str[i], size - i, "float ");
    else {
      if ((1 << 1) == (format & (1 << 1)))
        i += snprintf(&str[i], size - i, "unsigned ");
      else
        i += snprintf(&str[i], size - i, "signed ");
      i += snprintf(&str[i], size - i, "int ");
    }
  }
  if (i > 0 && str[i - 1] == ' ')
    i--;
  str[i] = 0;
  return str;
}
```