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

```asm
<solve>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,%rbp
  mov    %rsi,%r12
  mov    %edx,%eax
  mov    %edx,0xc(%rsp)
  mov    %ecx,%r14d
  mov    %fs:0x28,%rdx
  mov    %rdx,0x28(%rsp)
  xor    %edx,%edx
  mov    %ecx,0x18(%rsp)
  mov    %eax,0x1c(%rsp)
  lea    0x0(,%rax,4),%edi
  call   <malloc@plt>
  mov    %rax,%r15
  mov    0xc(%rsp),%eax
  mov    %eax,0x20(%rsp)
  imul   %eax,%eax
  lea    0x0(,%rax,8),%edi
  call   <malloc@plt>
  mov    %rax,%rbx
  mov    %r14d,%edi
  imul   0xc(%rsp),%edi
  shl    $0x3,%edi
  call   <malloc@plt>
  mov    %rax,%r13
  mov    $0x0,%esi
  cmpl   $0x0,0xc(%rsp)
  jg     L39
  cmp    $0x1,%r14d
  jg     L206
  jmp    L80
L14:
  mov    %eax,%edx
  imul   %esi,%edx
  add    %ecx,%edx
  movslq %edx,%rdx
  movsd  0x0(%rbp,%rdx,8),%xmm0
  imul   %ecx,%eax
  add    %esi,%eax
  cltq
  movsd  %xmm0,(%rbx,%rax,8)
  add    $0x1,%ecx
  mov    0xc(%rsp),%eax
  cmp    %ecx,%eax
  jg     L14
L131:
  add    $0x1,%esi
  cmp    %esi,0xc(%rsp)
  jle    L4
L39:
  mov    0xc(%rsp),%eax
  mov    $0x0,%ecx
  test   %eax,%eax
  jg     L14
  jmp    L131
L4:
  cmp    $0x1,%r14d
  jle    L199
L206:
  mov    $0x0,%esi
  cmpl   $0x0,0xc(%rsp)
  jg     L9
L109:
  lea    0x1c(%rsp),%rcx
  lea    0x18(%rsp),%rsi
  lea    0xc(%rsp),%rdi
  lea    0x24(%rsp),%rax
  push   %rax
  lea    0x28(%rsp),%rax
  push   %rax
  mov    %r13,%r9
  mov    %r15,%r8
  mov    %rbx,%rdx
  call   <dgesv_@plt>
  mov    0x1c(%rsp),%r9d
  add    $0x10,%rsp
  test   %r9d,%r9d
  jle    L165
  movslq %r9d,%rsi
  shl    $0x3,%rsi
  mov    $0x0,%r8d
  mov    $0x0,%edi
  lea    -0x1(%r9),%r11d
  lea    0x8(%r13),%r10
L155:
  movslq %r8d,%rdx
  lea    0x0(%r13,%rdx,8),%rax
  add    %r11,%rdx
  lea    (%r10,%rdx,8),%rcx
  mov    %r12,%rdx
L122:
  movsd  (%rax),%xmm0
  movsd  %xmm0,(%rdx)
  add    $0x8,%rax
  add    %rsi,%rdx
  cmp    %rcx,%rax
  jne    L122
  add    $0x1,%edi
  add    $0x8,%r12
  add    %r9d,%r8d
  cmp    %r9d,%edi
  jne    L155
L165:
  mov    %rbx,%rdi
  call   <free@plt>
  mov    %r13,%rdi
  call   <free@plt>
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L41
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L199:
  cmpl   $0x0,0xc(%rsp)
  jle    L80
  mov    %r13,%rax
  mov    $0x0,%edx
  mov    %r12,%rcx
  sub    %r13,%rcx
L59:
  movsd  (%rcx,%rax,1),%xmm0
  movsd  %xmm0,(%rax)
  add    $0x1,%edx
  add    $0x8,%rax
  cmp    %edx,0xc(%rsp)
  jg     L59
L80:
  lea    0x1c(%rsp),%rcx
  lea    0x18(%rsp),%rsi
  lea    0xc(%rsp),%rdi
  lea    0x24(%rsp),%rax
  push   %rax
  lea    0x28(%rsp),%rax
  push   %rax
  mov    %r13,%r9
  mov    %r15,%r8
  mov    %rbx,%rdx
  call   <dgesv_@plt>
  mov    0x1c(%rsp),%eax
  add    $0x10,%rsp
  test   %eax,%eax
  jle    L165
  mov    %eax,%eax
  lea    0x0(%r13,%rax,8),%rdx
  mov    %r13,%rax
  sub    %r13,%r12
L79:
  movsd  (%rax),%xmm0
  movsd  %xmm0,(%r12,%rax,1)
  add    $0x8,%rax
  cmp    %rdx,%rax
  jne    L79
  jmp    L165
L107:
  mov    %eax,%edx
  imul   %esi,%edx
  add    %ecx,%edx
  movslq %edx,%rdx
  movsd  (%r12,%rdx,8),%xmm0
  imul   %ecx,%eax
  add    %esi,%eax
  cltq
  movsd  %xmm0,0x0(%r13,%rax,8)
  add    $0x1,%ecx
  mov    0xc(%rsp),%eax
  cmp    %ecx,%eax
  jg     L107
L130:
  add    $0x1,%esi
  cmp    %esi,0xc(%rsp)
  jle    L109
L9:
  mov    0xc(%rsp),%eax
  mov    $0x0,%ecx
  test   %eax,%eax
  jg     L107
  jmp    L130
L41:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void solve(double *A, double *B, int nA, int nRHS) {
  int N = nA;
  int NRHS = nRHS;
  int LDA = nA;
  int *IPIV = (int *)malloc(sizeof(int) * nA);
  int LDB = nA;
  int INFO;
  double *AT = (double *)malloc(sizeof(double) * nA * nA);
  double *BT = (double *)malloc(sizeof(double) * nA * nRHS);
  int i, j;
  for (i = 0; i < nA; i++) {
    for (j = 0; j < nA; j++) {
      AT[i + nA * j] = A[j + nA * i];
    }
  }
  if (nRHS > 1) {
    for (i = 0; i < nA; i++) {
      for (j = 0; j < nA; j++) {
        BT[i + nA * j] = B[j + nA * i];
      }
    }
  } else {
    for (i = 0; i < nA; i++)
      BT[i] = B[i];
  }
  dgesv_(&nA, &NRHS, AT, &LDA, IPIV, BT, &LDB, &INFO);
  if (nRHS > 1) {
    for (i = 0; i < nA; i++) {
      for (j = 0; j < nA; j++) {
        B[i + nA * j] = BT[j + nA * i];
      }
    }
  } else {
    for (i = 0; i < nA; i++)
      B[i] = BT[i];
  }
  free(AT);
  free(BT);
  return;
}
```