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

```asm
<svd_lsq>:
  endbr64
  push   %r15
  mov    %r8,%r15
  push   %r14
  mov    %edx,%r14d
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %rcx,%rbp
  push   %rbx
  movslq %esi,%rbx
  lea    (%rbx,%rdx,1),%esi
  mov    %ebx,%edi
  mov    $0x8,%edx
  mov    %rbx,%r13
  sub    $0x48,%rsp
  mov    0x80(%rsp),%rax
  mov    %r9,0x8(%rsp)
  mov    %rax,0x10(%rsp)
  call   <alloc2d@plt>
  cmp    %r14d,%r13d
  mov    %rbx,0x18(%rsp)
  mov    0x8(%rsp),%rcx
  mov    %rax,(%rsp)
  lea    (%rax,%rbx,8),%rbx
  mov    %r14d,%eax
  cmovle %r13d,%eax
  test   %r15,%r15
  mov    %eax,0x30(%rsp)
  je     L209
  test   %r14d,%r14d
  jle    L209
  mov    %r13d,%eax
  mov    %r13d,%r11d
  mov    %rbx,0x28(%rsp)
  movslq %r14d,%rsi
  and    $0xfffffffe,%r11d
  mov    %r14d,0x34(%rsp)
  mov    %r15,%rdi
  xor    %r8d,%r8d
  lea    0x0(,%rax,8),%r9
  mov    %r13d,%eax
  movslq %r11d,%r10
  mov    %rcx,0x38(%rsp)
  shr    %eax
  shl    $0x3,%r10
  mov    %r9,%rbx
  mov    %r11d,%ecx
  lea    -0x1(%rax),%edx
  lea    -0x1(%r13),%eax
  mov    %eax,0x8(%rsp)
  lea    0x8(,%rax,8),%rax
  mov    %rax,0x20(%rsp)
  lea    0x1(%rdx),%rax
  shl    $0x4,%rax
  mov    %rax,%r14
L143:
  movsd  0x0(%rbp,%r8,8),%xmm0
  divsd  (%rdi),%xmm0
  movsd  %xmm0,0x0(%rbp,%r8,8)
  test   %r13d,%r13d
  jle    L291
  mov    (%r12,%r8,8),%rax
  lea    0x8(%rdi),%r11
  lea    (%rax,%rbx,1),%rdx
  cmp    %rdx,%rdi
  setae  %r9b
  cmp    %r11,%rax
  setae  %dl
  or     %r9b,%dl
  je     L12
  cmp    $0x1,%r13d
  je     L12
  movsd  (%rdi),%xmm1
  mov    %rax,%rdx
  lea    (%r14,%rax,1),%r9
  unpcklpd %xmm1,%xmm1
  nopl   0x0(%rax)
L215:
  movupd (%rdx),%xmm0
  add    $0x10,%rdx
  divpd  %xmm1,%xmm0
  movups %xmm0,-0x10(%rdx)
  cmp    %r9,%rdx
  jne    L215
  cmp    %r13d,%ecx
  je     L325
  add    %r10,%rax
  movsd  (%rax),%xmm0
  divsd  (%rdi),%xmm0
  movsd  %xmm0,(%rax)
L325:
  add    $0x1,%r8
  mov    %r11,%rdi
  cmp    %rsi,%r8
  jne    L143
  mov    0x34(%rsp),%r14d
  mov    0x38(%rsp),%rcx
  mov    %r13d,%esi
  mov    %r12,%rdi
  mov    (%rsp),%r8
  mov    0x28(%rsp),%rbx
  mov    %r14d,%edx
  mov    %rcx,0x20(%rsp)
  call   <svd@plt>
  test   %r13d,%r13d
  mov    0x20(%rsp),%rcx
  jle    L288
L159:
  mov    0x30(%rsp),%eax
  pxor   %xmm2,%xmm2
  test   %eax,%eax
  jle    L328
  mov    (%rsp),%rax
  mov    %r13d,%r13d
  movslq 0x30(%rsp),%rdi
  pxor   %xmm2,%xmm2
  mov    %rax,%rdx
  lea    (%rax,%r13,8),%rsi
  nopl   0x0(%rax)
L246:
  mov    (%rdx),%r8
  xor    %eax,%eax
  nopl   (%rax)
L45:
  movsd  (%rcx,%rax,8),%xmm0
  ucomisd %xmm2,%xmm0
  jp     L298
  je     L115
L298:
  movsd  (%r8,%rax,8),%xmm1
  divsd  %xmm0,%xmm1
  movsd  %xmm1,(%r8,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%rdi
  jne    L45
  add    $0x8,%rdx
  cmp    %rsi,%rdx
  jne    L246
L26:
  mov    0x18(%rsp),%r11
  mov    (%rsp),%r13
  xor    %r10d,%r10d
  movslq %r14d,%rsi
  shl    $0x3,%r11
  test   %r14d,%r14d
  jle    L328
  nopl   0x0(%rax,%rax,1)
L46:
  mov    0x0(%r13,%r10,1),%r8
  xor    %r9d,%r9d
  nopl   0x0(%rax,%rax,1)
L20:
  mov    (%rbx,%r9,8),%rdx
  mov    (%r12,%r9,8),%rcx
  xor    %eax,%eax
  add    %r10,%rdx
  movsd  (%rdx),%xmm1
  nopl   0x0(%rax)
L13:
  movsd  (%r8,%rax,8),%xmm0
  mulsd  (%rcx,%rax,8),%xmm0
  add    $0x1,%rax
  addsd  %xmm0,%xmm1
  movsd  %xmm1,(%rdx)
  cmp    %rax,%rdi
  jne    L13
  add    $0x1,%r9
  cmp    %rsi,%r9
  jne    L20
  add    $0x8,%r10
  cmp    %r11,%r10
  jne    L46
L328:
  mov    0x10(%rsp),%rcx
  mov    0x8(%rsp),%eax
  xor    %esi,%esi
  movslq %r14d,%rdi
  lea    0x8(%rcx,%rax,8),%r8
  nopl   0x0(%rax)
L63:
  movq   $0x0,(%rcx)
  xor    %eax,%eax
  movapd %xmm2,%xmm1
  test   %r14d,%r14d
  jle    L364
  nopw   0x0(%rax,%rax,1)
L279:
  mov    (%rbx,%rax,8),%rdx
  movsd  (%rdx,%rsi,1),%xmm0
  mulsd  0x0(%rbp,%rax,8),%xmm0
  add    $0x1,%rax
  addsd  %xmm0,%xmm1
  movsd  %xmm1,(%rcx)
  cmp    %rax,%rdi
  jne    L279
L364:
  add    $0x8,%rcx
  add    $0x8,%rsi
  cmp    %r8,%rcx
  jne    L63
  test   %r15,%r15
  je     L90
  test   %r14d,%r14d
  jle    L90
L288:
  lea    -0x1(%r14),%eax
  cmp    $0x1,%eax
  jbe    L292
  lea    0x8(%r15),%rax
  cmp    %rax,%rbp
  je     L292
  mov    %r14d,%edx
  xor    %eax,%eax
  shr    %edx
  shl    $0x4,%rdx
L71:
  movupd (%r15,%rax,1),%xmm0
  movupd 0x0(%rbp,%rax,1),%xmm3
  mulpd  %xmm3,%xmm0
  movups %xmm0,0x0(%rbp,%rax,1)
  add    $0x10,%rax
  cmp    %rax,%rdx
  jne    L71
  mov    %r14d,%eax
  and    $0xfffffffe,%eax
  and    $0x1,%r14d
  je     L90
  lea    0x0(%rbp,%rax,8),%rdx
  movsd  (%rdx),%xmm0
  mulsd  (%r15,%rax,8),%xmm0
  movsd  %xmm0,(%rdx)
L90:
  mov    (%rsp),%rdi
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1070 <free2d@plt>
  nopl   0x0(%rax,%rax,1)
L115:
  movq   $0x0,(%r8,%rax,8)
  add    $0x1,%rax
  cmp    %rdi,%rax
  jne    L45
  add    $0x8,%rdx
  cmp    %rsi,%rdx
  jne    L246
  jmp    L26
L12:
  mov    0x20(%rsp),%rdx
  add    %rax,%rdx
  nop
L360:
  movsd  (%rax),%xmm0
  add    $0x8,%rax
  divsd  (%rdi),%xmm0
  movsd  %xmm0,-0x8(%rax)
  cmp    %rdx,%rax
  jne    L360
  jmp    L325
L291:
  lea    0x8(%rdi),%r11
  jmp    L325
L209:
  mov    (%rsp),%r8
  mov    %r14d,%edx
  mov    %r13d,%esi
  mov    %r12,%rdi
  mov    %rcx,0x20(%rsp)
  call   <svd@plt>
  lea    -0x1(%r13),%eax
  test   %r13d,%r13d
  mov    0x20(%rsp),%rcx
  mov    %eax,0x8(%rsp)
  jg     L159
  jmp    L90
L292:
  mov    %r14d,%r14d
  xor    %eax,%eax
L78:
  movsd  0x0(%rbp,%rax,8),%xmm0
  mulsd  (%r15,%rax,8),%xmm0
  movsd  %xmm0,0x0(%rbp,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%r14
  jne    L78
  jmp    L90
```

