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

```asm
<matNd_print_to_string>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %ecx,-0x30(%rbp)
  movl   $0x0,-0x14(%rbp)
  mov    -0x2c(%rbp),%eax
  sub    -0x14(%rbp),%eax
  mov    -0x14(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x28(%rbp),%rdx
  lea    (%rcx,%rdx,1),%rdi
  mov    -0x30(%rbp),%edx
  mov    %edx,%ecx
  lea    D48(%rip),%rdx
  mov    %eax,%esi
  mov    $0x0,%eax
  call   <snprintf@plt>
  mov    %eax,%edx
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x14(%rbp)
  movl   $0x0,-0x10(%rbp)
  jmp    L34
L21:
  cmpl   $0x0,-0x10(%rbp)
  jle    L11
  mov    -0x2c(%rbp),%eax
  sub    -0x14(%rbp),%eax
  mov    -0x14(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x28(%rbp),%rdx
  add    %rdx,%rcx
  lea    D33(%rip),%rdx
  mov    %eax,%esi
  mov    %rcx,%rdi
  mov    $0x0,%eax
  call   <snprintf@plt>
  mov    %eax,%edx
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x14(%rbp)
L11:
  movl   $0x0,-0xc(%rbp)
  jmp    L19
L58:
  mov    -0x30(%rbp),%edx
  mov    -0xc(%rbp),%ecx
  mov    -0x10(%rbp),%eax
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <matN_getIndex@plt>
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x2c(%rbp),%eax
  sub    -0x14(%rbp),%eax
  mov    -0x14(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x28(%rbp),%rdx
  add    %rdx,%rcx
  mov    -0x8(%rbp),%rdx
  movq   %rdx,%xmm0
  lea    D5(%rip),%rdx
  mov    %eax,%esi
  mov    %rcx,%rdi
  mov    $0x1,%eax
  call   <snprintf@plt>
  mov    %eax,%edx
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x14(%rbp)
  addl   $0x1,-0xc(%rbp)
L19:
  mov    -0xc(%rbp),%eax
  cmp    -0x30(%rbp),%eax
  jl     L58
  mov    -0x2c(%rbp),%eax
  sub    -0x14(%rbp),%eax
  mov    -0x14(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x28(%rbp),%rdx
  add    %rdx,%rcx
  lea    D37(%rip),%rdx
  mov    %eax,%esi
  mov    %rcx,%rdi
  mov    $0x0,%eax
  call   <snprintf@plt>
  mov    %eax,%edx
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x30(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x10(%rbp)
  jge    L28
  mov    -0x2c(%rbp),%eax
  sub    -0x14(%rbp),%eax
  mov    -0x14(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x28(%rbp),%rdx
  add    %rdx,%rcx
  lea    D42(%rip),%rdx
  mov    %eax,%esi
  mov    %rcx,%rdi
  mov    $0x0,%eax
  call   <snprintf@plt>
  mov    %eax,%edx
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x14(%rbp)
L28:
  addl   $0x1,-0x10(%rbp)
L34:
  mov    -0x10(%rbp),%eax
  cmp    -0x30(%rbp),%eax
  jl     L21
  nop
  nop
  leave
  ret
```

tool_calls: name: read_data
arguments: tag: D48
datatype: string
name: read_data
arguments: tag: D33
datatype: string
name: read_data
arguments: tag: D5
datatype: string
name: read_data
arguments: tag: D37
datatype: string
name: read_data
arguments: tag: D42
datatype: string

tool: D48: mat%dd [ 

tool: D33:       [ 

tool: D5: %10.3f 

tool: D37: ]

tool: D42: 


assistant: ```c
void matNd_print_to_string(char *dest, const int destSize, const double m[], const int n) {
  int used = 0;
  used += snprintf(dest + used, destSize - used, "mat%dd [ ", n);
  for (int i = 0; i < n; i++) {
    if (i > 0)
      used += snprintf(dest + used, destSize - used, "      [ ");
    for (int j = 0; j < n; j++) {
      double tmp = m[matN_getIndex(i, j, n)];
      used += snprintf(dest + used, destSize - used, "%10.3f ", tmp);
    }
    used += snprintf(dest + used, destSize - used, "]");
    if (i < n - 1)
      used += snprintf(dest + used, destSize - used, "\n");
  }
}
```