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

```asm
<append_file>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x138,%rsp
  mov    %rdi,%r14
  mov    %rsi,0x8(%rsp)
  mov    %rdx,%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x128(%rsp)
  xor    %eax,%eax
  lea    D17(%rip),%rsi
  mov    %rdx,%rdi
  call   <fopen@plt>
  test   %rax,%rax
  je     L7
  mov    %rax,%r12
  mov    (%r14),%rbx
  mov    %rbx,%rdi
  call   <strlen@plt>
  cltq
  lea    (%rbx,%rax,1),%rdx
  mov    $0x1,%ecx
  mov    0x8(%rsp),%rsi
  mov    %r14,%rdi
  call   <expand_string@plt>
  test   %rax,%rax
  je     L86
  lea    0x1(%rax),%r15
  movb   $0x28,(%rax)
  lea    D11(%rip),%r13
  movabs $0x100002600,%rbp
  jmp    L165
L7:
  mov    %rbx,%rdi
  call   <perror@plt>
  jmp    L86
L22:
  lea    -0x1(%rax),%rdx
  mov    %rdx,0x18(%rsp)
  movb   $0x0,(%rax)
  mov    0x18(%rsp),%rax
  cmp    %rbx,%rax
  jb     L6
L280:
  movzbl (%rax),%edx
  mov    %edx,%ecx
  and    $0xfffffffb,%ecx
  cmp    $0x9,%cl
  je     L22
  cmp    $0x20,%dl
  je     L22
  cmp    %rbx,%rax
  jb     L6
  mov    %rbx,0x18(%rsp)
  movzbl 0x20(%rsp),%edx
  mov    %rbx,%rdi
  cmp    $0x20,%dl
  ja     L186
  bt     %rdx,%rbp
  jae    L186
  lea    0x21(%rsp),%rax
  jmp    L287
L202:
  add    $0x1,%rax
  bt     %rdx,%rbp
  jae    L186
L287:
  mov    %rax,%rdi
  mov    %rax,0x18(%rsp)
  movzbl (%rax),%edx
  cmp    $0x20,%dl
  jbe    L202
L186:
  test   %dl,%dl
  jne    L105
L6:
  mov    %r12,%rdx
  mov    $0x100,%esi
  mov    %rbx,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  je     L67
  mov    %rbx,0x18(%rsp)
  lea    0x18(%rsp),%rdi
  mov    %r13,%rsi
  call   <strsep@plt>
  mov    %rbx,%rdi
  call   <strlen@plt>
  cltq
  lea    -0x1(%rbx,%rax,1),%rax
  mov    %rax,0x18(%rsp)
  cmp    %rbx,%rax
  jae    L280
  jmp    L6
L105:
  call   <strlen@plt>
  lea    0x1(%rax,%rax,1),%ecx
  mov    %r15,%rdx
  mov    0x8(%rsp),%rsi
  mov    %r14,%rdi
  call   <expand_string@plt>
  test   %rax,%rax
  je     L86
  mov    0x18(%rsp),%rdx
  movzbl (%rdx),%edx
  test   %dl,%dl
  jne    L76
L296:
  lea    0x1(%rax),%r15
  movb   $0x7c,(%rax)
  movb   $0x0,0x1(%rax)
L165:
  lea    0x20(%rsp),%rbx
  jmp    L6
L212:
  movb   $0x5c,(%rax)
  movb   $0x2e,0x1(%rax)
  lea    0x2(%rax),%rax
  jmp    L248
L93:
  mov    %dl,(%rax)
  lea    0x1(%rax),%rax
L248:
  mov    0x18(%rsp),%rdx
  lea    0x1(%rdx),%rcx
  mov    %rcx,0x18(%rsp)
  movzbl 0x1(%rdx),%edx
  test   %dl,%dl
  je     L296
L76:
  cmp    $0x2e,%dl
  je     L212
  cmp    $0x3f,%dl
  jne    L93
  movb   $0x2e,(%rax)
  lea    0x1(%rax),%rax
  jmp    L248
L67:
  movzbl -0x1(%r15),%eax
  cmp    $0x28,%al
  je     L236
  cmp    $0x7c,%al
  je     L10
L101:
  mov    %r12,%rdi
  call   <fclose@plt>
L86:
  mov    0x128(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L117
  add    $0x138,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L236:
  movb   $0x0,-0x1(%r15)
  jmp    L101
L10:
  movb   $0x29,-0x1(%r15)
  jmp    L101
L117:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: tag: D17
datatype: string
name: unpack_data
arguments: tag: D11
datatype: string

tool: D17: r

tool: D11: #


assistant: ```c
void append_file(char **dst, int *len, char *filename) {
  FILE *fd;
  char line[256], *p, *tail;
  fd = fopen(filename, "r");
  if (!fd) {
    perror(filename);
    return;
  }
  tail = expand_string(dst, len, *dst + strlen(*dst), 1);
  if (!tail)
    return;
  *tail++ = '(';
  while (fgets(line, sizeof(line), fd)) {
    p = line;
    strsep(&p, "#\n");
    p = line + strlen(line) - 1;
    while (p >= line && (*p == ' ' || *p == '\t' || *p == '\r'))
      *p-- = 0;
    if (p < line)
      continue;
    p = line;
    while (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n')
      ++p;
    if (*p == 0)
      continue;
    tail = expand_string(dst, len, tail, 2 * strlen(p) + 1);
    if (!tail)
      return;
    for (; *p; ++p) {
      if (*p == '.') {
        *tail++ = '\\';
        *tail++ = '.';
      } else if (*p == '?')
        *tail++ = '.';
      else
        *tail++ = *p;
    }
    *tail++ = '|';
    *tail = 0;
  }
  if (*(tail - 1) == '(')
    *--tail = 0;
  else if (*(tail - 1) == '|')
    *(tail - 1) = ')';
  fclose(fd);
}
```