assistant: ```c
void svd_lsq(double **A, int ni, int nj, double *z, double *std, double *w, double *sol) {
  double **V = alloc2d(ni, ni + nj, sizeof(double));
  double **B = &V[ni];
  int nijmin = (ni < nj) ? ni : nj;
  int i, j, ii;
  if (std != NULL)
    for (j = 0; j < nj; ++j) {
      z[j] /= std[j];
      for (i = 0; i < ni; ++i)
        A[j][i] /= std[j];
    }
  svd(A, ni, nj, w, V);
  for (j = 0; j < ni; ++j)
    for (i = 0; i < nijmin; ++i)
      if (w[i] != 0.0)
        V[j][i] /= w[i];
      else
        V[j][i] = 0.0;
  for (i = 0; i < ni; ++i) {
    double *v = V[i];
    for (j = 0; j < nj; ++j) {
      double *a = A[j];
      double *b = &B[j][i];
      for (ii = 0; ii < nijmin; ++ii)
        *b += v[ii] * a[ii];
    }
  }
  for (i = 0; i < ni; ++i) {
    sol[i] = 0.0;
    for (j = 0; j < nj; ++j)
      sol[i] += B[j][i] * z[j];
  }
  if (std != NULL)
    for (j = 0; j < nj; ++j)
      z[j] *= std[j];
  free2d(V);
}
```