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

```asm
<printhex>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  jmp    L85
L183:
  cmpq   $0x1,-0x38(%rbp)
  jbe    L129
  mov    -0x30(%rbp),%rax
  mov    %eax,%ecx
  mov    -0x38(%rbp),%rax
  mov    $0x10,%edx
  cmp    %rdx,%rax
  cmova  %rdx,%rax
  add    %rcx,%rax
  lea    -0x1(%rax),%rdx
  mov    -0x30(%rbp),%rax
  mov    %eax,%esi
  mov    -0x28(%rbp),%rax
  mov    %rdx,%rcx
  mov    %esi,%edx
  lea    D65(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  jmp    L75
L129:
  mov    -0x30(%rbp),%rax
  mov    %eax,%esi
  mov    -0x28(%rbp),%rax
  lea    D47(%rip),%rdx
  mov    %rdx,%rcx
  mov    %esi,%edx
  lea    D34(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
L75:
  mov    -0x30(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  movl   $0x8,-0x14(%rbp)
  jmp    L95
L205:
  mov    -0x10(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x10(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x28(%rbp),%rax
  lea    D21(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  subl   $0x1,-0x14(%rbp)
  subq   $0x1,-0x8(%rbp)
L95:
  cmpl   $0x0,-0x14(%rbp)
  je     L182
  cmpq   $0x0,-0x8(%rbp)
  jne    L205
  jmp    L182
L52:
  mov    -0x28(%rbp),%rax
  mov    %rax,%rcx
  mov    $0x3,%edx
  mov    $0x1,%esi
  lea    D11(%rip),%rax
  mov    %rax,%rdi
  call   <fwrite@plt>
  subl   $0x1,-0x14(%rbp)
L182:
  cmpl   $0x0,-0x14(%rbp)
  jne    L52
  mov    -0x28(%rbp),%rax
  mov    %rax,%rsi
  mov    $0x20,%edi
  call   <fputc@plt>
  cmpq   $0x0,-0x8(%rbp)
  je     L104
  movl   $0x8,-0x14(%rbp)
  jmp    L175
L31:
  mov    -0x10(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x10(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x28(%rbp),%rax
  lea    D21(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  subl   $0x1,-0x14(%rbp)
  subq   $0x1,-0x8(%rbp)
L175:
  cmpl   $0x0,-0x14(%rbp)
  je     L46
  cmpq   $0x0,-0x8(%rbp)
  jne    L31
  jmp    L46
L104:
  movl   $0x8,-0x14(%rbp)
  jmp    L46
L25:
  mov    -0x28(%rbp),%rax
  mov    %rax,%rcx
  mov    $0x3,%edx
  mov    $0x1,%esi
  lea    D11(%rip),%rax
  mov    %rax,%rdi
  call   <fwrite@plt>
  subl   $0x1,-0x14(%rbp)
L46:
  cmpl   $0x0,-0x14(%rbp)
  jne    L25
  mov    -0x28(%rbp),%rax
  mov    %rax,%rcx
  mov    $0x2,%edx
  mov    $0x1,%esi
  lea    D31(%rip),%rax
  mov    %rax,%rdi
  call   <fwrite@plt>
  movl   $0x10,-0x14(%rbp)
  jmp    L120
L33:
  mov    -0x30(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x30(%rbp)
  movzbl (%rax),%eax
  mov    %al,-0x15(%rbp)
  cmpb   $0x1f,-0x15(%rbp)
  jle    L144
  movsbl -0x15(%rbp),%eax
  jmp    L112
L144:
  mov    $0x2e,%eax
L112:
  mov    -0x28(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <fputc@plt>
  subl   $0x1,-0x14(%rbp)
  subq   $0x1,-0x38(%rbp)
L120:
  cmpl   $0x0,-0x14(%rbp)
  je     L37
  cmpq   $0x0,-0x38(%rbp)
  jne    L33
L37:
  mov    -0x28(%rbp),%rax
  mov    %rax,%rsi
  mov    $0xa,%edi
  call   <fputc@plt>
L85:
  cmpq   $0x0,-0x38(%rbp)
  jne    L183
  nop
  nop
  leave
  ret
```

tool_calls: name: parse_data
arguments: tag: D65
type: string
name: parse_data
arguments: tag: D47
type: string
name: parse_data
arguments: tag: D34
type: string
name: parse_data
arguments: tag: D21
type: string
name: parse_data
arguments: tag: D11
type: string
name: parse_data
arguments: tag: D31
type: string

tool: D65: %08X-%08X 

tool: 

tool: D34: %08X %8.8s 

tool: D21:  %02X

tool: D11:    

tool: D31:   

assistant: ```c
void printhex(FILE *output, const char *buf, size_t size) {
  int i;
  char *ptr;
  char c;
  size_t tmp;
  while (size) {
    if (size > 1) {
      fprintf(output, "%08X-%08X ", (unsigned int)buf, (unsigned int)buf + (size > 15 ? 15 : size - 1));
    } else
      fprintf(output, "%08X %8.8s ", (unsigned int)buf, "");
    ptr = (char *)buf;
    tmp = size;
    for (i = 8; i && tmp; i--, tmp--)
      fprintf(output, " %02X", (unsigned char)*ptr++);
    for (; i; i--)
      fprintf(output, "   ");
    fprintf(output, " ");
    if (tmp) {
      for (i = 8; i && tmp; i--, tmp--)
        fprintf(output, " %02X", (unsigned char)*ptr++);
    } else
      i = 8;
    for (; i; i--)
      fprintf(output, "   ");
    fprintf(output, "  ");
    for (i = 16; i && size; i--, size--) {
      c = *buf++;
      fprintf(output, "%c", c < 32 ? '.' : c);
    }
    fprintf(output, "\n");
  }
}
```