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

```asm
<pca>:
  endbr64
  push   %r15
  movslq %esi,%r10
  mov    %edi,%r15d
  push   %r14
  lea    0x0(,%r10,4),%rax
  mov    %rdx,%r14
  push   %r13
  mov    %rax,%rdi
  mov    %r8,%r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rcx,%rbx
  sub    $0x38,%rsp
  mov    %esi,(%rsp)
  mov    %r10,0x8(%rsp)
  mov    %rax,0x20(%rsp)
  call   <malloc@plt>
  mov    0x8(%rsp),%r10
  mov    %rax,%r12
  lea    0x0(,%r10,8),%r11
  mov    %r10,0x10(%rsp)
  mov    %r11,%rdi
  mov    %r11,0x8(%rsp)
  call   <malloc@plt>
  mov    %rax,%rbp
  test   %r12,%r12
  je     L140
  test   %rax,%rax
  mov    0x8(%rsp),%r11
  mov    0x10(%rsp),%r10
  je     L59
  mov    (%rsp),%esi
  xor    %eax,%eax
  mov    %rbx,%r8
  mov    %r13,%rcx
  mov    %r14,%rdx
  mov    %r15d,%edi
  mov    %r10,0x18(%rsp)
  mov    %r11,0x8(%rsp)
  call   <svd@plt>
  mov    0x8(%rsp),%r11
  mov    0x18(%rsp),%r10
  test   %eax,%eax
  mov    %eax,0x10(%rsp)
  jne    L336
  cmp    %r15d,(%rsp)
  jle    L306
  test   %r15d,%r15d
  jle    L337
  mov    %r15d,%r8d
  lea    -0x1(%r15),%eax
  xor    %esi,%esi
  shl    $0x3,%r8
  lea    0x8(%rbx,%rax,8),%rdi
  cs nopw 0x0(%rax,%rax,1)
L92:
  movsd  0x0(%r13,%rsi,1),%xmm1
  mov    %rbx,%rax
  nopw   0x0(%rax,%rax,1)
L369:
  mov    (%rax),%rdx
  add    $0x8,%rax
  add    %rsi,%rdx
  movsd  (%rdx),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rdx)
  cmp    %rax,%rdi
  jne    L369
  add    $0x8,%rsi
  cmp    %rsi,%r8
  jne    L92
L337:
  xor    %eax,%eax
  mov    %r12,%rdx
  mov    %r13,%rsi
  mov    %r15d,%edi
  mov    %r10,0x8(%rsp)
  call   <sort@plt>
  mov    %r15d,%r8d
  mov    0x8(%rsp),%r10
  shr    $0x1f,%r8d
  add    %r15d,%r8d
  sar    %r8d
  cmp    $0x1,%r15d
  jle    L186
  lea    -0x1(%r15),%eax
  cltq
  lea    (%r12,%rax,4),%rdx
  xor    %eax,%eax
  nopl   (%rax)
L99:
  mov    (%rdx),%esi
  mov    (%r12,%rax,4),%ecx
  sub    $0x4,%rdx
  mov    %esi,(%r12,%rax,4)
  add    $0x1,%rax
  mov    %ecx,0x4(%rdx)
  cmp    %eax,%r8d
  jg     L99
L186:
  mov    (%rsp),%eax
  test   %eax,%eax
  jle    L302
  shl    $0x3,%r10
  xor    %edx,%edx
  movslq %r15d,%rsi
  nopw   0x0(%rax,%rax,1)
L318:
  xor    %eax,%eax
  test   %r15d,%r15d
  jle    L325
  nopw   0x0(%rax,%rax,1)
L75:
  movslq (%r12,%rax,4),%rcx
  mov    (%r14,%rcx,8),%rcx
  movsd  (%rcx,%rdx,1),%xmm0
  movsd  %xmm0,0x0(%rbp,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%rsi
  jne    L75
  xor    %eax,%eax
  xchg   %ax,%ax
L82:
  mov    (%r14,%rax,8),%rcx
  movsd  0x0(%rbp,%rax,8),%xmm0
  add    $0x1,%rax
  movsd  %xmm0,(%rcx,%rdx,1)
  cmp    %rax,%rsi
  jne    L82
L325:
  add    $0x8,%rdx
  cmp    %rdx,%r10
  jne    L318
L302:
  test   %r15d,%r15d
  jle    L336
  lea    -0x1(%r15),%eax
  mov    %rbx,%r14
  mov    %r15d,%r15d
  mov    %r13,(%rsp)
  lea    0x8(%rbx,%rax,8),%rax
  mov    %r14,%r13
  lea    0x0(,%r15,8),%rbx
  mov    %rax,%r14
  nopl   0x0(%rax,%rax,1)
L77:
  mov    0x0(%r13),%rdi
  xor    %eax,%eax
  cs nopw 0x0(%rax,%rax,1)
L238:
  movslq (%r12,%rax,4),%rdx
  movsd  (%rdi,%rdx,8),%xmm0
  movsd  %xmm0,0x0(%rbp,%rax,8)
  add    $0x1,%rax
  cmp    %r15,%rax
  jne    L238
  mov    %rbx,%rdx
  mov    %rbp,%rsi
  add    $0x8,%r13
  call   <memcpy@plt>
  cmp    %r13,%r14
  jne    L77
  mov    (%rsp),%r13
  xor    %eax,%eax
  nopw   0x0(%rax,%rax,1)
L121:
  movslq (%r12,%rax,4),%rdx
  movsd  0x0(%r13,%rdx,8),%xmm0
  movsd  %xmm0,0x0(%rbp,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%r15
  jne    L121
  mov    %rbx,%rdx
  mov    %rbp,%rsi
  mov    %r13,%rdi
  call   <memcpy@plt>
L336:
  mov    %r12,%rdi
  call   <free@plt>
  mov    %rbp,%rdi
  call   <free@plt>
L307:
  mov    0x10(%rsp),%eax
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L306:
  mov    (%rsp),%ecx
  test   %ecx,%ecx
  jle    L260
  lea    -0x1(%r15),%eax
  xor    %esi,%esi
  lea    0x8(%r14,%rax,8),%rdi
  nopw   0x0(%rax,%rax,1)
L64:
  movsd  0x0(%r13,%rsi,1),%xmm1
  mov    %r14,%rax
  test   %r15d,%r15d
  jle    L31
  nop
L152:
  mov    (%rax),%rdx
  add    $0x8,%rax
  add    %rsi,%rdx
  movsd  (%rdx),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rdx)
  cmp    %rax,%rdi
  jne    L152
L31:
  add    $0x8,%rsi
  cmp    %rsi,%r11
  jne    L64
L260:
  mov    (%rsp),%edi
  mov    %r12,%rdx
  xor    %eax,%eax
  mov    %r13,%rsi
  mov    %r10,0x8(%rsp)
  call   <sort@plt>
  mov    (%rsp),%edi
  mov    0x20(%rsp),%rax
  mov    0x8(%rsp),%r10
  mov    %edi,%r8d
  lea    -0x4(%r12,%rax,1),%rdx
  xor    %eax,%eax
  shr    $0x1f,%r8d
  add    %edi,%r8d
  sar    %r8d
  cmp    $0x1,%edi
  jle    L68
  nop
L45:
  mov    (%rdx),%esi
  mov    (%r12,%rax,4),%ecx
  sub    $0x4,%rdx
  mov    %esi,(%r12,%rax,4)
  add    $0x1,%rax
  mov    %ecx,0x4(%rdx)
  cmp    %eax,%r8d
  jg     L45
L68:
  test   %r15d,%r15d
  jle    L56
  lea    -0x1(%r15),%eax
  mov    %r14,%r8
  mov    %r10,0x28(%rsp)
  lea    0x8(%r14,%rax,8),%rax
  mov    %rbx,0x18(%rsp)
  mov    %rax,0x8(%rsp)
  mov    (%rsp),%eax
  mov    %r13,0x20(%rsp)
  mov    %rbp,%r13
  mov    %r8,%rbp
  lea    -0x1(%rax),%r14d
  lea    0x8(,%r14,8),%r15
  mov    %r15,%rbx
  mov    %eax,%r15d
  xchg   %ax,%ax
L331:
  test   %r15d,%r15d
  jle    L355
  mov    0x0(%rbp),%rdi
  xor    %eax,%eax
  nopl   0x0(%rax,%rax,1)
L134:
  movslq (%r12,%rax,4),%rdx
  movsd  (%rdi,%rdx,8),%xmm0
  mov    %rax,%rdx
  movsd  %xmm0,0x0(%r13,%rax,8)
  add    $0x1,%rax
  cmp    %r14,%rdx
  jne    L134
  mov    %rbx,%rdx
  mov    %r13,%rsi
  call   <memcpy@plt>
L355:
  add    $0x8,%rbp
  cmp    0x8(%rsp),%rbp
  jne    L331
  mov    %r13,%rbp
  mov    0x18(%rsp),%rbx
  mov    0x20(%rsp),%r13
  mov    0x28(%rsp),%r10
L56:
  mov    (%rsp),%edx
  test   %edx,%edx
  jle    L336
  lea    0x0(,%r10,8),%r8
  xor    %edx,%edx
  nopl   0x0(%rax)
L297:
  xor    %eax,%eax
  nopw   0x0(%rax,%rax,1)
L226:
  movslq (%r12,%rax,4),%rcx
  mov    (%rbx,%rcx,8),%rcx
  movsd  (%rcx,%rdx,1),%xmm0
  movsd  %xmm0,0x0(%rbp,%rax,8)
  add    $0x1,%rax
  cmp    %r10,%rax
  jne    L226
  xor    %eax,%eax
  cs nopw 0x0(%rax,%rax,1)
L144:
  mov    (%rbx,%rax,8),%rcx
  movsd  0x0(%rbp,%rax,8),%xmm0
  add    $0x1,%rax
  movsd  %xmm0,(%rcx,%rdx,1)
  cmp    %rax,%r10
  jne    L144
  add    $0x8,%rdx
  cmp    %rdx,%r8
  jne    L297
  xor    %eax,%eax
  nopl   0x0(%rax,%rax,1)
L32:
  movslq (%r12,%rax,4),%rdx
  movsd  0x0(%r13,%rdx,8),%xmm0
  movsd  %xmm0,0x0(%rbp,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%r10
  jne    L32
  mov    %r8,%rdx
  mov    %rbp,%rsi
  mov    %r13,%rdi
  call   <memcpy@plt>
  jmp    L336
L59:
  test   %r12,%r12
  je     L140
  mov    %r12,%rdi
  call   <free@plt>
L140:
  test   %rbp,%rbp
  je     L11
  mov    %rbp,%rdi
  call   <free@plt>
  movl   $0xffffffff,0x10(%rsp)
  jmp    L307
L11:
  movl   $0xffffffff,0x10(%rsp)
  jmp    L307
```

