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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x168,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x158(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rdi
  lea    D8(%rip),%rsi
  mov    $0x2a,%ecx
  rep movsq %ds:(%rsi),%es:(%rdi)
  mov    (%rsi),%eax
  mov    %eax,(%rdi)
  movzwl D16(%rip),%eax
  mov    %ax,0x4(%rdi)
  movzbl D9(%rip),%eax
  mov    %al,0x6(%rdi)
  mov    $0x7f8,%edi
  call   <malloc@plt>
  mov    %rax,%r14
  mov    $0xff,%edi
  call   <malloc@plt>
  mov    %rax,(%r14)
  movzbl (%rsp),%edx
  test   %dl,%dl
  je     L169
  mov    $0x0,%eax
  mov    $0x0,%ebx
  mov    $0x0,%r12d
  movabs $0x8000400200000000,%r15
  jmp    L205
L118:
  lea    0x2(%rbx),%ecx
  movslq %ecx,%rsi
  cmpb   $0x2e,(%rsp,%rsi,1)
  je     L146
  movslq %ebx,%rcx
  movzbl (%rsp,%rcx,1),%ecx
  cmp    $0xa,%cl
  sete   %sil
  test   %eax,%eax
  jne    L110
  test   %sil,%sil
  je     L110
  mov    %r8d,%ebx
  mov    $0x0,%eax
  jmp    L205
L146:
  lea    0x1(%rax),%edx
  movslq %edx,%rdx
  movb   $0x2e,(%rdi,%rdx,1)
  add    $0x2,%eax
  movslq %eax,%rdx
  movb   $0x2e,(%rdi,%rdx,1)
  mov    %ecx,%ebx
  jmp    L82
L31:
  movslq %eax,%rdx
  movb   $0x0,(%rdi,%rdx,1)
L108:
  add    $0x1,%eax
  movslq %eax,%rsi
  call   <realloc@plt>
  mov    %rax,0x0(%r13)
  add    $0x1,%r12d
  mov    $0xff,%edi
  call   <malloc@plt>
  mov    %rax,0x8(%r14,%rbp,1)
  mov    $0xffffffff,%eax
L52:
  add    $0x1,%ebx
  add    $0x1,%eax
  movslq %ebx,%rdx
  movzbl (%rsp,%rdx,1),%edx
  test   %dl,%dl
  je     L168
L205:
  movslq %r12d,%rbp
  shl    $0x3,%rbp
  lea    (%r14,%rbp,1),%r13
  mov    0x0(%r13),%rdi
  movslq %eax,%rcx
  mov    %dl,(%rdi,%rcx,1)
  cmp    $0xa,%dl
  je     L27
  cmp    $0x3f,%dl
  ja     L52
  bt     %rdx,%r15
  jae    L52
  cmp    $0x2e,%dl
  jne    L27
  lea    0x1(%rbx),%r8d
  movslq %r8d,%rdx
  movzbl (%rsp,%rdx,1),%edx
  cmp    $0x2e,%dl
  je     L118
L27:
  movslq %ebx,%rdx
  movzbl (%rsp,%rdx,1),%ecx
  cmp    $0xa,%cl
  sete   %sil
  test   %eax,%eax
  jne    L110
  test   %sil,%sil
  jne    L154
L110:
  test   %cl,%cl
  je     L31
  test   %sil,%sil
  jne    L31
L82:
  add    $0x1,%eax
  movslq %eax,%rdx
  movb   $0x0,(%rdi,%rdx,1)
  add    $0x1,%ebx
  jmp    L108
L154:
  mov    $0xffffffff,%eax
  jmp    L52
L168:
  movslq %r12d,%rsi
  shl    $0x3,%rsi
  mov    %r14,%rdi
  call   <realloc@plt>
  test   %r12d,%r12d
  jle    L116
  mov    %rax,%rbx
  mov    %r12d,%r12d
  lea    (%rax,%r12,8),%rbp
L23:
  mov    (%rbx),%rdi
  call   <puts@plt>
  add    $0x8,%rbx
  cmp    %rbx,%rbp
  jne    L23
L116:
  mov    0x158(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L62
  mov    $0x0,%eax
  add    $0x168,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L169:
  mov    $0x0,%esi
  mov    %r14,%rdi
  call   <realloc@plt>
  jmp    L116
L62:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_label: D8
type_guessed: string
name: read_data
arguments: data_label: D16
type_guessed: byte[2]
name: read_data
arguments: data_label: D9
type_guessed: byte

tool: D8: 
Utilizador 1 --> Bom dia! Tudo bem contigo?

Utilizador 2 --> Comigo tudo excelente. Que tens feito?
Utilizador 1 --> De momento estou a trabalhar num projeto... E tu?
Utilizador 2 --> Eu tenho estudado uma nova linguagem, Java. Bastante interessante. Devias experimentar.
Utilizador 2 --> Talvez experimente quando tiver algum tempo livre!


tool: {"D16": [0x21,0x0a]}

tool: D9: 0

assistant: ```c
int main() {
  char str[] = "\nUtilizador 1 --> Bom dia! Tudo bem contigo?\n\nUtilizador 2 --> Comigo tudo excelente. Que tens feito?\nUtilizador 1 --> De momento estou a trabalhar num projeto... E tu?\nUtilizador 2 --> Eu tenho estudado uma nova linguagem, Java. Bastante interessante. Devias experimentar.\nUtilizador 2 --> Talvez experimente quando tiver algum tempo livre!\n";
  char **matriz = malloc(sizeof(char *) * 255);
  int linha = 0;
  matriz[linha] = malloc(255);
  for (int caractere = 0, coluna = 0; str[caractere] != '\0'; caractere++, coluna++) {
    matriz[linha][coluna] = str[caractere];
    if (str[caractere] == '\n' || str[caractere] == '\0' || str[caractere] == '.' || str[caractere] == '!' || str[caractere] == '?') {
      if (str[caractere] == '.' && str[caractere + 1] == '.' && str[caractere + 2] == '.') {
        matriz[linha][++coluna] = str[++caractere];
        matriz[linha][++coluna] = str[++caractere];
      }
      if (str[caractere] == '\n' && coluna == 0) {
        coluna = -1;
        continue;
      }
      if (str[caractere] == '\n' || str[caractere] == '\0') {
        matriz[linha][coluna] = '\0';
      } else {
        matriz[linha][++coluna] = '\0';
        caractere++;
      }
      matriz[linha] = realloc(matriz[linha], coluna + 1);
      matriz[++linha] = malloc(255);
      coluna = -1;
    }
  }
  matriz = realloc(matriz, sizeof(char *) * linha);
  for (int i = 0; i < linha; i++) {
    printf("%s\n", matriz[i]);
  }
}
```