user: Converte this assembly snippet into its equivalent C code:

```asm
<append_file>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x158,%rsp
  mov    %rdi,-0x148(%rbp)
  mov    %rsi,-0x150(%rbp)
  mov    %rdx,-0x158(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x18(%rbp)
  xor    %eax,%eax
  mov    -0x158(%rbp),%rax
  lea    D2(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x128(%rbp)
  cmpq   $0x0,-0x128(%rbp)
  jne    L299
  mov    -0x158(%rbp),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  jmp    L181
L299:
  mov    -0x148(%rbp),%rax
  mov    (%rax),%rbx
  mov    -0x148(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cltq
  lea    (%rbx,%rax,1),%rdx
  mov    -0x150(%rbp),%rsi
  mov    -0x148(%rbp),%rax
  mov    $0x1,%ecx
  mov    %rax,%rdi
  call   <expand_string@plt>
  mov    %rax,-0x130(%rbp)
  cmpq   $0x0,-0x130(%rbp)
  je     L44
  mov    -0x130(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x130(%rbp)
  movb   $0x28,(%rax)
  jmp    L84
L219:
  lea    -0x120(%rbp),%rax
  mov    %rax,-0x138(%rbp)
  lea    -0x138(%rbp),%rax
  lea    D14(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strsep@plt>
  lea    -0x120(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cltq
  lea    -0x1(%rax),%rdx
  lea    -0x120(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x138(%rbp)
  jmp    L179
L123:
  mov    -0x138(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    %rdx,-0x138(%rbp)
  movb   $0x0,(%rax)
L179:
  mov    -0x138(%rbp),%rdx
  lea    -0x120(%rbp),%rax
  cmp    %rax,%rdx
  jb     L8
  mov    -0x138(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x20,%al
  je     L123
  mov    -0x138(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x9,%al
  je     L123
  mov    -0x138(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0xd,%al
  je     L123
L8:
  mov    -0x138(%rbp),%rdx
  lea    -0x120(%rbp),%rax
  cmp    %rax,%rdx
  jae    L301
  jmp    L84
L301:
  lea    -0x120(%rbp),%rax
  mov    %rax,-0x138(%rbp)
  jmp    L55
L287:
  mov    -0x138(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,-0x138(%rbp)
L55:
  mov    -0x138(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x20,%al
  je     L287
  mov    -0x138(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x9,%al
  je     L287
  mov    -0x138(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0xd,%al
  je     L287
  mov    -0x138(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0xa,%al
  je     L287
  mov    -0x138(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L156
  jmp    L84
L156:
  mov    -0x138(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  add    %eax,%eax
  lea    0x1(%rax),%ecx
  mov    -0x130(%rbp),%rdx
  mov    -0x150(%rbp),%rsi
  mov    -0x148(%rbp),%rax
  mov    %rax,%rdi
  call   <expand_string@plt>
  mov    %rax,-0x130(%rbp)
  cmpq   $0x0,-0x130(%rbp)
  je     L110
  jmp    L250
L309:
  mov    -0x138(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2e,%al
  jne    L162
  mov    -0x130(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x130(%rbp)
  movb   $0x5c,(%rax)
  mov    -0x130(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x130(%rbp)
  movb   $0x2e,(%rax)
  jmp    L163
L162:
  mov    -0x138(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x3f,%al
  jne    L169
  mov    -0x130(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x130(%rbp)
  movb   $0x2e,(%rax)
  jmp    L163
L169:
  mov    -0x138(%rbp),%rdx
  mov    -0x130(%rbp),%rax
  lea    0x1(%rax),%rcx
  mov    %rcx,-0x130(%rbp)
  movzbl (%rdx),%edx
  mov    %dl,(%rax)
L163:
  mov    -0x138(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,-0x138(%rbp)
L250:
  mov    -0x138(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L309
  mov    -0x130(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x130(%rbp)
  movb   $0x7c,(%rax)
  mov    -0x130(%rbp),%rax
  movb   $0x0,(%rax)
L84:
  mov    -0x128(%rbp),%rdx
  lea    -0x120(%rbp),%rax
  mov    $0x100,%esi
  mov    %rax,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  jne    L219
  mov    -0x130(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x28,%al
  jne    L17
  subq   $0x1,-0x130(%rbp)
  mov    -0x130(%rbp),%rax
  movb   $0x0,(%rax)
  jmp    L304
L17:
  mov    -0x130(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x7c,%al
  jne    L304
  mov    -0x130(%rbp),%rax
  sub    $0x1,%rax
  movb   $0x29,(%rax)
L304:
  mov    -0x128(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  jmp    L181
L44:
  nop
  jmp    L181
L110:
  nop
L181:
  mov    -0x18(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L249
  call   <__stack_chk_fail@plt>
L249:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: parse_data
arguments: data_tag: D2
type_infered: string
name: parse_data
arguments: data_tag: D14
type_infered: string

tool: D2: r

tool: D14: #


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);
}
```