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

```asm
<af_fmt2str>:
  endbr64
  test   %edx,%edx
  jle    L147
  push   %r15
  push   %r14
  push   %r13
  mov    %edi,%r13d
  push   %r12
  lea    -0x1(%rdx),%r12d
  lea    D103(%rip),%rdx
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  sub    $0x8,%rsp
  test   $0x1,%dil
  je     L5
L52:
  mov    %r12d,%esi
  mov    %rbp,%rdi
  xor    %eax,%eax
  mov    %r12d,%r15d
  call   <snprintf@plt>
  mov    %eax,%ebx
  sub    %eax,%r15d
  cltq
  lea    0x0(%rbp,%rax,1),%r14
  mov    %r13d,%eax
  and    $0x1c0,%eax
  je     L19
  lea    D133(%rip),%rdx
  cmp    $0x100,%eax
  je     L102
  jg     L71
  lea    D32(%rip),%rdx
  cmp    $0x80,%eax
  je     L102
  lea    D4(%rip),%rdx
  cmp    $0xc0,%eax
  jne    L26
L102:
  mov    %r15d,%esi
  mov    %r14,%rdi
  xor    %eax,%eax
  call   <snprintf@plt>
  add    %eax,%ebx
L40:
  movslq %ebx,%rax
  test   %ebx,%ebx
  jle    L64
  lea    -0x1(%rax),%rdx
  cmpb   $0x20,-0x1(%rbp,%rax,1)
  cmove  %rdx,%rax
L64:
  movb   $0x0,0x0(%rbp,%rax,1)
  add    $0x8,%rsp
  mov    %rbp,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L71:
  lea    D12(%rip),%rdx
  cmp    $0x140,%eax
  je     L102
  cmp    $0x180,%eax
  jne    L47
  lea    D138(%rip),%rdx
  jmp    L102
  cs nopw 0x0(%rax,%rax,1)
L26:
  lea    D28(%rip),%rdx
  cmp    $0x40,%eax
  je     L102
L47:
  lea    D114(%rip),%rdx
  jmp    L102
  nopl   (%rax)
L5:
  lea    D109(%rip),%rdx
  jmp    L52
  nopl   0x0(%rax)
L19:
  mov    %r13d,%edi
  call   <af_fmt2bits@plt>
  mov    %r15d,%esi
  mov    %r14,%rdi
  lea    D33(%rip),%rdx
  mov    %eax,%ecx
  xor    %eax,%eax
  call   <snprintf@plt>
  mov    %r12d,%esi
  add    %eax,%ebx
  movslq %ebx,%rdi
  sub    %ebx,%esi
  add    %rbp,%rdi
  test   $0x4,%r13b
  jne    L121
  and    $0x2,%r13d
  je     L139
  lea    D30(%rip),%rdx
  xor    %eax,%eax
  call   <snprintf@plt>
  add    %eax,%ebx
L3:
  movslq %ebx,%rdi
  mov    %r12d,%esi
  lea    D5(%rip),%rdx
  xor    %eax,%eax
  sub    %ebx,%esi
  add    %rbp,%rdi
  call   <snprintf@plt>
  add    %eax,%ebx
  jmp    L40
  nop
L121:
  lea    D90(%rip),%rdx
  xor    %eax,%eax
  call   <snprintf@plt>
  add    %eax,%ebx
  jmp    L40
  nopl   (%rax)
L147:
  xor    %eax,%eax
  ret
  nopl   0x0(%rax,%rax,1)
L139:
  lea    D7(%rip),%rdx
  xor    %eax,%eax
  call   <snprintf@plt>
  add    %eax,%ebx
  jmp    L3
```

tool_calls: name: read_data
arguments: tag: D103
data_type: string
name: read_data
arguments: tag: D133
data_type: string
name: read_data
arguments: tag: D32
data_type: string
name: read_data
arguments: tag: D4
data_type: string
name: read_data
arguments: tag: D12
data_type: string
name: read_data
arguments: tag: D138
data_type: string
name: read_data
arguments: tag: D28
data_type: string
name: read_data
arguments: tag: D114
data_type: string
name: read_data
arguments: tag: D109
data_type: string
name: read_data
arguments: tag: D33
data_type: string
name: read_data
arguments: tag: D30
data_type: string
name: read_data
arguments: tag: D5
data_type: string
name: read_data
arguments: tag: D90
data_type: string
name: read_data
arguments: tag: D7
data_type: string

tool: D103: little-endian 

tool: D133: AC3 

tool: D32: A-law 

tool: D4: MPEG-2 

tool: D12: IMA-ADPCM 

tool: D138: IEC61937 

tool: D28: mu-law 

tool: D114: unknown format 

tool: D109: big-endian 

tool: D33: %d-bit 

tool: D30: unsigned 

tool: D5: int 

tool: D90: float 

tool: D7: 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;
}
```