user: Please show me the C implementation that matches the assembly code listed below:

```asm
<readmessage>:
  endbr64
  push   %r15
  lea    D22(%rip),%r15
  push   %r14
  lea    D28(%rip),%r14
  push   %r13
  mov    %rdi,%r13
  mov    $0x1000,%edi
  push   %r12
  mov    $0x1000,%r12d
  push   %rbp
  push   %rbx
  sub    $0x428,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x418(%rsp)
  xor    %eax,%eax
  lea    0x10(%rsp),%rbx
  call   <malloc@plt>
  movb   $0x0,(%rax)
  mov    %rax,%rbp
  nopl   0x0(%rax)
L75:
  mov    %r13,%rdx
  mov    $0x400,%esi
  mov    %rbx,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  je     L106
  mov    %r14,%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L126
  cmp    $0x4,%r12d
  jle    L12
L50:
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <strcat@plt>
  jmp    L75
L126:
  mov    %rbx,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  je     L46
  lea    -0x1(%rax),%edx
  movslq %edx,%rdx
  cmpb   $0xa,0x10(%rsp,%rdx,1)
  je     L30
L46:
  cmp    %eax,%r12d
  jle    L0
L11:
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <strcat@plt>
  jmp    L75
  nop
L12:
  add    $0x1000,%r12d
  mov    %rbp,%rdi
  mov    %r12d,%esi
  call   <realloc@plt>
  mov    %rax,%rbp
  jmp    L50
  nopw   0x0(%rax,%rax,1)
L106:
  cmp    $0x3,%r12d
  jle    L147
L56:
  mov    %rbp,%rdi
  lea    D32(%rip),%rsi
  call   <strcat@plt>
  mov    %r13,%rdi
  call   <rewind@plt>
  mov    0x418(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L83
  add    $0x428,%rsp
  mov    %rbp,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L0:
  add    $0x1000,%r12d
  mov    %rbp,%rdi
  mov    %r12d,%esi
  call   <realloc@plt>
  mov    %rax,%rbp
  jmp    L11
  nopw   0x0(%rax,%rax,1)
L30:
  lea    -0x1(%r12),%ecx
  cmp    %eax,%ecx
  jle    L131
L70:
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  movb   $0x0,0x10(%rsp,%rdx,1)
  call   <strcat@plt>
  lea    D21(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcat@plt>
  jmp    L75
  nopl   (%rax)
L147:
  mov    %rbp,%rdi
  lea    0x1000(%r12),%esi
  call   <realloc@plt>
  mov    %rax,%rbp
  jmp    L56
  nopl   0x0(%rax,%rax,1)
L131:
  add    $0x1000,%r12d
  mov    %rbp,%rdi
  mov    %rdx,0x8(%rsp)
  mov    %r12d,%esi
  call   <realloc@plt>
  mov    0x8(%rsp),%rdx
  mov    %rax,%rbp
  jmp    L70
L83:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: label: D22
type_guessed: string
name: parse_data
arguments: label: D28
type_guessed: string
name: parse_data
arguments: label: D32
type_guessed: string
name: parse_data
arguments: label: D21
type_guessed: string

tool: D22: ..


tool: D28: .


tool: D32: .


tool: D21: 


assistant: ```c
char *readmessage(FILE *file) {
  char *buffer = malloc(4096);
  ssize_t bufsize = 4096, used = 0;
  char linebuf[1024];
  int i;
  buffer[0] = '\0';
  while (fgets(linebuf, sizeof(linebuf), file)) {
    if (strcmp(linebuf, ".\n") == 0) {
      do {
        if (used + 4 > bufsize - 1) {
          buffer = realloc(buffer, bufsize += 4096);
        }
      } while (0);
      strcat(buffer, "..\r\n");
    } else {
      i = strlen(linebuf);
      if (i && linebuf[i - 1] == '\n') {
        do {
          if (used + i + 1 > bufsize - 1) {
            buffer = realloc(buffer, bufsize += 4096);
          }
        } while (0);
        linebuf[i - 1] = '\0';
        strcat(buffer, linebuf);
        strcat(buffer, "\r\n");
      } else {
        do {
          if (used + i > bufsize - 1) {
            buffer = realloc(buffer, bufsize += 4096);
          }
        } while (0);
        strcat(buffer, linebuf);
      }
    }
  }
  do {
    if (used + 3 > bufsize - 1) {
      buffer = realloc(buffer, bufsize += 4096);
    }
  } while (0);
  strcat(buffer, ".\r\n");
  rewind(file);
  return buffer;
}
```