assistant: ```c
int pca(int nrows, int ncolumns, double **u, double **v, double *w) {
  int i;
  int j;
  int error;
  int *index = malloc(ncolumns * sizeof(int));
  double *temp = malloc(ncolumns * sizeof(double));
  if (!index || !temp) {
    if (index)
      free(index);
    if (temp)
      free(temp);
    return -1;
  }
  error = svd(nrows, ncolumns, u, w, v);
  if (error == 0) {
    if (nrows >= ncolumns) {
      for (j = 0; j < ncolumns; j++) {
        const double s = w[j];
        for (i = 0; i < nrows; i++)
          u[i][j] *= s;
      }
      sort(ncolumns, w, index);
      for (i = 0; i < ncolumns / 2; i++) {
        j = index[i];
        index[i] = index[ncolumns - 1 - i];
        index[ncolumns - 1 - i] = j;
      }
      for (i = 0; i < nrows; i++) {
        for (j = 0; j < ncolumns; j++)
          temp[j] = u[i][index[j]];
        for (j = 0; j < ncolumns; j++)
          u[i][j] = temp[j];
      }
      for (i = 0; i < ncolumns; i++) {
        for (j = 0; j < ncolumns; j++)
          temp[j] = v[index[j]][i];
        for (j = 0; j < ncolumns; j++)
          v[j][i] = temp[j];
      }
      for (i = 0; i < ncolumns; i++)
        temp[i] = w[index[i]];
      for (i = 0; i < ncolumns; i++)
        w[i] = temp[i];
    } else {
      for (j = 0; j < nrows; j++) {
        const double s = w[j];
        for (i = 0; i < nrows; i++)
          v[i][j] *= s;
      }
      sort(nrows, w, index);
      for (i = 0; i < nrows / 2; i++) {
        j = index[i];
        index[i] = index[nrows - 1 - i];
        index[nrows - 1 - i] = j;
      }
      for (j = 0; j < ncolumns; j++) {
        for (i = 0; i < nrows; i++)
          temp[i] = u[index[i]][j];
        for (i = 0; i < nrows; i++)
          u[i][j] = temp[i];
      }
      for (j = 0; j < nrows; j++) {
        for (i = 0; i < nrows; i++)
          temp[i] = v[j][index[i]];
        for (i = 0; i < nrows; i++)
          v[j][i] = temp[i];
      }
      for (i = 0; i < nrows; i++)
        temp[i] = w[index[i]];
      for (i = 0; i < nrows; i++)
        w[i] = temp[i];
    }
  }
  free(index);
  free(temp);
  return error;
}
```