user: What is the c source code of the assembly code below?

```asm
<least_squares>:
  endbr64
  push   %rbx
  sub    $0x40,%rsp
  mov    %edi,0xc(%rsp)
  mov    %esi,%ecx
  mov    %esi,0x8(%rsp)
  mov    %rdx,%rbx
  mov    %fs:0x28,%rdx
  mov    %rdx,0x38(%rsp)
  xor    %edx,%edx
  test   %edi,%edi
  setle  %dl
  test   %esi,%esi
  setle  %sil
  or     %sil,%dl
  jne    L129
  mov    %edi,%eax
  cmp    %ecx,%edi
  jl     L129
  imul   %edi,%eax
  mov    %eax,0x1c(%rsp)
  lea    0x20(%rsp),%rdi
  mov    %eax,%esi
  call   <allocate_double_vector@plt>
  test   %eax,%eax
  je     L153
  movb   $0x4e,0x17(%rsp)
  lea    0x28(%rsp),%rdi
  mov    0xc(%rsp),%edx
  mov    0x8(%rsp),%esi
  call   <allocate_double_matrix@plt>
  test   %eax,%eax
  je     L182
  mov    0xc(%rsp),%eax
  mov    $0x0,%esi
  test   %eax,%eax
  jg     L252
L46:
  lea    0x30(%rsp),%rdi
  mov    %eax,%edx
  mov    %eax,%esi
  call   <allocate_double_matrix@plt>
  test   %eax,%eax
  je     L131
  mov    $0x0,%ecx
  movsd  D4(%rip),%xmm1
  pxor   %xmm2,%xmm2
  cmpl   $0x0,0xc(%rsp)
  jg     L67
L229:
  lea    0xc(%rsp),%rsi
  lea    0x8(%rsp),%rdx
  lea    0x17(%rsp),%rdi
  sub    $0x8,%rsp
  lea    0x20(%rsp),%rax
  push   %rax
  lea    0x2c(%rsp),%rax
  push   %rax
  push   0x38(%rsp)
  push   %rsi
  mov    0x58(%rsp),%rax
  push   (%rax)
  mov    %rsi,%r9
  mov    0x58(%rsp),%rax
  mov    (%rax),%r8
  mov    %rsi,%rcx
  call   <dgels_@plt>
  add    $0x30,%rsp
  cmpl   $0x0,0x8(%rsp)
  jle    L2
  mov    %rbx,%rdx
  mov    $0x0,%edi
  jmp    L39
L105:
  mov    (%rbx,%rax,8),%rcx
  movsd  (%rcx,%rdx,1),%xmm0
  mov    0x28(%rsp),%rcx
  mov    (%rcx,%rax,8),%rcx
  movsd  %xmm0,(%rcx,%rdx,1)
  add    $0x1,%rax
  cmp    %eax,0x8(%rsp)
  jg     L105
L18:
  mov    0xc(%rsp),%eax
  add    $0x1,%rsi
  cmp    %esi,%eax
  jle    L46
L252:
  lea    0x0(,%rsi,8),%rdx
  mov    $0x0,%eax
  cmpl   $0x0,0x8(%rsp)
  jg     L105
  jmp    L18
L73:
  mov    0x30(%rsp),%rdx
  mov    (%rdx,%rsi,1),%rdx
  movsd  %xmm0,(%rdx,%rax,8)
  add    $0x1,%rax
  cmp    %eax,0xc(%rsp)
  jle    L237
L75:
  movapd %xmm1,%xmm0
  cmp    %ecx,%eax
  je     L73
  movapd %xmm2,%xmm0
  jmp    L73
L237:
  add    $0x1,%rcx
  cmp    %ecx,0xc(%rsp)
  jle    L229
L67:
  lea    0x0(,%rcx,8),%rsi
  mov    $0x0,%eax
  cmpl   $0x0,0xc(%rsp)
  jg     L75
  jmp    L237
L244:
  add    $0x1,%rdi
  add    $0x8,%rdx
  cmp    %edi,0x8(%rsp)
  jle    L2
L39:
  lea    0x0(,%rdi,8),%rsi
  mov    $0x0,%eax
  cmpl   $0x0,0xc(%rsp)
  jle    L244
L45:
  mov    0x30(%rsp),%rcx
  mov    (%rcx,%rax,8),%rcx
  movsd  (%rcx,%rsi,1),%xmm0
  mov    (%rdx),%rcx
  movsd  %xmm0,(%rcx,%rax,8)
  add    $0x1,%rax
  cmp    %eax,0xc(%rsp)
  jg     L45
  jmp    L244
L2:
  mov    0x28(%rsp),%rdi
  call   <free_matrix@plt>
  mov    0x30(%rsp),%rdi
  call   <free_matrix@plt>
  mov    0x20(%rsp),%rdi
  call   <free_vector@plt>
  mov    $0x1,%eax
L9:
  mov    0x38(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L112
  add    $0x40,%rsp
  pop    %rbx
  ret
L129:
  mov    $0xfffffffe,%eax
  jmp    L9
L153:
  mov    $0xffffffff,%eax
  jmp    L9
L182:
  mov    $0xffffffff,%eax
  jmp    L9
L131:
  mov    $0xffffffff,%eax
  jmp    L9
L112:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: label: D4
type_guessed: byte[8]

tool: {"D4": [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;
}
```