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

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x28(%rbp),%rdx
  lea    -0x30(%rbp),%rsi
  lea    -0x34(%rbp),%rax
  mov    $0x0,%ecx
  mov    %rax,%rdi
  call   <read_mat@plt>
  mov    -0x34(%rbp),%eax
  cltq
  shl    $0x3,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x28(%rbp)
  movl   $0x0,-0x2c(%rbp)
  jmp    L1
L9:
  mov    -0x30(%rbp),%eax
  cltq
  shl    $0x3,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    -0x2c(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x28(%rbp),%rdx
  add    %rcx,%rdx
  mov    %rax,(%rdx)
  addl   $0x1,-0x2c(%rbp)
L1:
  mov    -0x34(%rbp),%eax
  cmp    %eax,-0x2c(%rbp)
  jl     L9
  mov    -0x28(%rbp),%rdx
  lea    -0x30(%rbp),%rsi
  lea    -0x34(%rbp),%rax
  mov    $0x1,%ecx
  mov    %rax,%rdi
  call   <read_mat@plt>
  mov    -0x30(%rbp),%eax
  cltq
  shl    $0x3,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x20(%rbp)
  mov    -0x34(%rbp),%eax
  cltq
  shl    $0x3,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x18(%rbp)
  mov    -0x30(%rbp),%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <read_vector@plt>
  mov    -0x30(%rbp),%esi
  mov    -0x34(%rbp),%eax
  mov    -0x18(%rbp),%rdi
  mov    -0x20(%rbp),%rcx
  mov    -0x28(%rbp),%rdx
  mov    %rdi,%r8
  mov    %eax,%edi
  call   <calc_matrix_vector@plt>
  lea    D1(%rip),%rax
  mov    %rax,%rsi
  lea    D21(%rip),%rax
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x10(%rbp)
  movl   $0x0,-0x2c(%rbp)
  jmp    L14
L55:
  mov    -0x34(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x2c(%rbp)
  jne    L34
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x10(%rbp),%rax
  movq   %rdx,%xmm0
  lea    D22(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fprintf@plt>
  jmp    L5
L34:
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x10(%rbp),%rax
  movq   %rdx,%xmm0
  lea    D20(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fprintf@plt>
L5:
  addl   $0x1,-0x2c(%rbp)
L14:
  mov    -0x34(%rbp),%eax
  cmp    %eax,-0x2c(%rbp)
  jl     L55
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L18
  call   <__stack_chk_fail@plt>
L18:
  leave
  ret
```

tool_calls: name: parse_data
arguments: data_tag: D1
data_type: string
name: parse_data
arguments: data_tag: D21
data_type: string
name: parse_data
arguments: data_tag: D22
data_type: string
name: parse_data
arguments: data_tag: D20
data_type: string

tool: D1: w

tool: D21: output.dat

tool: D22: %f


tool: D20: %f 

assistant: ```c
void main() {
  double **a;
  double *x, *b;
  int i, j, n, m;
  read_mat(&n, &m, a, 0);
  a = (double **)malloc(n * sizeof(double *));
  for (i = 0; i < n; i++) {
    *(a + i) = (double *)malloc(m * sizeof(double));
  }
  read_mat(&n, &m, a, 1);
  x = (double *)malloc(m * sizeof(double));
  b = (double *)malloc(n * sizeof(double));
  read_vector(x, m);
  calc_matrix_vector(n, m, a, x, b);
  FILE *fp;
  fp = fopen("output.dat", "w");
  for (i = 0; i < n; i++) {
    if (i == n - 1) {
      fprintf(fp, "%f\n", b[i]);
    } else {
      fprintf(fp, "%f ", b[i]);
    }
  }
  fclose(fp);
}
```