user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<least_squares>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %edi,-0x44(%rbp)
  mov    %esi,-0x48(%rbp)
  mov    %rdx,-0x50(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x44(%rbp),%eax
  test   %eax,%eax
  jle    L35
  mov    -0x48(%rbp),%eax
  test   %eax,%eax
  jle    L35
  mov    -0x48(%rbp),%edx
  mov    -0x44(%rbp),%eax
  cmp    %eax,%edx
  jle    L238
L35:
  mov    $0xfffffffe,%eax
  jmp    L142
L238:
  mov    -0x44(%rbp),%edx
  mov    -0x44(%rbp),%eax
  imul   %edx,%eax
  mov    %eax,-0x2c(%rbp)
  mov    -0x2c(%rbp),%edx
  lea    -0x20(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <allocate_double_vector@plt>
  test   %eax,%eax
  jne    L11
  mov    $0xffffffff,%eax
  jmp    L142
L11:
  movb   $0x4e,-0x31(%rbp)
  mov    -0x44(%rbp),%edx
  mov    -0x48(%rbp),%ecx
  lea    -0x18(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <allocate_double_matrix@plt>
  test   %eax,%eax
  jne    L120
  mov    $0xffffffff,%eax
  jmp    L142
L120:
  movl   $0x0,-0x28(%rbp)
  jmp    L58
L174:
  movl   $0x0,-0x24(%rbp)
  jmp    L90
L44:
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x28(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rax,%rdx
  mov    -0x18(%rbp),%rcx
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rcx,%rax
  mov    (%rax),%rcx
  mov    -0x28(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rcx,%rax
  movsd  (%rdx),%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x24(%rbp)
L90:
  mov    -0x48(%rbp),%eax
  cmp    %eax,-0x24(%rbp)
  jl     L44
  addl   $0x1,-0x28(%rbp)
L58:
  mov    -0x44(%rbp),%eax
  cmp    %eax,-0x28(%rbp)
  jl     L174
  mov    -0x44(%rbp),%edx
  mov    -0x44(%rbp),%ecx
  lea    -0x10(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <allocate_double_matrix@plt>
  test   %eax,%eax
  jne    L0
  mov    $0xffffffff,%eax
  jmp    L142
L0:
  movl   $0x0,-0x28(%rbp)
  jmp    L137
L115:
  movl   $0x0,-0x24(%rbp)
  jmp    L226
L202:
  mov    -0x28(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jne    L63
  movsd  D1(%rip),%xmm0
  jmp    L106
L63:
  pxor   %xmm0,%xmm0
L106:
  mov    -0x10(%rbp),%rdx
  mov    -0x28(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x24(%rbp)
L226:
  mov    -0x44(%rbp),%eax
  cmp    %eax,-0x24(%rbp)
  jl     L202
  addl   $0x1,-0x28(%rbp)
L137:
  mov    -0x44(%rbp),%eax
  cmp    %eax,-0x28(%rbp)
  jl     L115
  mov    -0x20(%rbp),%r8
  mov    -0x10(%rbp),%rax
  mov    (%rax),%rdi
  mov    -0x18(%rbp),%rax
  mov    (%rax),%r10
  lea    -0x44(%rbp),%r11
  lea    -0x44(%rbp),%rcx
  lea    -0x48(%rbp),%rdx
  lea    -0x44(%rbp),%rsi
  lea    -0x31(%rbp),%rax
  sub    $0x8,%rsp
  lea    -0x30(%rbp),%r9
  push   %r9
  lea    -0x2c(%rbp),%r9
  push   %r9
  push   %r8
  lea    -0x44(%rbp),%r8
  push   %r8
  push   %rdi
  mov    %r11,%r9
  mov    %r10,%r8
  mov    %rax,%rdi
  call   <dgels_@plt>
  add    $0x30,%rsp
  movl   $0x0,-0x28(%rbp)
  jmp    L146
L162:
  movl   $0x0,-0x24(%rbp)
  jmp    L6
L30:
  mov    -0x10(%rbp),%rdx
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x28(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rax,%rdx
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x50(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rcx
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rcx,%rax
  movsd  (%rdx),%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x24(%rbp)
L6:
  mov    -0x44(%rbp),%eax
  cmp    %eax,-0x24(%rbp)
  jl     L30
  addl   $0x1,-0x28(%rbp)
L146:
  mov    -0x48(%rbp),%eax
  cmp    %eax,-0x28(%rbp)
  jl     L162
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <free_matrix@plt>
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free_matrix@plt>
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free_vector@plt>
  mov    $0x1,%eax
L142:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L119
  call   <__stack_chk_fail@plt>
L119:
  leave
  ret
```

tool_calls: name: read_data
arguments: label: D1
data_type: byte[8]

tool: {"D1": [0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x3f]}

assistant: ```c
int least_squares(int m, int n, double **matrix) {
  if (m < 1 || n < 1 || n > m)
    return -2;
  int i, j;
  int info, lwork = m * m;
  double *work;
  if (!allocate_double_vector(&work, lwork)) {
    return -1;
  }
  char transa = 'N';
  double **a_matrix;
  if (!allocate_double_matrix(&a_matrix, n, m)) {
    return -1;
  }
  for (i = 0; i < m; i++)
    for (j = 0; j < n; j++)
      a_matrix[j][i] = matrix[j][i];
  double **b_matrix;
  if (!allocate_double_matrix(&b_matrix, m, m)) {
    return -1;
  }
  for (i = 0; i < m; i++)
    for (j = 0; j < m; j++)
      b_matrix[i][j] = (i == j);
  dgels_(&transa, &m, &n, &m, a_matrix[0], &m, b_matrix[0], &m, work, &lwork, &info);
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      matrix[i][j] = b_matrix[j][i];
  free_matrix((void **)a_matrix);
  free_matrix((void **)b_matrix);
  free_vector(work);
  return 1;
}
```