user: 请从给定的汇编指令推导出C源代码：

```asm
<read_tree>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %rsi,0x8(%rsp)
  mov    %edx,0x10(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  lea    0x28(%rsp),%rdx
  lea    0x30(%rsp),%rsi
  call   <read_sha1_file@plt>
  test   %eax,%eax
  je     L123
  movslq %eax,%r12
  lea    0x30(%rsp),%rdi
  lea    D15(%rip),%rsi
  call   <strcmp@plt>
  mov    %eax,0x14(%rsp)
  test   %eax,%eax
  jne    L27
  mov    0x28(%rsp),%r14
  test   %r14,%r14
  je     L106
  lea    D4(%rip),%r15
  jmp    L12
L93:
  mov    0x24(%rsp),%r8d
  mov    %r13,%rcx
  mov    0x10(%rsp),%edx
  mov    0x8(%rsp),%rsi
  mov    %rbp,%rdi
  mov    $0x0,%eax
  call   <read_one_entry@plt>
  test   %eax,%eax
  js     L117
L21:
  mov    0x28(%rsp),%r14
  test   %r14,%r14
  je     L106
L12:
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    %rax,%rbx
  lea    0x1(%rax),%ebp
  movslq %ebp,%rbp
  add    %r12,%rbp
  mov    $0x20,%esi
  mov    %r12,%rdi
  call   <strchr@plt>
  lea    0x1(%rax),%r13
  add    $0x15,%ebx
  movslq %ebx,%rbx
  cmp    %r14,%rbx
  ja     L117
  lea    0x24(%rsp),%rdx
  mov    %r15,%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L117
  lea    0x14(%rbp),%r12
  sub    %rbx,0x28(%rsp)
  mov    0x24(%rsp),%edi
  mov    $0x0,%eax
  call   <S_ISDIR@plt>
  test   %eax,%eax
  je     L93
  mov    %r13,%rdi
  call   <strlen@plt>
  mov    %rax,%rbx
  mov    0x10(%rsp),%eax
  lea    0x1(%rax,%rbx,1),%edi
  movslq %edi,%rdi
  call   <malloc@plt>
  mov    %rax,%r14
  movslq 0x10(%rsp),%rcx
  mov    %rcx,0x18(%rsp)
  mov    %rcx,%rdx
  mov    0x8(%rsp),%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    0x18(%rsp),%rcx
  lea    (%r14,%rcx,1),%rdi
  movslq %ebx,%rdx
  mov    %r13,%rsi
  call   <memcpy@plt>
  mov    0x10(%rsp),%eax
  lea    (%rax,%rbx,1),%edx
  movslq %edx,%rax
  movb   $0x2f,(%r14,%rax,1)
  add    $0x1,%edx
  mov    %r14,%rsi
  mov    %rbp,%rdi
  call   <read_tree>
  mov    %eax,%ebx
  mov    %r14,%rdi
  call   <free@plt>
  test   %ebx,%ebx
  je     L21
L117:
  movl   $0xffffffff,0x14(%rsp)
L106:
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L74
  mov    0x14(%rsp),%eax
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L123:
  movl   $0xffffffff,0x14(%rsp)
  jmp    L106
L27:
  movl   $0xffffffff,0x14(%rsp)
  jmp    L106
L74:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: tag: D15
type: string
name: read_data
arguments: tag: D4
type: string

tool: D15: tree

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