user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<read_tree>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %rsi,(%rsp)
  lea    0x30(%rsp),%rsi
  mov    %edx,0x10(%rsp)
  lea    0x28(%rsp),%rdx
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  call   <read_sha1_file@plt>
  test   %eax,%eax
  je     L12
  cmpl   $0x65657274,0x30(%rsp)
  je     L9
L12:
  movl   $0xffffffff,0x14(%rsp)
L120:
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L95
  mov    0x14(%rsp),%eax
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L9:
  cmpb   $0x0,0x34(%rsp)
  jne    L12
  mov    0x28(%rsp),%r14
  movl   $0x0,0x14(%rsp)
  movslq %eax,%r12
  lea    D7(%rip),%r15
  test   %r14,%r14
  jne    L111
  jmp    L120
  nopl   0x0(%rax)
L61:
  mov    %r13,%rdi
  call   <strlen@plt>
  mov    0x10(%rsp),%ebx
  mov    %rax,0x8(%rsp)
  lea    0x1(%rbx,%rax,1),%edi
  movslq %edi,%rdi
  call   <malloc@plt>
  mov    (%rsp),%rsi
  movslq %ebx,%rdx
  mov    %rax,%rdi
  mov    %rax,%r14
  mov    %rdx,0x18(%rsp)
  call   <memcpy@plt>
  mov    0x18(%rsp),%rdx
  mov    %r13,%rsi
  lea    (%r14,%rdx,1),%rdi
  movslq 0x8(%rsp),%rdx
  call   <memcpy@plt>
  mov    0x8(%rsp),%edx
  mov    %rbp,%rdi
  mov    %r14,%rsi
  add    %ebx,%edx
  movslq %edx,%rax
  add    $0x1,%edx
  movb   $0x2f,(%r14,%rax,1)
  call   <read_tree>
  mov    %r14,%rdi
  mov    %eax,%ebp
  call   <free@plt>
  test   %ebp,%ebp
  jne    L12
L25:
  mov    0x28(%rsp),%r14
  test   %r14,%r14
  je     L120
L111:
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    $0x20,%esi
  mov    %r12,%rdi
  mov    %rax,%rbx
  lea    0x1(%rax),%ebp
  call   <strchr@plt>
  lea    0x15(%rbx),%edx
  movslq %ebp,%rbp
  movslq %edx,%rbx
  add    %r12,%rbp
  lea    0x1(%rax),%r13
  cmp    %r14,%rbx
  ja     L12
  xor    %eax,%eax
  lea    0x24(%rsp),%rdx
  mov    %r15,%rsi
  mov    %r12,%rdi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L12
  mov    0x24(%rsp),%edi
  xor    %eax,%eax
  sub    %rbx,0x28(%rsp)
  lea    0x14(%rbp),%r12
  call   <S_ISDIR@plt>
  test   %eax,%eax
  jne    L61
  mov    0x24(%rsp),%r8d
  mov    0x10(%rsp),%edx
  xor    %eax,%eax
  mov    %r13,%rcx
  mov    (%rsp),%rsi
  mov    %rbp,%rdi
  call   <read_one_entry@plt>
  test   %eax,%eax
  jns    L25
  jmp    L12
L95:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: label: D7
type_guessed: string

tool: D7: %o

assistant: ```c
int read_tree(unsigned char *sha1, const char *base, int baselen) {
  void *buffer;
  unsigned long size;
  char type[20];
  buffer = read_sha1_file(sha1, type, &size);
  if (!buffer)
    return -1;
  if (strcmp(type, "tree"))
    return -1;
  while (size) {
    int len = strlen(buffer) + 1;
    unsigned char *sha1 = buffer + len;
    char *path = strchr(buffer, ' ') + 1;
    unsigned int mode;
    if (size < len + 20 || sscanf(buffer, "%o", &mode) != 1)
      return -1;
    buffer = sha1 + 20;
    size -= len + 20;
    if (S_ISDIR(mode)) {
      int retval;
      int pathlen = strlen(path);
      char *newbase = malloc(baselen + 1 + pathlen);
      memcpy(newbase, base, baselen);
      memcpy(newbase + baselen, path, pathlen);
      newbase[baselen + pathlen] = '/';
      retval = read_tree(sha1, newbase, baselen + pathlen + 1);
      free(newbase);
      if (retval)
        return -1;
      continue;
    }
    if (read_one_entry(sha1, base, baselen, path, mode) < 0)
      return -1;
  }
  return 0;
}
```